1 { config, lib, pkgs, ... }:
4 cfg = config.services.gnunet;
6 stateDir = "/var/lib/gnunet";
11 GNUNET_HOME = ${stateDir}
12 GNUNET_RUNTIME_DIR = /run/gnunet
13 GNUNET_USER_RUNTIME_DIR = /run/gnunet
14 GNUNET_DATA_HOME = ${stateDir}/data
17 WAN_QUOTA_IN = ${toString load.maxNetDownBandwidth} b
18 WAN_QUOTA_OUT = ${toString load.maxNetUpBandwidth} b
21 QUOTA = ${toString fileSharing.quota} MB
24 PORT = ${toString udp.port}
25 ADVERTISED_PORT = ${toString udp.port}
28 PORT = ${toString tcp.port}
29 ADVERTISED_PORT = ${toString tcp.port}
44 enable = lib.mkOption {
45 type = lib.types.bool;
48 Whether to run the GNUnet daemon. GNUnet is GNU's anonymous
49 peer-to-peer communication and file sharing framework.
54 quota = lib.mkOption {
58 Maximum file system usage (in MiB) for file sharing.
65 type = lib.types.port;
66 default = 2086; # assigned by IANA
68 The UDP port for use by GNUnet.
75 type = lib.types.port;
76 default = 2086; # assigned by IANA
78 The TCP port for use by GNUnet.
84 maxNetDownBandwidth = lib.mkOption {
88 Maximum bandwidth usage (in bits per second) for GNUnet
89 when downloading data.
93 maxNetUpBandwidth = lib.mkOption {
97 Maximum bandwidth usage (in bits per second) for GNUnet
98 when downloading data.
102 hardNetUpBandwidth = lib.mkOption {
103 type = lib.types.int;
106 Hard bandwidth limit (in bits per second) when uploading
112 package = lib.mkPackageOption pkgs "gnunet" {
113 example = "gnunet_git";
116 extraOptions = lib.mkOption {
117 type = lib.types.lines;
120 Additional options that will be copied verbatim in `gnunet.conf`.
121 See {manpage}`gnunet.conf(5)` for details.
129 ###### implementation
131 config = lib.mkIf config.services.gnunet.enable {
133 users.users.gnunet = {
135 description = "GNUnet User";
136 uid = config.ids.uids.gnunet;
139 users.groups.gnunet.gid = config.ids.gids.gnunet;
141 # The user tools that talk to `gnunetd' should come from the same source,
142 # so install them globally.
143 environment.systemPackages = [ cfg.package ];
145 environment.etc."gnunet.conf".text = configFile;
147 systemd.services.gnunet = {
148 description = "GNUnet";
149 after = [ "network.target" ];
150 wantedBy = [ "multi-user.target" ];
151 restartTriggers = [ config.environment.etc."gnunet.conf".source ];
152 path = [ cfg.package pkgs.miniupnpc ];
153 serviceConfig.ExecStart = "${cfg.package}/lib/gnunet/libexec/gnunet-service-arm -c /etc/gnunet.conf";
154 serviceConfig.User = "gnunet";
155 serviceConfig.UMask = "0007";
156 serviceConfig.WorkingDirectory = stateDir;
157 serviceConfig.RuntimeDirectory = "gnunet";
158 serviceConfig.StateDirectory = "gnunet";