From 6355db00b220725993c6e483aa972dc46e77e8cf Mon Sep 17 00:00:00 2001 From: MZauchner Date: Thu, 24 Oct 2024 13:34:46 +0200 Subject: [PATCH] Mount /dev when creating a VM image from RPMs Currently, using `runInLinuxVM` fails for CentosOS7 versions >=7.4. The error manifests itself by the VM powering down after failing to initialize the NSS library. The reason for this is that some devices in /dev are required during the built process of the VM. To fix this issue, we mount /dev before calling chroot. --- pkgs/build-support/vm/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix index 7ba67af5cf5a..8509c89b6d1a 100644 --- a/pkgs/build-support/vm/default.nix +++ b/pkgs/build-support/vm/default.nix @@ -449,6 +449,8 @@ rec { # Make the Nix store available in /mnt, because that's where the RPMs live. mkdir -p /mnt${storeDir} ${util-linux}/bin/mount -o bind ${storeDir} /mnt${storeDir} + # Some programs may require devices in /dev to be available (e.g. /dev/random) + ${util-linux}/bin/mount -o bind /dev /mnt/dev # Newer distributions like Fedora 18 require /lib etc. to be # symlinked to /usr. @@ -487,7 +489,7 @@ rec { rm /mnt/.debug - ${util-linux}/bin/umount /mnt${storeDir} /mnt/tmp ${lib.optionalString unifiedSystemDir "/mnt/proc"} + ${util-linux}/bin/umount /mnt${storeDir} /mnt/tmp /mnt/dev ${lib.optionalString unifiedSystemDir "/mnt/proc"} ${util-linux}/bin/umount /mnt '';