clan-core/pkgs/clan-cli/tests/test_flake/flake.nix

69 lines
2.3 KiB
Nix
Raw Normal View History

{
2023-09-15 10:31:18 +00:00
# this placeholder is replaced by the path to nixpkgs
inputs.nixpkgs.url = "__NIXPKGS__";
2024-03-17 18:48:49 +00:00
outputs =
inputs':
let
# fake clan-core input
fake-clan-core = {
clanModules.fake-module = ./fake-module.nix;
};
2024-03-17 18:48:49 +00:00
inputs = inputs' // {
clan-core = fake-clan-core;
};
machineSettings = (
2024-03-17 18:48:49 +00:00
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 {
2024-03-17 18:48:49 +00:00
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;
};
2024-06-17 10:42:28 +00:00
options.clan.core.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.
'';
};
2024-03-17 18:48:49 +00:00
}
)
];
};
};
}