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;
|
|
|
|
|
2013-04-24 15:03:29 +00:00
|
|
|
homeDir = "/var/lib/gnunet";
|
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
configFile = with cfg; pkgs.writeText "gnunetd.conf"
|
|
|
|
''
|
|
|
|
[PATHS]
|
2013-04-24 15:03:29 +00:00
|
|
|
SERVICEHOME = ${homeDir}
|
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 {
|
|
|
|
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 20:28:02 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
fileSharing = {
|
|
|
|
quota = mkOption {
|
|
|
|
default = 1024;
|
2009-03-06 12:26:26 +00:00
|
|
|
description = ''
|
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 {
|
|
|
|
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 16:36:19 +00:00
|
|
|
load = {
|
|
|
|
maxNetDownBandwidth = mkOption {
|
|
|
|
default = 50000;
|
2009-03-06 12:26:26 +00:00
|
|
|
description = ''
|
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 {
|
|
|
|
default = 50000;
|
2009-03-06 12:26:26 +00:00
|
|
|
description = ''
|
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 {
|
|
|
|
default = 0;
|
2009-03-06 12:26:26 +00:00
|
|
|
description = ''
|
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
|
|
|
|
|
|
|
extraOptions = mkOption {
|
|
|
|
default = "";
|
|
|
|
description = ''
|
2013-04-24 15:03:29 +00:00
|
|
|
Additional options that will be copied verbatim in `gnunet.conf'.
|
|
|
|
See `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
|
|
|
|
2013-08-26 13:20:25 +00:00
|
|
|
users.extraUsers.gnunet = {
|
|
|
|
group = "gnunet";
|
|
|
|
description = "GNUnet User";
|
|
|
|
home = homeDir;
|
|
|
|
createHome = true;
|
|
|
|
uid = config.ids.uids.gnunet;
|
|
|
|
};
|
2009-10-12 16:36:19 +00:00
|
|
|
|
2013-08-26 13:20:25 +00:00
|
|
|
users.extraGroups.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.
|
|
|
|
environment.systemPackages = [ pkgs.gnunet ];
|
|
|
|
|
2013-04-24 15:03:29 +00:00
|
|
|
systemd.services.gnunet = {
|
|
|
|
description = "GNUnet";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2013-05-07 16:53:28 +00:00
|
|
|
path = [ pkgs.gnunet pkgs.miniupnpc ];
|
2013-04-24 16:17:14 +00:00
|
|
|
serviceConfig.ExecStart = "${pkgs.gnunet}/lib/gnunet/libexec/gnunet-service-arm -c ${configFile}";
|
2013-04-24 15:03:29 +00:00
|
|
|
serviceConfig.User = "gnunet";
|
|
|
|
serviceConfig.UMask = "0007";
|
|
|
|
serviceConfig.WorkingDirectory = homeDir;
|
|
|
|
};
|
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
|
|
|
}
|