nixfiles/modules/build.nix

36 lines
1.0 KiB
Nix
Raw Normal View History

2022-02-11 16:36:02 +00:00
{ lib, extendModules, modulesPath, baseModules, options, config, ... }:
2022-02-13 13:10:21 +00:00
let
2022-02-13 13:44:37 +00:00
inherit (lib) recursiveUpdate mkOption;
2022-02-13 17:44:14 +00:00
inherit (lib.my) mkBoolOpt';
2022-02-13 13:10:21 +00:00
cfg = config.my.build;
2022-02-13 13:10:21 +00:00
asDevVM = extendModules {
# TODO: Hack because this is kinda broken on 21.11 (https://github.com/NixOS/nixpkgs/issues/148343)
specialArgs = { inherit baseModules; };
modules = [
"${modulesPath}/virtualisation/qemu-vm.nix"
({ ... }: {
my.boot.isDevVM = true;
})
];
};
in
{
options.my = with lib.types; {
2022-02-13 17:44:14 +00:00
boot.isDevVM = mkBoolOpt' false "Whether the system is a development VM.";
2022-02-13 13:10:21 +00:00
build = options.system.build;
asDevVM = mkOption {
inherit (asDevVM) type;
default = { };
visible = "shallow";
2022-02-13 17:44:14 +00:00
description = "Configuration as a development VM";
};
2022-02-13 13:10:21 +00:00
};
2022-02-13 13:10:21 +00:00
config.my.build = {
2022-02-13 13:44:37 +00:00
# The meta.mainProgram should probably be set upstream but oh well...
devVM = recursiveUpdate config.my.asDevVM.system.build.vm { meta.mainProgram = "run-${config.system.name}-vm"; };
2022-02-13 13:10:21 +00:00
};
}