git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/solanum: implement reload and allow config changes

Reload only works with a static configuration path as there is no way to pass the dynamically generated config path to a running solanum instance, therefore we symlink the configuration to /etc/solanum/ircd.conf. But that will prevent reloads of the ircd, because the systemd unit wouldn't change when the configuration changes. That is why we add the actual location of the config file to restartTriggers and enable reloadIfChanged, so changes will not restart, but reload on changes.

commit60c62214f5a3c7db6aa30d8a8e02c863b6abcf0a authorMartin Weinelt <hexa@darmstadt.ccc.de> dateMon 31 May 2021, 03:21 (5 years ago) parentff06400
1 file changed+10−2
nixos/modules/services/networking/solanum.nix+10−2
nixos/modules/services/networking/solanum.nix+10−2
@@ -2,7 +2,7 @@
22
33let
44 inherit (lib) mkEnableOption mkIf mkOption types;
5− inherit (pkgs) solanum;
5+ inherit (pkgs) solanum util-linux;
66 cfg = config.services.solanum;
77
88 configFile = pkgs.writeText "solanum.conf" cfg.config;
@@ -78,12 +78,20 @@ in
7878
7979 config = mkIf cfg.enable (lib.mkMerge [
8080 {
81+
82+ environment.etc."solanum/ircd.conf".source = configFile;
83+
8184 systemd.services.solanum = {
8285 description = "Solanum IRC daemon";
8386 after = [ "network.target" ];
8487 wantedBy = [ "multi-user.target" ];
88+ reloadIfChanged = true;
89+ restartTriggers = [
90+ configFile
91+ ];
8592 serviceConfig = {
86− ExecStart = "${solanum}/bin/solanum -foreground -logfile /dev/stdout -configfile ${configFile} -pidfile /run/solanum/ircd.pid";
93+ ExecStart = "${solanum}/bin/solanum -foreground -logfile /dev/stdout -configfile /etc/solanum/ircd.conf -pidfile /run/solanum/ircd.pid";
94+ ExecReload = "${util-linux}/bin/kill -HUP $MAINPID";
8795 DynamicUser = true;
8896 User = "solanum";
8997 StateDirectory = "solanum";