diff options
author | Samuel Dionne-Riel <samuel@dionne-riel.com> | 2020-02-20 18:19:05 -0500 |
---|---|---|
committer | Samuel Dionne-Riel <samuel@dionne-riel.com> | 2020-02-20 18:51:17 -0500 |
commit | 687e2195d8076b0cef3e29c719fb5ab35975c160 (patch) | |
tree | 112a45c71164a1190fc4caa486e60843d98ffe53 | |
parent | e2b4abe3c8f2e09adfc6a52007841d1b96c89371 (diff) | |
download | nixlib-687e2195d8076b0cef3e29c719fb5ab35975c160.tar nixlib-687e2195d8076b0cef3e29c719fb5ab35975c160.tar.gz nixlib-687e2195d8076b0cef3e29c719fb5ab35975c160.tar.bz2 nixlib-687e2195d8076b0cef3e29c719fb5ab35975c160.tar.lz nixlib-687e2195d8076b0cef3e29c719fb5ab35975c160.tar.xz nixlib-687e2195d8076b0cef3e29c719fb5ab35975c160.tar.zst nixlib-687e2195d8076b0cef3e29c719fb5ab35975c160.zip |
runInLinuxVM: Ensure tools requiring /etc/passwd work
This includes, but is not limited to: * whoami * nix >= 2.3.1 See * https://github.com/NixOS/nixpkgs/issues/71157 * https://github.com/NixOS/nixops/issues/1216 * https://github.com/nix-community/nixops-libvirtd/issues/5
-rw-r--r-- | pkgs/build-support/vm/default.nix | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix index a7050f52e521..488c7f2ce2c7 100644 --- a/pkgs/build-support/vm/default.nix +++ b/pkgs/build-support/vm/default.nix @@ -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 |