api/machines: allow importing extra modules
- add top-level option `clanImports` to clanCore
- clanImports can be set and checked as any other option
- buildClan resolves the clanImports from the settings.json before calling evalModules to prevent infinite recursions
- new endpoint PUT machines/{name}/schema to allow getting the schema for a specific list of imports
- to retrieve the currently imported modules, cimply do a GET or PU on machines/{name}/config which will return `clanImports` as part of the config
Still missing: get list of available modules
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
{ self, inputs, lib, ... }: {
|
||||
flake.nixosModules.clanCore = { config, pkgs, options, ... }: {
|
||||
imports = [
|
||||
../clanImports
|
||||
./secrets
|
||||
./zerotier
|
||||
./networking.nix
|
||||
@@ -34,6 +35,11 @@
|
||||
internal = true;
|
||||
};
|
||||
};
|
||||
# TODO: factor these out into a separate interface.nix.
|
||||
# Also think about moving these options out of `system.clan`.
|
||||
# Maybe we should not re-use the already polluted confg.system namespace
|
||||
# and instead have a separate top-level namespace like `clanOutputs`, with
|
||||
# well defined options marked as `internal = true;`.
|
||||
options.system.clan = lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
options = {
|
||||
|
||||
16
nixosModules/clanImports/default.nix
Normal file
16
nixosModules/clanImports/default.nix
Normal file
@@ -0,0 +1,16 @@
|
||||
{ lib
|
||||
, ...
|
||||
}: {
|
||||
/*
|
||||
Declaring imports inside the module system does not trigger an infinite
|
||||
recursion in this case because buildClan generates the imports from the
|
||||
settings.json file before calling out to evalModules.
|
||||
*/
|
||||
options.clanImports = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
description = ''
|
||||
A list of imported module names imported from clan-core.clanModules.<name>
|
||||
The buildClan function will automatically import these modules for the current machine.
|
||||
'';
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user