From 872790aaf09f39bdee81f70a64942cf0c59e4345 Mon Sep 17 00:00:00 2001 From: Niklas Gollenstede Date: Sun, 13 Oct 2024 21:21:12 +0200 Subject: [PATCH] actually fix VM installation on nixos-unstable/-24.11 --- lib/nixos.nix | 2 +- modules/vm-exec.nix.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/nixos.nix b/lib/nixos.nix index a29b027..b39e55c 100644 --- a/lib/nixos.nix +++ b/lib/nixos.nix @@ -117,7 +117,7 @@ in rec { # An attrset of imported Nix flakes, for example the argument(s) passed to the flake »outputs« function. All other arguments are optional (and have reasonable defaults) if this is provided and contains »self« and the standard »nixpkgs«. This is also the second argument passed to the individual hosts' top level config files. inputs ? { }, # Arguments »{ files, dir, exclude, }« to »mkNixosConfigurations«, see there for details. May also be a list of those attrsets, in which case those multiple sets of hosts will be built separately by »mkNixosConfigurations«, allowing for separate sets of »peers« passed to »mkNixosConfiguration«. Each call will receive all other arguments, and the resulting sets of hosts will be merged. - hosts ? ({ dir = "${getFlakeDir inputs.self "Can't determine flake dir from »inputs.self«. Supply »mkSystemsFlake.hosts.dir« explicitly!"}/hosts"; exclude = [ ]; }), + hosts ? (let dir = "${getFlakeDir inputs.self "Can't determine flake dir from »inputs.self«. Supply »mkSystemsFlake.hosts.dir« explicitly!"}/hosts"; in if builtins.pathExists dir then { inherit dir; exclude = [ ]; } else { files = { }; }), # List of Modules to import for all hosts, in addition to the default ones in »nixpkgs«. The host-individual module should selectively enable these. Defaults to ».nixosModules.default« of all »moduleInputs«/»inputs« (including »inputs.self«). modules ? (getModulesFromInputs moduleInputs), # (Subset of) »inputs« that »modules« will be used from. Example: »{ inherit (inputs) self flakeA flakeB; }«. diff --git a/modules/vm-exec.nix.md b/modules/vm-exec.nix.md index 0db4865..f5f3780 100644 --- a/modules/vm-exec.nix.md +++ b/modules/vm-exec.nix.md @@ -92,7 +92,7 @@ in let hostModule = { # Instead of tearing down the initrd environment, adjust some mounts and run the »command« in the initrd: boot.initrd.systemd.enable = lib.mkVMOverride false; - boot.initrd.postMountCommands = '' + boot.initrd.postMountCommands = lib.mkAfter '' set -x for fs in tmp/shared tmp/xchg nix/store nix/var/nix/.ro-db ; do @@ -158,7 +158,7 @@ in let hostModule = { fsType = "9p"; device = "nix-var-nix-db"; neededForBoot = true; options = [ "trans=virtio" "version=9p2000.L" "msize=2097152" "ro" ]; }; - "/nix/store".overlay = { lowerdir = [ "/nix/.ro-store" ]; upperdir = "/nix/.rw-store/upper"; workdir = "/nix/.rw-store/work"; }; # (default from 24.11 onwards) + "/nix/store" = lib.mkIf ((builtins.substring 0 5 inputs.nixpkgs.lib.version) < "24.11") { overlay = { lowerdir = [ "/nix/.ro-store" ]; upperdir = "/nix/.rw-store/upper"; workdir = "/nix/.rw-store/work"; }; }; # (default from 24.11 onwards) }; virtualisation.qemu.options = [ "-virtfs local,path=/nix/var/nix/db,security_model=none,mount_tag=nix-var-nix-db,readonly=on" ]; # (doing this manually to pass »readonly«, to not ever corrupt the host's Nix DBs)