mirror of
https://github.com/oddlama/nix-config.git
synced 2025-10-11 07:10:39 +02:00
feat: allow microvms to override configPath
This commit is contained in:
parent
f65b217a92
commit
cc2397669d
7 changed files with 74 additions and 53 deletions
|
@ -89,25 +89,9 @@
|
|||
};
|
||||
|
||||
microvm.vms.${vmName} = let
|
||||
# Loads configuration from a subfolder of this nodes configuration, if it exists.
|
||||
configPath =
|
||||
if nodePath == null
|
||||
then null
|
||||
else nodePath + "/microvms/${vmName}";
|
||||
|
||||
node =
|
||||
(import ../nix/generate-node.nix inputs)
|
||||
vmCfg.nodeName
|
||||
{
|
||||
inherit (vmCfg) system;
|
||||
# Load configPath, if it exists.
|
||||
${
|
||||
if configPath != null && builtins.pathExists configPath
|
||||
then "config"
|
||||
else null
|
||||
} =
|
||||
configPath;
|
||||
};
|
||||
node = import ../nix/generate-node.nix inputs vmCfg.nodeName {
|
||||
inherit (vmCfg) system configPath;
|
||||
};
|
||||
mac = net.mac.addPrivate vmCfg.id cfg.networking.baseMac;
|
||||
in {
|
||||
# Allow children microvms to know which node is their parent
|
||||
|
@ -265,6 +249,12 @@ in {
|
|||
];
|
||||
|
||||
options.extra.microvms = {
|
||||
commonImports = mkOption {
|
||||
type = types.listOf types.unspecified;
|
||||
default = [];
|
||||
description = mdDoc "Modules to import on all microvms.";
|
||||
};
|
||||
|
||||
networking = {
|
||||
baseMac = mkOption {
|
||||
type = net.types.mac;
|
||||
|
@ -353,6 +343,26 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
configPath = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default =
|
||||
if nodePath != null && builtins.pathExists (nodePath + "/microvms/${name}")
|
||||
then nodePath + "/microvms/${name}"
|
||||
else null;
|
||||
description = mdDoc ''
|
||||
The main configuration directory for this microvm. If not-null, the given
|
||||
directory will automatically be imported as system configuration. It will
|
||||
become the nodePath for the microvm meaning that some machine-specific files
|
||||
may be referenced there automatically (for example host.pub).
|
||||
|
||||
This can also be set to a file, which will then simply be used as the main
|
||||
import for configuration, without setting a nodePath.
|
||||
|
||||
By default this will be set to the current node's <nodePath>/microvms/<vmname>
|
||||
if the current nodePath is non-null and the directory exists.
|
||||
'';
|
||||
};
|
||||
|
||||
id = mkOption {
|
||||
type =
|
||||
types.addCheck types.int (x: x > 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue