refactor(guest): assemble guest modules
This commit is contained in:
@@ -6,12 +6,9 @@
|
||||
registryAssembly,
|
||||
util,
|
||||
}:
|
||||
{
|
||||
let
|
||||
mkGuest =
|
||||
{
|
||||
name,
|
||||
interior ? { },
|
||||
}:
|
||||
name:
|
||||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.guests.${name};
|
||||
@@ -131,6 +128,11 @@
|
||||
Mounts are read-write unless `readOnly` is set.
|
||||
'';
|
||||
};
|
||||
interior = lib.mkOption {
|
||||
type = lib.types.deferredModule;
|
||||
default = { };
|
||||
description = "NixOS module imported into the guest interior.";
|
||||
};
|
||||
limits = {
|
||||
memory = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
@@ -246,7 +248,7 @@
|
||||
|
||||
repositoryModules
|
||||
registryAssembly.module
|
||||
interior
|
||||
cfg.interior
|
||||
|
||||
{
|
||||
modules.guest.enable = true;
|
||||
@@ -265,4 +267,16 @@
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
mkGuests =
|
||||
{ root }:
|
||||
let
|
||||
files = util.collectNixFiles root;
|
||||
guestFiles = lib.filterAttrs (file: type: type == "regular" && lib.hasSuffix ".nix" file) (builtins.readDir root);
|
||||
names = map (file: lib.removeSuffix ".nix" file) (lib.attrNames guestFiles);
|
||||
in
|
||||
{
|
||||
imports = files ++ map mkGuest names;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user