interactive-vm: use host pkgs in the launcher script.

This commit is contained in:
zerox
2024-09-22 01:03:56 +05:00
committed by mergify[bot]
parent 430ba34990
commit b1d6bed240
2 changed files with 7 additions and 3 deletions

View File

@@ -18,6 +18,8 @@ You can configure the VM using the `virtualisation.vmVariantWithDisko` NixOS opt
{
virtualisation.vmVariantWithDisko = {
virtualisation.fileSystems."/persist".neededForBoot = true;
# For running VM on macos: https://www.tweag.io/blog/2023-02-09-nixos-vm-on-macos/
# virtualisation.host.pkgs = inputs.nixpkgs.legacyPackages.aarch64-darwin;
};
}
```

View File

@@ -40,6 +40,8 @@ let
boot = cfg_.disko.devices._config.boot or { };
swapDevices = cfg_.disko.devices._config.swapDevices or [ ];
};
hostPkgs = config.virtualisation.host.pkgs;
in
{
imports = [
@@ -63,12 +65,12 @@ in
boot.zfs.devNodes = "/dev/disk/by-uuid"; # needed because /dev/disk/by-id is empty in qemu-vms
boot.zfs.forceImportAll = true;
system.build.vmWithDisko = pkgs.writers.writeDashBin "disko-vm" ''
system.build.vmWithDisko = hostPkgs.writers.writeDashBin "disko-vm" ''
set -efux
export tmp=$(mktemp -d)
export tmp=$(${hostPkgs.coreutils}/bin/mktemp -d)
trap 'rm -rf "$tmp"' EXIT
${lib.concatMapStringsSep "\n" (disk: ''
${pkgs.qemu}/bin/qemu-img create -f qcow2 \
${hostPkgs.qemu}/bin/qemu-img create -f qcow2 \
-b ${config.system.build.diskoImages}/${disk.name}.qcow2 \
-F qcow2 "$tmp"/${disk.name}.qcow2
'') disks}