add miniguest.<guest>.system

This commit is contained in:
Julie B. 2021-10-11 19:01:16 +02:00
parent d58d012d4c
commit 7c33c3e2c1
2 changed files with 14 additions and 6 deletions

View File

@ -13,13 +13,13 @@
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
inputs:
{ lib, ... }:
{ config, lib, ... }:
with lib;
{
options.miniguests = mkOption {
description = "A set of NixOS configurations to be built and made available as miniguests.";
default = { };
type = types.attrsOf (types.submodule ({ config, options, name, ... }:
type = types.attrsOf (types.submodule ({ options, name, ... }:
{
options = {
configuration = mkOption {
@ -32,6 +32,14 @@ with lib;
merge = lib.options.mergeOneOption;
};
};
system = mkOption {
description = ''
specifies the nix platform type for which the guest should be built.
'';
type = types.str;
default = config.nixpkgs.initialSystem;
defaultText = literalDocBook "same as the host";
};
};
}));
};

View File

@ -16,9 +16,9 @@ inputs@{ nixpkgs, ... }:
{ baseModules, config, lib, pkgs, specialArgs, ... }:
let
hostPkgs = pkgs; # give the guest the packages from the host configuration
mkGuest = name: configuration: nixpkgs.lib.nixosSystem {
mkGuest = name: configuration: system: nixpkgs.lib.nixosSystem {
inherit lib baseModules specialArgs;
system = config.nixpkgs.initialSystem;
inherit system;
modules = [
configuration
../core
@ -34,7 +34,7 @@ lib.mkIf (config.miniguests != { }) {
environment.etc =
with lib.attrsets;
lib.flip mapAttrs' config.miniguests
(name: { configuration, ... }: nameValuePair "miniguests/${name}" {
source = (mkGuest name configuration).config.system.build.miniguest;
(name: { configuration, system, ... }: nameValuePair "miniguests/${name}" {
source = (mkGuest name configuration system).config.system.build.miniguest;
});
}