Convert "gnunet"

svn path=/nixos/branches/fix-style/; revision=14377
This commit is contained in:
Marc Weber 2009-03-06 12:26:26 +00:00
parent f9f61c0a1e
commit 931f68c924
3 changed files with 203 additions and 191 deletions

View File

@ -480,142 +480,6 @@ in
}; };
gnunet = {
enable = mkOption {
default = false;
description = ''
Whether to run the GNUnet daemon. GNUnet is GNU's anonymous
peer-to-peer communication and file sharing framework.
'';
};
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;
description = ''
Maximum file system usage (in MiB) for file sharing.
'';
};
activeMigration = mkOption {
default = false;
description = ''
Whether to allow active migration of content originating
from other nodes.
'';
};
};
load = {
maxNetDownBandwidth = mkOption {
default = 50000;
description = ''
Maximum bandwidth usage (in bits per second) for GNUnet
when downloading data.
'';
};
maxNetUpBandwidth = mkOption {
default = 50000;
description = ''
Maximum bandwidth usage (in bits per second) for GNUnet
when downloading data.
'';
};
hardNetUpBandwidth = mkOption {
default = 0;
description = ''
Hard bandwidth limit (in bits per second) when uploading
data.
'';
};
maxCPULoad = mkOption {
default = 100;
description = ''
Maximum CPU load (percentage) authorized for the GNUnet
daemon.
'';
};
interfaces = mkOption {
default = [ "eth0" ];
example = [ "wlan0" "eth1" ];
description = ''
List of network interfaces to use.
'';
};
};
extraOptions = mkOption {
default = "";
example = ''
[NETWORK]
INTERFACE = eth3
'';
description = ''
Additional options that will be copied verbatim in `gnunetd.conf'.
See `gnunetd.conf(5)' for details.
'';
};
};
ejabberd = { ejabberd = {
enable = mkOption { enable = mkOption {
default = false; default = false;
@ -1504,6 +1368,7 @@ in
(import ../upstart-jobs/ntpd.nix) (import ../upstart-jobs/ntpd.nix)
(import ../upstart-jobs/portmap.nix) (import ../upstart-jobs/portmap.nix)
(import ../upstart-jobs/bitlbee.nix) (import ../upstart-jobs/bitlbee.nix)
(import ../upstart-jobs/gnunet.nix)
# nix # nix
(import ../upstart-jobs/nix.nix) # nix options and daemon (import ../upstart-jobs/nix.nix) # nix options and daemon

View File

@ -141,13 +141,6 @@ let
inherit config; inherit config;
}) })
# GNUnet daemon.
++ optional config.services.gnunet.enable
(import ../upstart-jobs/gnunet.nix {
inherit (pkgs) gnunet lib writeText;
gnunetConfig = config.services.gnunet;
})
# Apache httpd. # Apache httpd.
++ optional (config.services.httpd.enable && !config.services.httpd.experimental) ++ optional (config.services.httpd.enable && !config.services.httpd.experimental)
(import ../upstart-jobs/httpd.nix { (import ../upstart-jobs/httpd.nix {

View File

@ -1,64 +1,218 @@
{ gnunet, gnunetConfig, lib, writeText }: {pkgs, config, ...}:
assert gnunetConfig.enable; ###### interface
let
inherit (pkgs.lib) mkOption mkIf;
{ options = {
name = "gnunetd"; services = {
gnunet = {
enable = mkOption {
default = false;
description = ''
Whether to run the GNUnet daemon. GNUnet is GNU's anonymous
peer-to-peer communication and file sharing framework.
'';
};
users = [ home = mkOption {
{ name = "gnunetd"; default = "/var/lib/gnunet";
uid = (import ../system/ids.nix).uids.gnunetd; description = ''
description = "GNUnet Daemon User"; Directory where the GNUnet daemon will store its data.
home = "/var/empty"; '';
} };
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;
description = ''
Maximum file system usage (in MiB) for file sharing.
'';
};
activeMigration = mkOption {
default = false;
description = ''
Whether to allow active migration of content originating
from other nodes.
'';
};
};
load = {
maxNetDownBandwidth = mkOption {
default = 50000;
description = ''
Maximum bandwidth usage (in bits per second) for GNUnet
when downloading data.
'';
};
maxNetUpBandwidth = mkOption {
default = 50000;
description = ''
Maximum bandwidth usage (in bits per second) for GNUnet
when downloading data.
'';
};
hardNetUpBandwidth = mkOption {
default = 0;
description = ''
Hard bandwidth limit (in bits per second) when uploading
data.
'';
};
maxCPULoad = mkOption {
default = 100;
description = ''
Maximum CPU load (percentage) authorized for the GNUnet
daemon.
'';
};
interfaces = mkOption {
default = [ "eth0" ];
example = [ "wlan0" "eth1" ];
description = ''
List of network interfaces to use.
'';
};
};
extraOptions = mkOption {
default = "";
example = ''
[NETWORK]
INTERFACE = eth3
'';
description = ''
Additional options that will be copied verbatim in `gnunetd.conf'.
See `gnunetd.conf(5)' for details.
'';
};
};
};
};
in
###### implementation
mkIf config.services.gnunet.enable {
require = [
options
]; ];
job = users = {
with gnunetConfig; extraUsers = [
let configFile = writeText "gnunetd.conf" '' { name = "gnunetd";
[PATHS] uid = (import ../system/ids.nix).uids.gnunetd;
GNUNETD_HOME = ${home} description = "GNUnet Daemon User";
home = "/var/empty";
}
];
};
[GNUNETD] services = {
HOSTLISTURL = ${lib.concatStringsSep " " hostLists} extraJobs = [{
APPLICATIONS = ${lib.concatStringsSep " " applications} name = "gnunetd";
TRANSPORTS = ${lib.concatStringsSep " " transports}
[LOAD] job =
MAXNETDOWNBPSTOTAL = ${toString load.maxNetDownBandwidth} with config.services.gnunet;
MAXNETUPBPSTOTAL = ${toString load.maxNetUpBandwidth} let
HARDUPLIMIT = ${toString load.hardNetUpBandwidth} inherit (pkgs) lib gnunet;
MAXCPULOAD = ${toString load.maxCPULoad} configFile = pkgs.writeText "gnunetd.conf" ''
INTERFACES = ${lib.concatStringsSep " " load.interfaces} [PATHS]
GNUNETD_HOME = ${home}
[FS] [GNUNETD]
QUOTA = ${toString fileSharing.quota} HOSTLISTURL = ${lib.concatStringsSep " " hostLists}
ACTIVEMIGRATION = ${if fileSharing.activeMigration then "YES" else "NO"} APPLICATIONS = ${lib.concatStringsSep " " applications}
TRANSPORTS = ${lib.concatStringsSep " " transports}
[MODULES] [LOAD]
sqstore = sqstore_sqlite MAXNETDOWNBPSTOTAL = ${toString load.maxNetDownBandwidth}
dstore = dstore_sqlite MAXNETUPBPSTOTAL = ${toString load.maxNetUpBandwidth}
topology = topology_default HARDUPLIMIT = ${toString load.hardNetUpBandwidth}
MAXCPULOAD = ${toString load.maxCPULoad}
INTERFACES = ${lib.concatStringsSep " " load.interfaces}
${extraOptions} [FS]
''; QUOTA = ${toString fileSharing.quota}
ACTIVEMIGRATION = ${if fileSharing.activeMigration then "YES" else "NO"}
in '' [MODULES]
description "The GNUnet Daemon" sqstore = sqstore_sqlite
dstore = dstore_sqlite
topology = topology_default
start on network-interfaces/started ${extraOptions}
stop on network-interfaces/stop '';
in ''
description "The GNUnet Daemon"
start script start on network-interfaces/started
test -d "${home}" || \ stop on network-interfaces/stop
( mkdir -m 755 -p "${home}" && chown -R gnunetd:users "${home}")
end script
respawn ${gnunet}/bin/gnunetd \ start script
${if debug then "--debug" else "" } \ test -d "${home}" || \
--user="gnunetd" \ ( mkdir -m 755 -p "${home}" && chown -R gnunetd:users "${home}")
--config="${configFile}" \ end script
--log="${logLevel}"
'';
respawn ${gnunet}/bin/gnunetd \
${if debug then "--debug" else "" } \
--user="gnunetd" \
--config="${configFile}" \
--log="${logLevel}"
'';
}];
};
} }