summary refs log tree commit diff
path: root/upstart-jobs/gnunet.nix
diff options
context:
space:
mode:
Diffstat (limited to 'upstart-jobs/gnunet.nix')
-rw-r--r--upstart-jobs/gnunet.nix64
1 files changed, 64 insertions, 0 deletions
diff --git a/upstart-jobs/gnunet.nix b/upstart-jobs/gnunet.nix
new file mode 100644
index 00000000000..3b3de2d97b3
--- /dev/null
+++ b/upstart-jobs/gnunet.nix
@@ -0,0 +1,64 @@
+{ gnunet, gnunetConfig, lib, writeText }:
+
+assert gnunetConfig.enable;
+
+{
+  name = "gnunetd";
+
+  users = [
+    { name = "gnunetd";
+      uid = (import ../system/ids.nix).uids.gnunetd;
+      description = "GNUnet Daemon User";
+      home = "/var/empty";
+    }
+  ];
+
+  job =
+    with gnunetConfig;
+    let configFile = writeText "gnunetd.conf" ''
+      [PATHS]
+      GNUNETD_HOME = ${home}
+
+      [GNUNETD]
+      HOSTLISTURL = ${lib.concatStringsSep " " hostLists}
+      APPLICATIONS = ${lib.concatStringsSep " " applications}
+      TRANSPORTS = ${lib.concatStringsSep " " transports}
+
+      [LOAD]
+      MAXNETDOWNBPSTOTAL = ${toString load.maxNetDownBandwidth}
+      MAXNETUPBPSTOTAL = ${toString load.maxNetUpBandwidth}
+      HARDUPLIMIT = ${toString load.hardNetUpBandwidth}
+      MAXCPULOAD = ${toString load.maxCPULoad}
+      INTERFACES = ${lib.concatStringsSep " " load.interfaces}
+
+      [FS]
+      QUOTA = ${toString fileSharing.quota}
+      ACTIVEMIGRATION = ${if fileSharing.activeMigration then "YES" else "NO"}
+
+      [MODULES]
+      sqstore = sqstore_sqlite
+      dstore = dstore_sqlite
+      topology = topology_default
+
+      ${extraOptions}
+    '';
+
+    in ''
+description "The GNUnet Daemon"
+
+start on network-interfaces/started
+stop on network-interfaces/stop
+
+start script
+    test -d "${home}" || \
+    ( mkdir -m 755 -p "${home}" && chown -R gnunetd:users "${home}")
+end script
+
+respawn ${gnunet}/bin/gnunetd                   \
+  ${if debug then "--debug" else "" }           \
+  --user="gnunetd"                              \
+  --config="${configFile}"                      \
+  --log="${logLevel}"
+'';
+
+}