git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #68906 from edolstra/revert-interface-version

Revert systemd interface version to 2

commit387a2f27ec366dbdf6d3ca174c895e5d0c584da4 authorEelco Dolstra <edolstra@gmail.com> dateThu 19 Sep 2019, 14:09 (7 years ago) parent0784d26b20a0e4
2 files changed+14−7
nixos/modules/system/activation/switch-to-configuration.pl+13−6 pkgs/os-specific/linux/systemd/default.nix+1−1
nixos/modules/system/activation/switch-to-configuration.pl+13−6
@@ -10,6 +10,9 @@ use Cwd 'abs_path';
1010
1111my $out = "@out@";
1212
13+# FIXME: maybe we should use /proc/1/exe to get the current systemd.
14+my $curSystemd = abs_path("/run/current-system/sw/bin");
15+
1316# To be robust against interruption, record what units need to be started etc.
1417my $startListFile = "/run/systemd/start-list";
1518my $restartListFile = "/run/systemd/restart-list";
@@ -267,7 +270,7 @@ while (my ($unit, $state) = each %{$activePrev}) {
267270sub pathToUnitName {
268271 my ($path) = @_;
269272 # Use current version of systemctl binary before daemon is reexeced.
270− open my $cmd, "-|", "/run/current-system/sw/bin/systemd-escape", "--suffix=mount", "-p", $path
273+ open my $cmd, "-|", "$curSystemd/systemd-escape", "--suffix=mount", "-p", $path
271274 or die "Unable to escape $path!\n";
272275 my $escaped = join "", <$cmd>;
273276 chomp $escaped;
@@ -370,7 +373,7 @@ if (scalar (keys %unitsToStop) > 0) {
370373 print STDERR "stopping the following units: ", join(", ", @unitsToStopFiltered), "\n"
371374 if scalar @unitsToStopFiltered;
372375 # Use current version of systemctl binary before daemon is reexeced.
373− system("/run/current-system/sw/bin/systemctl", "stop", "--", sort(keys %unitsToStop)); # FIXME: ignore errors?
376+ system("$curSystemd/systemctl", "stop", "--", sort(keys %unitsToStop)); # FIXME: ignore errors?
374377}
375378
376379print STDERR "NOT restarting the following changed units: ", join(", ", sort(keys %unitsToSkip)), "\n"
@@ -382,10 +385,12 @@ my $res = 0;
382385print STDERR "activating the configuration...\n";
383386system("$out/activate", "$out") == 0 or $res = 2;
384387
385−# Restart systemd if necessary.
388+# Restart systemd if necessary. Note that this is done using the
389+# current version of systemd, just in case the new one has trouble
390+# communicating with the running pid 1.
386391if ($restartSystemd) {
387392 print STDERR "restarting systemd...\n";
388− system("@systemd@/bin/systemctl", "daemon-reexec") == 0 or $res = 2;
393+ system("$curSystemd/systemctl", "daemon-reexec") == 0 or $res = 2;
389394}
390395
391396# Forget about previously failed services.
@@ -401,8 +406,10 @@ while (my $f = <$listActiveUsers>) {
401406 my ($uid, $name) = ($+{uid}, $+{user});
402407 print STDERR "reloading user units for $name...\n";
403408
404− system("@su@", "-s", "@shell@", "-l", $name, "-c", "XDG_RUNTIME_DIR=/run/user/$uid @systemd@/bin/systemctl --user daemon-reload");
405− system("@su@", "-s", "@shell@", "-l", $name, "-c", "XDG_RUNTIME_DIR=/run/user/$uid @systemd@/bin/systemctl --user start nixos-activation.service");
409+ system("@su@", "-s", "@shell@", "-l", $name, "-c",
410+ "export XDG_RUNTIME_DIR=/run/user/$uid; " .
411+ "$curSystemd/systemctl --user daemon-reexec; " .
412+ "@systemd@/bin/systemctl --user start nixos-activation.service");
406413}
407414
408415close $listActiveUsers;
pkgs/os-specific/linux/systemd/default.nix+1−1
@@ -223,7 +223,7 @@ in stdenv.mkDerivation {
223223 # in a backwards-incompatible way. If the interface version of two
224224 # systemd builds is the same, then we can switch between them at
225225 # runtime; otherwise we can't and we need to reboot.
226− passthru.interfaceVersion = 3;
226+ passthru.interfaceVersion = 2;
227227
228228 meta = with stdenv.lib; {
229229 homepage = http://www.freedesktop.org/wiki/Software/systemd;