mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
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.
This commit is contained in:
parent
8dcf76480c
commit
179acfb664
9 changed files with 72 additions and 97 deletions
|
@ -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$/) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue