From 59d7d726f11b8c759ab1b804fa71c15cc1b25627 Mon Sep 17 00:00:00 2001 From: Malte Voos Date: Sat, 14 Aug 2021 22:16:58 +0200 Subject: [PATCH] nixos/gnunet: improve service configuration Co-authored-by: Michele Guerini Rocco Co-authored-by: Aaron Andersen --- nixos/modules/services/networking/gnunet.nix | 22 ++++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/nixos/modules/services/networking/gnunet.nix b/nixos/modules/services/networking/gnunet.nix index 69d4ed047756..cf3d1841a979 100644 --- a/nixos/modules/services/networking/gnunet.nix +++ b/nixos/modules/services/networking/gnunet.nix @@ -6,12 +6,15 @@ let cfg = config.services.gnunet; - homeDir = "/var/lib/gnunet"; + stateDir = "/var/lib/gnunet"; - configFile = with cfg; pkgs.writeText "gnunetd.conf" + configFile = with cfg; '' [PATHS] - SERVICEHOME = ${homeDir} + GNUNET_HOME = ${stateDir} + GNUNET_RUNTIME_DIR = /run/gnunet + GNUNET_USER_RUNTIME_DIR = /run/gnunet + GNUNET_DATA_HOME = ${stateDir}/data [ats] WAN_QUOTA_IN = ${toString load.maxNetDownBandwidth} b @@ -137,8 +140,6 @@ in users.users.gnunet = { group = "gnunet"; description = "GNUnet User"; - home = homeDir; - createHome = true; uid = config.ids.uids.gnunet; }; @@ -148,17 +149,20 @@ in # so install them globally. environment.systemPackages = [ cfg.package ]; + environment.etc."gnunet.conf".text = configFile; + systemd.services.gnunet = { description = "GNUnet"; after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; + restartTriggers = [ configFile ]; path = [ cfg.package pkgs.miniupnpc ]; - environment.TMPDIR = "/tmp"; - serviceConfig.PrivateTmp = true; - serviceConfig.ExecStart = "${cfg.package}/lib/gnunet/libexec/gnunet-service-arm -c ${configFile}"; + serviceConfig.ExecStart = "${cfg.package}/lib/gnunet/libexec/gnunet-service-arm -c /etc/gnunet.conf"; serviceConfig.User = "gnunet"; serviceConfig.UMask = "0007"; - serviceConfig.WorkingDirectory = homeDir; + serviceConfig.WorkingDirectory = stateDir; + serviceConfig.RuntimeDirectory = "gnunet"; + serviceConfig.StateDirectory = "gnunet"; }; };