diff options
author | Gleb Peregud <gleber.p@gmail.com> | 2017-11-18 23:33:24 +0100 |
---|---|---|
committer | Gleb Peregud <gleber.p@gmail.com> | 2017-11-19 19:42:54 +0100 |
commit | 2f6148c7433c08c7b32e772f7557fd08d39f48ab (patch) | |
tree | b3353452527e8614912180fc846d4988c414f45d /nixos/modules/system/activation | |
parent | f1caf10ec96708e198a0e9242104d2381ea4f0ca (diff) | |
download | nixlib-2f6148c7433c08c7b32e772f7557fd08d39f48ab.tar nixlib-2f6148c7433c08c7b32e772f7557fd08d39f48ab.tar.gz nixlib-2f6148c7433c08c7b32e772f7557fd08d39f48ab.tar.bz2 nixlib-2f6148c7433c08c7b32e772f7557fd08d39f48ab.tar.lz nixlib-2f6148c7433c08c7b32e772f7557fd08d39f48ab.tar.xz nixlib-2f6148c7433c08c7b32e772f7557fd08d39f48ab.tar.zst nixlib-2f6148c7433c08c7b32e772f7557fd08d39f48ab.zip |
nixos/system: make switch-to-configuration script pure.
Fixes #28443 Fixed few invocations to `systemctl` to have an absolute path. Additionally add LOCALE_ARCHIVE so that perl stops spewing warning messages.
Diffstat (limited to 'nixos/modules/system/activation')
-rw-r--r-- | nixos/modules/system/activation/switch-to-configuration.pl | 13 | ||||
-rw-r--r-- | nixos/modules/system/activation/top-level.nix | 2 |
2 files changed, 11 insertions, 4 deletions
diff --git a/nixos/modules/system/activation/switch-to-configuration.pl b/nixos/modules/system/activation/switch-to-configuration.pl index 29cc60b00324..87a4ab2a586d 100644 --- a/nixos/modules/system/activation/switch-to-configuration.pl +++ b/nixos/modules/system/activation/switch-to-configuration.pl @@ -16,6 +16,10 @@ my $reloadListFile = "/run/systemd/reload-list"; my $action = shift @ARGV; +if ("@localeArchive@" ne "") { + $ENV{LOCALE_ARCHIVE} = "@localeArchive@"; +} + if (!defined $action || ($action ne "switch" && $action ne "boot" && $action ne "test" && $action ne "dry-activate")) { print STDERR <<EOF; Usage: $0 [switch|boot|test] @@ -65,7 +69,8 @@ $SIG{PIPE} = "IGNORE"; sub getActiveUnits { # FIXME: use D-Bus or whatever to query this, since parsing the # output of list-units is likely to break. - my $lines = `LANG= systemctl list-units --full --no-legend`; + # Use current version of systemctl binary before daemon is reexeced. + my $lines = `LANG= /run/current-system/sw/bin/systemctl list-units --full --no-legend`; my $res = {}; foreach my $line (split '\n', $lines) { chomp $line; @@ -262,7 +267,8 @@ while (my ($unit, $state) = each %{$activePrev}) { sub pathToUnitName { my ($path) = @_; - open my $cmd, "-|", "@systemd@/bin/systemd-escape", "--suffix=mount", "-p", $path + # Use current version of systemctl binary before daemon is reexeced. + open my $cmd, "-|", "/run/current-system/sw/bin/systemd-escape", "--suffix=mount", "-p", $path or die "Unable to escape $path!\n"; my $escaped = join "", <$cmd>; chomp $escaped; @@ -364,7 +370,8 @@ syslog(LOG_NOTICE, "switching to system configuration $out"); if (scalar (keys %unitsToStop) > 0) { print STDERR "stopping the following units: ", join(", ", @unitsToStopFiltered), "\n" if scalar @unitsToStopFiltered; - system("systemctl", "stop", "--", sort(keys %unitsToStop)); # FIXME: ignore errors? + # Use current version of systemctl binary before daemon is reexeced. + system("/run/current-system/sw/bin/systemctl", "stop", "--", sort(keys %unitsToStop)); # FIXME: ignore errors? } print STDERR "NOT restarting the following changed units: ", join(", ", sort(keys %unitsToSkip)), "\n" diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix index 67cb2264e3f3..0c50241f2edf 100644 --- a/nixos/modules/system/activation/top-level.nix +++ b/nixos/modules/system/activation/top-level.nix @@ -26,7 +26,6 @@ let cloner false config.nesting.children ++ cloner true config.nesting.clone; - systemBuilder = let kernelPath = "${config.boot.kernelPackages.kernel}/" + @@ -83,6 +82,7 @@ let done mkdir $out/bin + export localeArchive="${config.i18n.glibcLocales}/lib/locale/locale-archive" substituteAll ${./switch-to-configuration.pl} $out/bin/switch-to-configuration chmod +x $out/bin/switch-to-configuration |