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