From 01d078d9702aa032fece5d21ae1670dae538843f Mon Sep 17 00:00:00 2001 From: Linus Heckemann Date: Tue, 10 Jan 2023 14:15:05 +0100 Subject: [PATCH 1/3] vmTools.runInLinuxImage: allow setting root filesystem --- pkgs/build-support/vm/default.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix index 4ec5531192dc..0bca8e4d30b8 100644 --- a/pkgs/build-support/vm/default.nix +++ b/pkgs/build-support/vm/default.nix @@ -72,8 +72,8 @@ rec { for o in $(cat /proc/cmdline); do case $o in - mountDisk=1) - mountDisk=1 + mountDisk=*) + mountDisk=''${mountDisk#mountDisk=} ;; command=*) set -- $(IFS==; echo $o) @@ -103,6 +103,8 @@ rec { if test -z "$mountDisk"; then mount -t tmpfs none /fs + elif [[ -e "$mountDisk" ]]; then + mount "$mountDisk" /fs else mount /dev/${hd} /fs fi @@ -388,7 +390,7 @@ rec { filesystem containing a non-NixOS Linux distribution. */ runInLinuxImage = drv: runInLinuxVM (lib.overrideDerivation drv (attrs: { - mountDisk = true; + mountDisk = attrs.mountDisk or true; /* Mount `image' as the root FS, but use a temporary copy-on-write image since we don't want to (and can't) write to `image'. */ From e6a4a3feea46c11c9daaba01d8acfe52839e185b Mon Sep 17 00:00:00 2001 From: Linus Heckemann Date: Sat, 28 Jan 2023 11:23:45 +0100 Subject: [PATCH 2/3] vmTools/deb tools: pass through args This is useful for adding preVM/postVM steps. --- pkgs/build-support/vm/default.nix | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix index 0bca8e4d30b8..17c9184b0947 100644 --- a/pkgs/build-support/vm/default.nix +++ b/pkgs/build-support/vm/default.nix @@ -578,9 +578,9 @@ rec { fillDiskWithDebs = { size ? 4096, debs, name, fullName, postInstall ? null, createRootFS ? defaultCreateRootFS - , QEMU_OPTS ? "", memSize ? 512 }: + , QEMU_OPTS ? "", memSize ? 512, ... }@args: - runInLinuxVM (stdenv.mkDerivation { + runInLinuxVM (stdenv.mkDerivation ({ inherit name postInstall QEMU_OPTS memSize; debs = (lib.intersperse "|" debs); @@ -649,7 +649,6 @@ rec { echo "running post-install script..." eval "$postInstall" - ln -sf dash /mnt/bin/sh rm /mnt/.debug @@ -660,7 +659,7 @@ rec { ''; passthru = { inherit fullName; }; - }); + } // args)); /* Generate a Nix expression containing fetchurl calls for the @@ -746,7 +745,7 @@ rec { , packagesList ? "", packagesLists ? [packagesList] , packages, extraPackages ? [], postInstall ? "" , extraDebs ? [], createRootFS ? defaultCreateRootFS - , QEMU_OPTS ? "", memSize ? 512 }: + , QEMU_OPTS ? "", memSize ? 512, ... }@args: let expr = debClosureGenerator { @@ -754,10 +753,10 @@ rec { packages = packages ++ extraPackages; }; in - (fillDiskWithDebs { + (fillDiskWithDebs ({ inherit name fullName size postInstall createRootFS QEMU_OPTS memSize; debs = import expr {inherit fetchurl;} ++ extraDebs; - }) // {inherit expr;}; + } // args)) // {inherit expr;}; /* The set of supported RPM-based distributions. */ From 5a4f40797c98c8eb33d2e86b8eb78624a36b83ea Mon Sep 17 00:00:00 2001 From: Linus Heckemann Date: Sat, 28 Jan 2023 11:24:16 +0100 Subject: [PATCH 3/3] vmTools.debClosureGenerator: remove apparently obsolete bugfix --- pkgs/build-support/vm/default.nix | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix index 17c9184b0947..5103d745b56e 100644 --- a/pkgs/build-support/vm/default.nix +++ b/pkgs/build-support/vm/default.nix @@ -728,9 +728,6 @@ rec { esac done - # Work around this bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=452279 - sed -i ./Packages -e s/x86_64-linux-gnu/x86-64-linux-gnu/g - perl -w ${deb/deb-closure.pl} \ ./Packages ${urlPrefix} ${toString packages} > $out '';