1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7let
8 cfg = config.services.i2p;
9 homeDir = "/var/lib/i2p";
10in
11{
12 ###### interface
13 options.services.i2p.enable = lib.mkEnableOption "I2P router";
14
15 ###### implementation
16 config = lib.mkIf cfg.enable {
17 users.users.i2p = {
18 group = "i2p";
19 description = "i2p User";
20 home = homeDir;
21 createHome = true;
22 uid = config.ids.uids.i2p;
23 };
24 users.groups.i2p.gid = config.ids.gids.i2p;
25 systemd.services.i2p = {
26 description = "I2P router with administration interface for hidden services";
27 after = [ "network.target" ];
28 wantedBy = [ "multi-user.target" ];
29 serviceConfig = {
30 User = "i2p";
31 WorkingDirectory = homeDir;
32 Restart = "on-abort";
33 ExecStart = "${pkgs.i2p}/bin/i2prouter";
34 };
35 };
36 };
37}