2009-10-12 18:36:19 +02:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.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;
|
|
|
|
|
|
|
|
configFile = with cfg; pkgs.writeText "gnunetd.conf"
|
|
|
|
''
|
|
|
|
[PATHS]
|
|
|
|
GNUNETD_HOME = ${home}
|
|
|
|
|
|
|
|
[GNUNETD]
|
2010-01-23 16:47:33 +01:00
|
|
|
HOSTLISTURL = ${concatStringsSep " " hostLists}
|
|
|
|
APPLICATIONS = ${concatStringsSep " " applications}
|
|
|
|
TRANSPORTS = ${concatStringsSep " " transports}
|
2009-10-12 18:36:19 +02:00
|
|
|
|
|
|
|
[LOAD]
|
|
|
|
MAXNETDOWNBPSTOTAL = ${toString load.maxNetDownBandwidth}
|
|
|
|
MAXNETUPBPSTOTAL = ${toString load.maxNetUpBandwidth}
|
|
|
|
HARDUPLIMIT = ${toString load.hardNetUpBandwidth}
|
|
|
|
MAXCPULOAD = ${toString load.maxCPULoad}
|
2010-01-23 16:47:33 +01:00
|
|
|
INTERFACES = ${concatStringsSep " " load.interfaces}
|
2009-10-12 18:36:19 +02:00
|
|
|
|
|
|
|
[FS]
|
|
|
|
QUOTA = ${toString fileSharing.quota}
|
|
|
|
ACTIVEMIGRATION = ${if fileSharing.activeMigration then "YES" else "NO"}
|
|
|
|
|
2010-01-23 16:47:33 +01:00
|
|
|
[UDP]
|
|
|
|
PORT = ${toString udp.port}
|
|
|
|
|
|
|
|
[TCP]
|
|
|
|
PORT = ${toString tcp.port}
|
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
[MODULES]
|
|
|
|
sqstore = sqstore_sqlite
|
|
|
|
dstore = dstore_sqlite
|
|
|
|
topology = topology_default
|
|
|
|
|
|
|
|
${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
|
|
|
home = mkOption {
|
|
|
|
default = "/var/lib/gnunet";
|
|
|
|
description = ''
|
|
|
|
Directory where the GNUnet daemon will store its data.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
debug = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
When true, run in debug mode; gnunetd will not daemonize and
|
|
|
|
error messages will be written to stderr instead of a
|
|
|
|
logfile.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
logLevel = mkOption {
|
|
|
|
default = "ERROR";
|
|
|
|
example = "INFO";
|
|
|
|
description = ''
|
|
|
|
Log level of the deamon (see `gnunetd(1)' for details).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
hostLists = mkOption {
|
|
|
|
default = [
|
|
|
|
"http://gnunet.org/hostlist.php"
|
|
|
|
"http://gnunet.mine.nu:8081/hostlist"
|
|
|
|
"http://vserver1236.vserver-on.de/hostlist-074"
|
|
|
|
];
|
|
|
|
description = ''
|
|
|
|
URLs of host lists.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
applications = mkOption {
|
|
|
|
default = [ "advertising" "getoption" "fs" "stats" "traffic" ];
|
|
|
|
example = [ "chat" "fs" ];
|
|
|
|
description = ''
|
|
|
|
List of GNUnet applications supported by the daemon. Note that
|
|
|
|
`fs', which means "file sharing", is probably the one you want.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
transports = mkOption {
|
|
|
|
default = [ "udp" "tcp" "http" "nat" ];
|
|
|
|
example = [ "smtp" "http" ];
|
|
|
|
description = ''
|
|
|
|
List of transport methods used by the server.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
activeMigration = mkOption {
|
2009-03-06 13:26:26 +01:00
|
|
|
default = false;
|
|
|
|
description = ''
|
2009-10-12 18:36:19 +02:00
|
|
|
Whether to allow active migration of content originating
|
|
|
|
from other nodes.
|
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
|
|
|
maxCPULoad = mkOption {
|
|
|
|
default = 100;
|
2009-03-06 13:26:26 +01:00
|
|
|
description = ''
|
2009-10-12 18:36:19 +02:00
|
|
|
Maximum CPU load (percentage) authorized for the GNUnet
|
|
|
|
daemon.
|
2009-03-06 13:26:26 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
interfaces = mkOption {
|
|
|
|
default = [ "eth0" ];
|
|
|
|
example = [ "wlan0" "eth1" ];
|
2009-03-06 13:26:26 +01:00
|
|
|
description = ''
|
2009-10-12 18:36:19 +02:00
|
|
|
List of network interfaces to use.
|
2009-03-06 13:26:26 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2009-10-12 18:36:19 +02:00
|
|
|
|
|
|
|
extraOptions = mkOption {
|
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
[NETWORK]
|
|
|
|
INTERFACE = eth3
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Additional options that will be copied verbatim in `gnunetd.conf'.
|
|
|
|
See `gnunetd.conf(5)' for details.
|
|
|
|
'';
|
|
|
|
};
|
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
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
users.extraUsers = singleton
|
2009-03-06 13:26:26 +01:00
|
|
|
{ name = "gnunetd";
|
2009-05-29 16:25:56 +02:00
|
|
|
uid = config.ids.uids.gnunetd;
|
2009-03-06 13:26:26 +01:00
|
|
|
description = "GNUnet Daemon User";
|
|
|
|
home = "/var/empty";
|
2009-10-12 18:36:19 +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.
|
|
|
|
environment.systemPackages = [ pkgs.gnunet ];
|
|
|
|
|
|
|
|
environment.etc = [
|
|
|
|
# Tools such as `gnunet-transport-check' expect /etc/gnunetd.conf.
|
|
|
|
{ source = configFile;
|
|
|
|
target = "gnunetd.conf";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2009-10-12 20:09:34 +02:00
|
|
|
jobs.gnunetd =
|
2009-10-12 18:36:19 +02:00
|
|
|
{ description = "The GNUnet Daemon";
|
|
|
|
|
2009-11-06 23:19:17 +01:00
|
|
|
startOn = "started network-interfaces";
|
|
|
|
stopOn = "stopping network-interfaces";
|
2009-03-06 13:26:26 +01:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
preStart =
|
|
|
|
''
|
|
|
|
test -d "${cfg.home}" || \
|
|
|
|
( mkdir -m 755 -p "${cfg.home}" && chown -R gnunetd:users "${cfg.home}")
|
|
|
|
'';
|
|
|
|
|
|
|
|
exec =
|
|
|
|
''
|
2010-01-23 16:47:33 +01:00
|
|
|
${pkgs.gnunet}/bin/gnunetd \
|
|
|
|
${if cfg.debug then "--debug" else "" } \
|
|
|
|
--user="gnunetd" \
|
|
|
|
--config="${configFile}" \
|
2009-10-12 18:36:19 +02:00
|
|
|
--log="${cfg.logLevel}"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2009-03-06 13:26:26 +01:00
|
|
|
};
|
2009-10-12 18:36:19 +02:00
|
|
|
|
2008-09-04 22:28:02 +02:00
|
|
|
}
|