Revert "nixos-container: use systemd-run instead of nsenter"

This reverts commit 7cb100b683.

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)
This commit is contained in:
Maximilian Bosch 2020-03-26 01:17:32 +01:00
parent 59c58f3360
commit ebb6e385ea
No known key found for this signature in database
GPG Key ID: 091DBF4D1FC46B8E

View File

@ -9,6 +9,7 @@ use Getopt::Long qw(:config gnu_getopt);
use Cwd 'abs_path';
use Time::HiRes;
my $nsenter = "@utillinux@/bin/nsenter";
my $su = "@su@";
# Ensure a consistent umask.
@ -319,10 +320,9 @@ sub restartContainer {
# Run a command in the container.
sub runInContainer {
my @args = @_;
exec("systemd-run", "--machine", $containerName, "--pty", "--quiet", "--", @args);
die "cannot run systemd-run: $!\n";
my $leader = getLeader;
exec($nsenter, "-t", $leader, "-m", "-u", "-i", "-n", "-p", "--", @args);
die "cannot run nsenter: $!\n";
}
# Remove a directory while recursively unmounting all mounted filesystems within