1 { config, lib, pkgs, ... }:
7 cfg = config.services.gnunet;
9 stateDir = "/var/lib/gnunet";
11 configFile = with cfg;
14 GNUNET_HOME = ${stateDir}
15 GNUNET_RUNTIME_DIR = /run/gnunet
16 GNUNET_USER_RUNTIME_DIR = /run/gnunet
17 GNUNET_DATA_HOME = ${stateDir}/data
20 WAN_QUOTA_IN = ${toString load.maxNetDownBandwidth} b
21 WAN_QUOTA_OUT = ${toString load.maxNetUpBandwidth} b
24 QUOTA = ${toString fileSharing.quota} MB
27 PORT = ${toString udp.port}
28 ADVERTISED_PORT = ${toString udp.port}
31 PORT = ${toString tcp.port}
32 ADVERTISED_PORT = ${toString tcp.port}
50 description = lib.mdDoc ''
51 Whether to run the GNUnet daemon. GNUnet is GNU's anonymous
52 peer-to-peer communication and file sharing framework.
60 description = lib.mdDoc ''
61 Maximum file system usage (in MiB) for file sharing.
69 default = 2086; # assigned by IANA
70 description = lib.mdDoc ''
71 The UDP port for use by GNUnet.
79 default = 2086; # assigned by IANA
80 description = lib.mdDoc ''
81 The TCP port for use by GNUnet.
87 maxNetDownBandwidth = mkOption {
90 description = lib.mdDoc ''
91 Maximum bandwidth usage (in bits per second) for GNUnet
92 when downloading data.
96 maxNetUpBandwidth = mkOption {
99 description = lib.mdDoc ''
100 Maximum bandwidth usage (in bits per second) for GNUnet
101 when downloading data.
105 hardNetUpBandwidth = mkOption {
108 description = lib.mdDoc ''
109 Hard bandwidth limit (in bits per second) when uploading
116 type = types.package;
117 default = pkgs.gnunet;
118 defaultText = literalExpression "pkgs.gnunet";
119 description = lib.mdDoc "Overridable attribute of the gnunet package to use.";
120 example = literalExpression "pkgs.gnunet_git";
123 extraOptions = mkOption {
126 description = lib.mdDoc ''
127 Additional options that will be copied verbatim in `gnunet.conf'.
128 See `gnunet.conf(5)' for details.
136 ###### implementation
138 config = mkIf config.services.gnunet.enable {
140 users.users.gnunet = {
142 description = "GNUnet User";
143 uid = config.ids.uids.gnunet;
146 users.groups.gnunet.gid = config.ids.gids.gnunet;
148 # The user tools that talk to `gnunetd' should come from the same source,
149 # so install them globally.
150 environment.systemPackages = [ cfg.package ];
152 environment.etc."gnunet.conf".text = configFile;
154 systemd.services.gnunet = {
155 description = "GNUnet";
156 after = [ "network.target" ];
157 wantedBy = [ "multi-user.target" ];
158 restartTriggers = [ configFile ];
159 path = [ cfg.package pkgs.miniupnpc ];
160 serviceConfig.ExecStart = "${cfg.package}/lib/gnunet/libexec/gnunet-service-arm -c /etc/gnunet.conf";
161 serviceConfig.User = "gnunet";
162 serviceConfig.UMask = "0007";
163 serviceConfig.WorkingDirectory = stateDir;
164 serviceConfig.RuntimeDirectory = "gnunet";
165 serviceConfig.StateDirectory = "gnunet";