- 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
59 lines
2.2 KiB
Nix
59 lines
2.2 KiB
Nix
{
|
|
# this placeholder is replaced by the path to nixpkgs
|
|
inputs.nixpkgs.url = "__NIXPKGS__";
|
|
|
|
outputs = inputs':
|
|
let
|
|
# fake clan-core input
|
|
fake-clan-core = {
|
|
clanModules.fake-module = ./fake-module.nix;
|
|
};
|
|
inputs = inputs' // { clan-core = fake-clan-core; };
|
|
machineSettings = (
|
|
if builtins.getEnv "CLAN_MACHINE_SETTINGS_FILE" != ""
|
|
then builtins.fromJSON (builtins.readFile (builtins.getEnv "CLAN_MACHINE_SETTINGS_FILE"))
|
|
else if builtins.pathExists ./machines/machine1/settings.json
|
|
then builtins.fromJSON (builtins.readFile ./machines/machine1/settings.json)
|
|
else { }
|
|
);
|
|
machineImports =
|
|
map
|
|
(module: fake-clan-core.clanModules.${module})
|
|
(machineSettings.clanImports or [ ]);
|
|
in
|
|
{
|
|
nixosConfigurations.machine1 = inputs.nixpkgs.lib.nixosSystem {
|
|
modules =
|
|
machineImports ++ [
|
|
./nixosModules/machine1.nix
|
|
machineSettings
|
|
({ lib, options, pkgs, ... }: {
|
|
config = {
|
|
nixpkgs.hostPlatform = "x86_64-linux";
|
|
# speed up by not instantiating nixpkgs twice and disable documentation
|
|
nixpkgs.pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux;
|
|
documentation.enable = false;
|
|
};
|
|
options.clanCore.optionsNix = lib.mkOption {
|
|
type = lib.types.raw;
|
|
internal = true;
|
|
readOnly = true;
|
|
default = (pkgs.nixosOptionsDoc { inherit options; }).optionsNix;
|
|
defaultText = "optionsNix";
|
|
description = ''
|
|
This is to export nixos options used for `clan config`
|
|
'';
|
|
};
|
|
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.
|
|
'';
|
|
};
|
|
})
|
|
];
|
|
};
|
|
};
|
|
}
|