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:
DavHau
2023-10-25 16:36:01 +01:00
parent 1d45d493ef
commit bf176ad277
11 changed files with 234 additions and 81 deletions

View File

@@ -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 = {