9 cfg = config.services.gnunet;
11 stateDir = "/var/lib/gnunet";
13 configFile = with cfg; ''
15 GNUNET_HOME = ${stateDir}
16 GNUNET_RUNTIME_DIR = /run/gnunet
17 GNUNET_USER_RUNTIME_DIR = /run/gnunet
18 GNUNET_DATA_HOME = ${stateDir}/data
21 WAN_QUOTA_IN = ${toString load.maxNetDownBandwidth} b
22 WAN_QUOTA_OUT = ${toString load.maxNetUpBandwidth} b
25 QUOTA = ${toString fileSharing.quota} MB
28 PORT = ${toString udp.port}
29 ADVERTISED_PORT = ${toString udp.port}
32 PORT = ${toString tcp.port}
33 ADVERTISED_PORT = ${toString tcp.port}
48 enable = lib.mkOption {
49 type = lib.types.bool;
52 Whether to run the GNUnet daemon. GNUnet is GNU's anonymous
53 peer-to-peer communication and file sharing framework.
58 quota = lib.mkOption {
62 Maximum file system usage (in MiB) for file sharing.
69 type = lib.types.port;
70 default = 2086; # assigned by IANA
72 The UDP port for use by GNUnet.
79 type = lib.types.port;
80 default = 2086; # assigned by IANA
82 The TCP port for use by GNUnet.
88 maxNetDownBandwidth = lib.mkOption {
92 Maximum bandwidth usage (in bits per second) for GNUnet
93 when downloading data.
97 maxNetUpBandwidth = lib.mkOption {
101 Maximum bandwidth usage (in bits per second) for GNUnet
102 when downloading data.
106 hardNetUpBandwidth = lib.mkOption {
107 type = lib.types.int;
110 Hard bandwidth limit (in bits per second) when uploading
116 package = lib.mkPackageOption pkgs "gnunet" {
117 example = "gnunet_git";
120 extraOptions = lib.mkOption {
121 type = lib.types.lines;
124 Additional options that will be copied verbatim in `gnunet.conf`.
125 See {manpage}`gnunet.conf(5)` for details.
132 ###### implementation
134 config = lib.mkIf config.services.gnunet.enable {
136 users.users.gnunet = {
138 description = "GNUnet User";
139 uid = config.ids.uids.gnunet;
142 users.groups.gnunet.gid = config.ids.gids.gnunet;
144 # The user tools that talk to `gnunetd' should come from the same source,
145 # so install them globally.
146 environment.systemPackages = [ cfg.package ];
148 environment.etc."gnunet.conf".text = configFile;
150 systemd.services.gnunet = {
151 description = "GNUnet";
152 after = [ "network.target" ];
153 wantedBy = [ "multi-user.target" ];
154 restartTriggers = [ config.environment.etc."gnunet.conf".source ];
159 serviceConfig.ExecStart = "${cfg.package}/lib/gnunet/libexec/gnunet-service-arm -c /etc/gnunet.conf";
160 serviceConfig.User = "gnunet";
161 serviceConfig.UMask = "0007";
162 serviceConfig.WorkingDirectory = stateDir;
163 serviceConfig.RuntimeDirectory = "gnunet";
164 serviceConfig.StateDirectory = "gnunet";