From b606165bd9d4c8a1f82160f67bd541f064ed1ddc Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 11 Oct 2012 17:54:43 -0400 Subject: [PATCH] Allow a unit to declare "triggers" that force a restart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The triggers are just arbitrary strings that are included in the unit under X-Restart-Triggers. The idea is that if they change between reconfigurations, switch-to-configuration will restart the unit because its store path changed. This is mostly useful for services that implicitly depend on generated files in /etc. Thus you can say restartTriggers = [ confFile ]; where ‘confFile’ is the derivation that generated the /etc file in question. --- modules/system/boot/systemd-unit-options.nix | 9 +++++++++ modules/system/boot/systemd.nix | 1 + 2 files changed, 10 insertions(+) diff --git a/modules/system/boot/systemd-unit-options.nix b/modules/system/boot/systemd-unit-options.nix index 2efea2fb9e1..239c837c676 100644 --- a/modules/system/boot/systemd-unit-options.nix +++ b/modules/system/boot/systemd-unit-options.nix @@ -83,6 +83,15 @@ rec { ''; }; + restartTriggers = mkOption { + default = []; + description = '' + An arbitrary list of items such as derivations. If any item + in the list changes between reconfigurations, the service will + be restarted. + ''; + }; + }; diff --git a/modules/system/boot/systemd.nix b/modules/system/boot/systemd.nix index c166c1cbf03..d88ac652ae0 100644 --- a/modules/system/boot/systemd.nix +++ b/modules/system/boot/systemd.nix @@ -176,6 +176,7 @@ let Before = concatStringsSep " " config.before; BindsTo = concatStringsSep " " config.bindsTo; PartOf = concatStringsSep " " config.partOf; + "X-Restart-Triggers" = toString config.restartTriggers; } // optionalAttrs (config.description != "") { Description = config.description; };