From bb9a5b25369dc85f3e139edd7b03098816b6658c Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Fri, 11 Feb 2022 16:36:02 +0000 Subject: [PATCH] Add hack for working VM on nixos-21.11 --- modules/build.nix | 9 +++++---- systems.nix | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/modules/build.nix b/modules/build.nix index cb9889e..f291ed4 100644 --- a/modules/build.nix +++ b/modules/build.nix @@ -1,15 +1,16 @@ -{ lib, extendModules, modulesPath, options, config, ... }: +{ lib, extendModules, modulesPath, baseModules, options, config, ... }: let inherit (lib) mkOption; inherit (lib.my) mkBoolOpt; cfg = config.my.build; - # TODO: This is broken on 21.11 (https://github.com/NixOS/nixpkgs/issues/148343) asDevVM = extendModules { + # TODO: Hack because this is kinda broken on 21.11 (https://github.com/NixOS/nixpkgs/issues/148343) + specialArgs = { inherit baseModules; }; modules = [ - (import "${modulesPath}/virtualisation/qemu-vm.nix") - ({ config, ... }: { + "${modulesPath}/virtualisation/qemu-vm.nix" + ({ ... }: { my.boot.isDevVM = true; }) ]; diff --git a/systems.nix b/systems.nix index 907c80b..b1101a7 100644 --- a/systems.nix +++ b/systems.nix @@ -9,8 +9,19 @@ config, }: let - lib = pkgsFlakes.${nixpkgs}.lib; - in lib.nixosSystem { + pkgsFlake = pkgsFlakes.${nixpkgs}; + lib = pkgsFlake.lib; + # TODO: This is mostly yoinked from nixpkgs/flake.nix master (as of 2022/02/11) since 21.11's version has hacky + # vm build stuff that breaks our impl. REMOVE WHEN 22.05 IS OUT! + nixosSystem' = args: + import "${pkgsFlake}/nixos/lib/eval-config.nix" (args // { + modules = args.modules ++ [ { + system.nixos.versionSuffix = + ".${lib.substring 0 8 pkgsFlake.lastModifiedDate}.${pkgsFlake.shortRev}"; + system.nixos.revision = pkgsFlake.rev; + } ]; + }); + in nixosSystem' { inherit lib system; specialArgs = { inherit inputs system; }; modules = attrValues modules ++ [ { networking.hostName = mkDefault name; } config ]; @@ -18,7 +29,7 @@ in mapAttrs mkSystem { colony = { system = "x86_64-linux"; - nixpkgs = "unstable"; + nixpkgs = "stable"; config = boxes/colony.nix; }; }