From 69c508ea075b2d1e5103088e84e72bae4a1e0843 Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Sun, 13 Feb 2022 13:44:37 +0000 Subject: [PATCH] Make `nix run .#vms.` work --- flake.nix | 9 ++------- modules/build.nix | 5 +++-- util.nix | 1 + 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/flake.nix b/flake.nix index 9cc0948..81c76c1 100644 --- a/flake.nix +++ b/flake.nix @@ -39,7 +39,7 @@ inherit (builtins) mapAttrs; inherit (lib) genAttrs mapAttrs'; inherit (lib.flake) defaultSystems eachDefaultSystem; - inherit (lib.my) addPrefix; + inherit (lib.my) addPrefix mkApp; extendLib = lib: lib.extend (final: prev: { my = import ./util.nix { lib = final; }; @@ -77,12 +77,7 @@ nixosConfigurations = import ./systems.nix { inherit lib pkgsFlakes inputs; modules = self.nixosModules; }; systems = mapAttrs (_: system: system.config.system.build.toplevel) self.nixosConfigurations; - vms = mapAttrs (_: 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'; }; + vms = mapAttrs (name: system: system.config.my.build.devVM) self.nixosConfigurations; devShell = genAttrs defaultSystems (system: let diff --git a/modules/build.nix b/modules/build.nix index 4c572e1..8f7a001 100644 --- a/modules/build.nix +++ b/modules/build.nix @@ -1,6 +1,6 @@ { lib, extendModules, modulesPath, baseModules, options, config, ... }: let - inherit (lib) mkOption; + inherit (lib) recursiveUpdate mkOption; inherit (lib.my) mkBoolOpt; cfg = config.my.build; @@ -28,6 +28,7 @@ in }; 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"; }; }; } diff --git a/util.nix b/util.nix index 78cf576..baa0087 100644 --- a/util.nix +++ b/util.nix @@ -22,6 +22,7 @@ rec { }; mkPkgs = path: args: genAttrs defaultSystems (system: import path (args // { inherit system; })); + mkApp = program: { type = "app"; inherit program; }; mkOpt = type: default: mkOption { inherit type default; }; mkBoolOpt = default: mkOption {