Skip to content

Commit

Permalink
runInLinuxVM: Ensure tools requiring /etc/passwd work
Browse files Browse the repository at this point in the history
This includes, but is not limited to:

 * whoami
 * nix >= 2.3.1

See

 * #71157
 * NixOS/nixops#1216
 * nix-community/nixops-libvirtd#5
  • Loading branch information
samueldr committed Feb 20, 2020
1 parent e2b4abe commit 687e219
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkgs/build-support/vm/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ rec {
mkdir -p /fs/etc
ln -sf /proc/mounts /fs/etc/mtab
echo "127.0.0.1 localhost" > /fs/etc/hosts
# Ensures tools requiring /etc/passwd will work (e.g. nix)
if [ ! -e /fs/etc/passwd ]; then
echo "root:x:0:0:System administrator:/root:/bin/sh" > /fs/etc/passwd
fi
echo "starting stage 2 ($command)"
exec switch_root /fs $command $out
Expand Down

0 comments on commit 687e219

Please sign in to comment.