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