git.iko.soy/typeable/nixpkgs
on master help sign in
Revert "nixos-container: use systemd-run instead of nsenter"

This reverts commit 7cb100b6833e020d4a4b25c3766cfde507e763e6. See also #83432. This appears to break at least the `container`-backend of `nixops`: when running `switch-to-configuration` within `nixos-container run`, the running `systemd`-instance gets reloaded which appears to kill the `systemd-run` command and causes `nixos-container run` to hang. The full issue is reported in the original PR[1]. [1] https://github.com/NixOS/nixpkgs/pull/67332#issuecomment-604145869 (cherry picked from commit 7f1ba606ac632c50efd33c435aa59e69d4f58acc)

commitebb6e385eac53f74963c95ac25cc22b16d161177 authorMaximilian Bosch <maximilian@mbosch.me> dateThu 26 Mar 2020, 01:17 (7 years ago) parent59c58f3
1 file changed+4−4
pkgs/tools/virtualization/nixos-container/nixos-container.pl+4−4
pkgs/tools/virtualization/nixos-container/nixos-container.pl+4−4
@@ -9,6 +9,7 @@ use Getopt::Long qw(:config gnu_getopt);
99use Cwd 'abs_path';
1010use Time::HiRes;
1111
12+my $nsenter = "@utillinux@/bin/nsenter";
1213my $su = "@su@";
1314
1415# Ensure a consistent umask.
@@ -319,10 +320,9 @@ sub restartContainer {
319320# Run a command in the container.
320321sub runInContainer {
321322 my @args = @_;
322−
323− exec("systemd-run", "--machine", $containerName, "--pty", "--quiet", "--", @args);
324−
325− die "cannot run ‘systemd-run’: $!\n";
323+ my $leader = getLeader;
324+ exec($nsenter, "-t", $leader, "-m", "-u", "-i", "-n", "-p", "--", @args);
325+ die "cannot run ‘nsenter’: $!\n";
326326}
327327
328328# Remove a directory while recursively unmounting all mounted filesystems within