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