about summary refs log tree commit diff
path: root/nixos/modules/system/activation/switch-to-configuration.pl
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-04-17 18:52:31 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-04-17 18:52:31 +0200
commit179acfb664ed06519ac515eada7bbef677cbee87 (patch)
tree76c599294fe8ce8530b92c8a36f9b2adc7ee0595 /nixos/modules/system/activation/switch-to-configuration.pl
parent8dcf76480c34520997816d1bf4cfd68c6280ebbd (diff)
downloadnixlib-179acfb664ed06519ac515eada7bbef677cbee87.tar
nixlib-179acfb664ed06519ac515eada7bbef677cbee87.tar.gz
nixlib-179acfb664ed06519ac515eada7bbef677cbee87.tar.bz2
nixlib-179acfb664ed06519ac515eada7bbef677cbee87.tar.lz
nixlib-179acfb664ed06519ac515eada7bbef677cbee87.tar.xz
nixlib-179acfb664ed06519ac515eada7bbef677cbee87.tar.zst
nixlib-179acfb664ed06519ac515eada7bbef677cbee87.zip
Allow upstream systemd units to be extended
If you define a unit, and either systemd or a package in
systemd.packages already provides that unit, then we now generate a
file /etc/systemd/system/<unit>.d/overrides.conf. This makes it
possible to use upstream units, while allowing them to be customised
from the NixOS configuration. For instance, the module nix-daemon.nix
now uses the units provided by the Nix package. And all unit
definitions that duplicated upstream systemd units are finally gone.

This makes the baseUnit option unnecessary, so I've removed it.
Diffstat (limited to 'nixos/modules/system/activation/switch-to-configuration.pl')
-rw-r--r--nixos/modules/system/activation/switch-to-configuration.pl10
1 files changed, 9 insertions, 1 deletions
diff --git a/nixos/modules/system/activation/switch-to-configuration.pl b/nixos/modules/system/activation/switch-to-configuration.pl
index fd2b5b7950d5..13bd0b60f820 100644
--- a/nixos/modules/system/activation/switch-to-configuration.pl
+++ b/nixos/modules/system/activation/switch-to-configuration.pl
@@ -115,6 +115,14 @@ sub boolIsTrue {
     return $s eq "yes" || $s eq "true";
 }
 
+# As a fingerprint for determining whether a unit has changed, we use
+# its absolute path. If it has an override file, we append *its*
+# absolute path as well.
+sub fingerprintUnit {
+    my ($s) = @_;
+    return abs_path($s) . (-f "${s}.d/overrides.conf" ? " " . abs_path "${s}.d/overrides.conf" : "");
+}
+
 # Stop all services that no longer exist or have changed in the new
 # configuration.
 my (@unitsToStop, @unitsToSkip);
@@ -166,7 +174,7 @@ while (my ($unit, $state) = each %{$activePrev}) {
             }
         }
 
-        elsif (abs_path($prevUnitFile) ne abs_path($newUnitFile)) {
+        elsif (fingerprintUnit($prevUnitFile) ne fingerprintUnit($newUnitFile)) {
             if ($unit eq "sysinit.target" || $unit eq "basic.target" || $unit eq "multi-user.target" || $unit eq "graphical.target") {
                 # Do nothing.  These cannot be restarted directly.
             } elsif ($unit =~ /\.mount$/) {