Make nix run .#vms.<system> work

This commit is contained in:
Jack O'Sullivan 2022-02-13 13:44:37 +00:00
parent 7627395222
commit 69c508ea07
3 changed files with 6 additions and 9 deletions

View File

@ -39,7 +39,7 @@
inherit (builtins) mapAttrs; inherit (builtins) mapAttrs;
inherit (lib) genAttrs mapAttrs'; inherit (lib) genAttrs mapAttrs';
inherit (lib.flake) defaultSystems eachDefaultSystem; inherit (lib.flake) defaultSystems eachDefaultSystem;
inherit (lib.my) addPrefix; inherit (lib.my) addPrefix mkApp;
extendLib = lib: lib.extend (final: prev: { extendLib = lib: lib.extend (final: prev: {
my = import ./util.nix { lib = final; }; my = import ./util.nix { lib = final; };
@ -77,12 +77,7 @@
nixosConfigurations = import ./systems.nix { inherit lib pkgsFlakes inputs; modules = self.nixosModules; }; nixosConfigurations = import ./systems.nix { inherit lib pkgsFlakes inputs; modules = self.nixosModules; };
systems = mapAttrs (_: system: system.config.system.build.toplevel) self.nixosConfigurations; systems = mapAttrs (_: system: system.config.system.build.toplevel) self.nixosConfigurations;
vms = mapAttrs (_: system: system.config.my.build.devVM) self.nixosConfigurations; vms = mapAttrs (name: system: system.config.my.build.devVM) self.nixosConfigurations;
apps =
let apps' = { }
// addPrefix "vms/" (mapAttrs (name: vm: { type = "app"; program = "${vm}/bin/run-${name}-vm"; }) self.vms);
in { x86_64-linux = apps'; };
devShell = genAttrs defaultSystems (system: devShell = genAttrs defaultSystems (system:
let let

View File

@ -1,6 +1,6 @@
{ lib, extendModules, modulesPath, baseModules, options, config, ... }: { lib, extendModules, modulesPath, baseModules, options, config, ... }:
let let
inherit (lib) mkOption; inherit (lib) recursiveUpdate mkOption;
inherit (lib.my) mkBoolOpt; inherit (lib.my) mkBoolOpt;
cfg = config.my.build; cfg = config.my.build;
@ -28,6 +28,7 @@ in
}; };
config.my.build = { config.my.build = {
devVM = config.my.asDevVM.system.build.vm; # 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"; };
}; };
} }

View File

@ -22,6 +22,7 @@ rec {
}; };
mkPkgs = path: args: genAttrs defaultSystems (system: import path (args // { inherit system; })); mkPkgs = path: args: genAttrs defaultSystems (system: import path (args // { inherit system; }));
mkApp = program: { type = "app"; inherit program; };
mkOpt = type: default: mkOption { inherit type default; }; mkOpt = type: default: mkOption { inherit type default; };
mkBoolOpt = default: mkOption { mkBoolOpt = default: mkOption {