Change:
When executing switch-to-configuration in a pure environment it fails: I am calling switch-to-configuration via systemd-run to active a new profile using the Hail update tool. The actual executed script is as follows: Actual output: <preactivating the configuration... perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LCALL = (unset), LANG = "enUS.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). setting up /etc... perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LCALL = (unset), LANG = "enUS.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). setting up tmpfiles Too few arguments. sh: systemctl: command not found </preThe script works if I pass on the PATH and LOCALE_ARCHIVE environment variables: System: (NixOS: 17.09pre-git (Hummingbird)) Nix version: nix-env (Nix) 1.11.13 Nixpkgs version: nixos-unstable (Commit ) Sandboxing enabled: no (Related Hail issue: )

Discussion:
my $action = shift @ARGV; <ins> if ("@localeArchive@" ne "") { $ENV{LOCALE_ARCHIVE} = "@localeArchive@"; } </ins> if (!defined $action || ($action ne "switch" && $action ne "boot" && $action ne "test" && $action ne "dry-activate")) { print STDERR <<EOF; Usage: $0 [switch|boot|test]

sub getActiveUnits { # FIXME: use D-Bus or whatever to query this, since parsing the # output of list-units is likely to break. <del> my $lines = `LANG= systemctl list-units --full --no-legend`; </del> <ins> # Use current version of systemctl binary before daemon is reexeced. my $lines = `LANG= /run/current-system/sw/bin/systemctl list-units --full --no-legend`; </ins> my $res = {}; foreach my $line (split 'n', $lines) { chomp $line;

sub pathToUnitName { my ($path) = @_; <del> open my $cmd, "-|", "@systemd@/bin/systemd-escape", "--suffix=mount", "-p", $path </del> <ins> # Use current version of systemctl binary before daemon is reexeced. open my $cmd, "-|", "/run/current-system/sw/bin/systemd-escape", "--suffix=mount", "-p", $path </ins> or die "Unable to escape $path!n"; my $escaped = join "", <$cmd>; chomp $escaped;

if (scalar (keys %unitsToStop) > 0) { print STDERR "stopping the following units: ", join(", ", @unitsToStopFiltered), "n" if scalar @unitsToStopFiltered; <del> system("systemctl", "stop", "--", sort(keys %unitsToStop)); # FIXME: ignore errors? </del> <ins> # Use current version of systemctl binary before daemon is reexeced. system("/run/current-system/sw/bin/systemctl", "stop", "--", sort(keys %unitsToStop)); # FIXME: ignore errors? </ins> } print STDERR "NOT restarting the following changed units: ", join(", ", sort(keys %unitsToSkip)), "n"

cloner false config.nesting.children ++ cloner true config.nesting.clone; systemBuilder = let kernelPath = "${config.boot.kernelPackages.kernel}/" +

done mkdir $out/bin <ins> export localeArchive="${config.i18n.glibcLocales}/lib/locale/locale-archive" </ins> substituteAll ${./switch-to-configuration.pl} $out/bin/switch-to-configuration chmod +x $out/bin/switch-to-configuration

(all nixos.tests.sddm.default) (all nixos.tests.simple) (all nixos.tests.slim) <ins> (all nixos.tests.switchTest) </ins> (all nixos.tests.udisks2) (all nixos.tests.xfce)

tests.slim = callTest tests/slim.nix {}; tests.smokeping = callTest tests/smokeping.nix {}; tests.snapper = callTest tests/snapper.nix {}; <ins> tests.switchTest = callTest tests/switch-test.nix {}; </ins> tests.taskserver = callTest tests/taskserver.nix {}; tests.tomcat = callTest tests/tomcat.nix {}; tests.udisks2 = callTest tests/udisks2.nix {};

<ins> # Test configuration switching. import ./make-test.nix ({ pkgs, ...} : { name = "switch-test"; meta = with pkgs.stdenv.lib.maintainers; { maintainers = [ gleber ]; }; nodes = { machine = { config, lib, pkgs, ... }: { users.mutableUsers = false; }; other = { config, lib, pkgs, ... }: { users.mutableUsers = true; }; }; testScript = {nodes, ...}: let originalSystem = nodes.machine.config.system.build.toplevel; otherSystem = nodes.other.config.system.build.toplevel; in '' $machine->succeed("env -i ${originalSystem}/bin/switch-to-configuration test | tee /dev/stderr"); $machine->succeed("env -i ${otherSystem}/bin/switch-to-configuration test | tee /dev/stderr"); ''; }) </ins>