2014-04-14 14:26:48 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2009-10-12 16:36:19 +00:00
|
|
|
|
2014-04-14 14:26:48 +00:00
|
|
|
with lib;
|
2008-09-04 20:28:02 +00:00
|
|
|
|
2009-03-06 12:26:26 +00:00
|
|
|
let
|
2009-10-12 16:36:19 +00:00
|
|
|
|
|
|
|
cfg = config.services.gnunet;
|
|
|
|
|
2021-08-14 20:16:58 +00:00
|
|
|
stateDir = "/var/lib/gnunet";
|
2013-04-24 15:03:29 +00:00
|
|
|
|
2021-08-14 20:16:58 +00:00
|
|
|
configFile = with cfg;
|
2009-10-12 16:36:19 +00:00
|
|
|
''
|
|
|
|
[PATHS]
|
2021-08-14 20:16:58 +00:00
|
|
|
GNUNET_HOME = ${stateDir}
|
|
|
|
GNUNET_RUNTIME_DIR = /run/gnunet
|
|
|
|
GNUNET_USER_RUNTIME_DIR = /run/gnunet
|
|
|
|
GNUNET_DATA_HOME = ${stateDir}/data
|
2009-10-12 16:36:19 +00:00
|
|
|
|
2013-04-24 15:03:29 +00:00
|
|
|
[ats]
|
|
|
|
WAN_QUOTA_IN = ${toString load.maxNetDownBandwidth} b
|
|
|
|
WAN_QUOTA_OUT = ${toString load.maxNetUpBandwidth} b
|
2009-10-12 16:36:19 +00:00
|
|
|
|
2013-04-24 15:03:29 +00:00
|
|
|
[datastore]
|
|
|
|
QUOTA = ${toString fileSharing.quota} MB
|
2009-10-12 16:36:19 +00:00
|
|
|
|
2013-04-24 15:03:29 +00:00
|
|
|
[transport-udp]
|
2010-01-23 15:47:33 +00:00
|
|
|
PORT = ${toString udp.port}
|
2013-04-24 15:03:29 +00:00
|
|
|
ADVERTISED_PORT = ${toString udp.port}
|
2010-01-23 15:47:33 +00:00
|
|
|
|
2013-04-24 15:03:29 +00:00
|
|
|
[transport-tcp]
|
2010-01-23 15:47:33 +00:00
|
|
|
PORT = ${toString tcp.port}
|
2013-04-24 15:03:29 +00:00
|
|
|
ADVERTISED_PORT = ${toString tcp.port}
|
2009-10-12 16:36:19 +00:00
|
|
|
|
|
|
|
${extraOptions}
|
|
|
|
'';
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
2008-09-04 20:28:02 +00:00
|
|
|
|
2009-03-06 12:26:26 +00:00
|
|
|
options = {
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
services.gnunet = {
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
enable = mkOption {
|
2020-01-04 09:41:33 +00:00
|
|
|
type = types.bool;
|
2009-10-12 16:36:19 +00:00
|
|
|
default = false;
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
Whether to run the GNUnet daemon. GNUnet is GNU's anonymous
|
|
|
|
peer-to-peer communication and file sharing framework.
|
|
|
|
'';
|
|
|
|
};
|
2008-09-04 20:28:02 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
fileSharing = {
|
|
|
|
quota = mkOption {
|
2020-01-04 09:41:33 +00:00
|
|
|
type = types.int;
|
2009-10-12 16:36:19 +00:00
|
|
|
default = 1024;
|
2009-03-06 12:26:26 +00:00
|
|
|
description = lib.mdDoc ''
|
2009-10-12 16:36:19 +00:00
|
|
|
Maximum file system usage (in MiB) for file sharing.
|
2009-03-06 12:26:26 +00:00
|
|
|
'';
|
|
|
|
};
|
2009-10-12 16:36:19 +00:00
|
|
|
};
|
2009-03-06 12:26:26 +00:00
|
|
|
|
2010-01-23 15:47:33 +00:00
|
|
|
udp = {
|
|
|
|
port = mkOption {
|
2020-01-04 09:41:33 +00:00
|
|
|
type = types.port;
|
2010-01-23 15:47:33 +00:00
|
|
|
default = 2086; # assigned by IANA
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
The UDP port for use by GNUnet.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
tcp = {
|
|
|
|
port = mkOption {
|
2020-01-04 09:41:33 +00:00
|
|
|
type = types.port;
|
2010-01-23 15:47:33 +00:00
|
|
|
default = 2086; # assigned by IANA
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
The TCP port for use by GNUnet.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
load = {
|
|
|
|
maxNetDownBandwidth = mkOption {
|
2020-01-04 09:41:33 +00:00
|
|
|
type = types.int;
|
2009-10-12 16:36:19 +00:00
|
|
|
default = 50000;
|
2009-03-06 12:26:26 +00:00
|
|
|
description = lib.mdDoc ''
|
2009-10-12 16:36:19 +00:00
|
|
|
Maximum bandwidth usage (in bits per second) for GNUnet
|
|
|
|
when downloading data.
|
2009-03-06 12:26:26 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
maxNetUpBandwidth = mkOption {
|
2020-01-04 09:41:33 +00:00
|
|
|
type = types.int;
|
2009-10-12 16:36:19 +00:00
|
|
|
default = 50000;
|
2009-03-06 12:26:26 +00:00
|
|
|
description = lib.mdDoc ''
|
2009-10-12 16:36:19 +00:00
|
|
|
Maximum bandwidth usage (in bits per second) for GNUnet
|
|
|
|
when downloading data.
|
2009-03-06 12:26:26 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
hardNetUpBandwidth = mkOption {
|
2020-01-04 09:41:33 +00:00
|
|
|
type = types.int;
|
2009-10-12 16:36:19 +00:00
|
|
|
default = 0;
|
2009-03-06 12:26:26 +00:00
|
|
|
description = lib.mdDoc ''
|
2009-10-12 16:36:19 +00:00
|
|
|
Hard bandwidth limit (in bits per second) when uploading
|
|
|
|
data.
|
2009-03-06 12:26:26 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2009-10-12 16:36:19 +00:00
|
|
|
|
2023-11-27 00:19:27 +00:00
|
|
|
package = mkPackageOption pkgs "gnunet" {
|
|
|
|
example = "gnunet_git";
|
2018-04-29 18:36:06 +00:00
|
|
|
};
|
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
extraOptions = mkOption {
|
2020-01-04 09:41:33 +00:00
|
|
|
type = types.lines;
|
2009-10-12 16:36:19 +00:00
|
|
|
default = "";
|
|
|
|
description = lib.mdDoc ''
|
2023-01-21 10:06:46 +00:00
|
|
|
Additional options that will be copied verbatim in `gnunet.conf`.
|
|
|
|
See {manpage}`gnunet.conf(5)` for details.
|
2009-10-12 16:36:19 +00:00
|
|
|
'';
|
|
|
|
};
|
2009-03-06 12:26:26 +00:00
|
|
|
};
|
2009-10-12 16:36:19 +00:00
|
|
|
|
2009-03-06 12:26:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.gnunet.enable {
|
2008-09-04 20:28:02 +00:00
|
|
|
|
2018-06-29 23:58:35 +00:00
|
|
|
users.users.gnunet = {
|
2013-08-26 13:20:25 +00:00
|
|
|
group = "gnunet";
|
|
|
|
description = "GNUnet User";
|
|
|
|
uid = config.ids.uids.gnunet;
|
|
|
|
};
|
2009-10-12 16:36:19 +00:00
|
|
|
|
2018-06-29 23:58:35 +00:00
|
|
|
users.groups.gnunet.gid = config.ids.gids.gnunet;
|
2013-05-28 08:19:59 +00:00
|
|
|
|
2010-01-23 15:47:33 +00:00
|
|
|
# The user tools that talk to `gnunetd' should come from the same source,
|
|
|
|
# so install them globally.
|
2018-04-29 18:36:06 +00:00
|
|
|
environment.systemPackages = [ cfg.package ];
|
2010-01-23 15:47:33 +00:00
|
|
|
|
2021-08-14 20:16:58 +00:00
|
|
|
environment.etc."gnunet.conf".text = configFile;
|
|
|
|
|
2013-04-24 15:03:29 +00:00
|
|
|
systemd.services.gnunet = {
|
|
|
|
description = "GNUnet";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2023-06-09 16:33:51 +00:00
|
|
|
restartTriggers = [ config.environment.etc."gnunet.conf".source ];
|
2018-04-29 18:36:06 +00:00
|
|
|
path = [ cfg.package pkgs.miniupnpc ];
|
2021-08-14 20:16:58 +00:00
|
|
|
serviceConfig.ExecStart = "${cfg.package}/lib/gnunet/libexec/gnunet-service-arm -c /etc/gnunet.conf";
|
2013-04-24 15:03:29 +00:00
|
|
|
serviceConfig.User = "gnunet";
|
|
|
|
serviceConfig.UMask = "0007";
|
2021-08-14 20:16:58 +00:00
|
|
|
serviceConfig.WorkingDirectory = stateDir;
|
|
|
|
serviceConfig.RuntimeDirectory = "gnunet";
|
|
|
|
serviceConfig.StateDirectory = "gnunet";
|
2013-04-24 15:03:29 +00:00
|
|
|
};
|
2009-10-12 16:36:19 +00:00
|
|
|
|
2009-03-06 12:26:26 +00:00
|
|
|
};
|
2009-10-12 16:36:19 +00:00
|
|
|
|
2008-09-04 20:28:02 +00:00
|
|
|
}
|