From 4948766e50bda046b0c8445b1e060b8d41db66df Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Fri, 11 Feb 2022 13:26:33 +0000 Subject: [PATCH] Improve VM options overrides --- flake.lock | 12 ++++++------ modules/tmproot.nix | 10 +++++++--- util.nix | 1 + 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index 80f215c..5ee71f3 100644 --- a/flake.lock +++ b/flake.lock @@ -95,11 +95,11 @@ }, "impermanence": { "locked": { - "lastModified": 1644541943, - "narHash": "sha256-bMiRtPs3xh8S3duX7JiWLZdUZi7RwktpXGhykCdCroE=", + "lastModified": 1644585928, + "narHash": "sha256-jOnLRLnzFI/YHE53bHgz/9QjR4Qt6dgIXLnTZOf5oLc=", "owner": "devplayer0", "repo": "impermanence", - "rev": "4bfa7f8b6844be7172264c1f7c11ac0c89027f79", + "rev": "47809005570ee4d5b504e382309f5b6dcc5999e5", "type": "github" }, "original": { @@ -177,11 +177,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1644193793, - "narHash": "sha256-ggCI5LCXwkUJQwjpkr9qDFbQMiK3JvAfeNR4Uy0ny5Q=", + "lastModified": 1644472683, + "narHash": "sha256-sP6iM4NksOYO6NFfTJ96cg+ClPnq6cdY30xKA1iYtyU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "521e4d7d13b09bc0a21976b9d19abd197d4e3b1e", + "rev": "7adc9c14ec74b27358a8df9b973087e351425a79", "type": "github" }, "original": { diff --git a/modules/tmproot.nix b/modules/tmproot.nix index 017d13f..c2e4c52 100644 --- a/modules/tmproot.nix +++ b/modules/tmproot.nix @@ -1,7 +1,7 @@ { lib, pkgs, inputs, config, ... }@args: let inherit (lib) any concatStringsSep mkIf mkDefault mkMerge mkVMOverride; - inherit (lib.my) mkOpt mkBoolOpt mkVMOverride'; + inherit (lib.my) mkOpt mkBoolOpt mkVMOverride' dummyOption; cfg = config.my.tmproot; @@ -63,6 +63,11 @@ ]; }; + # Forward declare options that won't exist until the VM module is actually imported + options.virtualisation = { + diskImage = dummyOption; + }; + config = mkMerge [ (mkIf cfg.enable { assertions = [ @@ -88,8 +93,7 @@ fileSystems."/" = rootDef; - # If we need to override any VM-specific options that the modules system won't know about this early - my.asDevVM.config.virtualisation = { + virtualisation = { diskImage = "./.vms/${config.system.name}-persist.qcow2"; }; }) diff --git a/util.nix b/util.nix index 36a3492..4c3819e 100644 --- a/util.nix +++ b/util.nix @@ -13,4 +13,5 @@ example = true; }; mkVMOverride' = mkOverride 9; + dummyOption = mkOption {}; }