refactor: clan expose the clan module as is

This commit is contained in:
Johannes Kirschbauer
2025-06-26 11:47:37 +02:00
parent a5c5777a9e
commit af007bfe4a

View File

@@ -11,45 +11,58 @@ let
buildClanModule = clan-core.clanLib.buildClanModule; buildClanModule = clan-core.clanLib.buildClanModule;
publicAttrs = import ../lib/modules/public.nix;
# Create output options only for listed attributes
# TODO: Refactor this into an explicit module, so we can have description and other attributes to be listed in flake-parts
outputModule = {
clan = lib.genAttrs publicAttrs.clan (
name: config.clan.${name} or (throw "Output: clan.${name} not found.")
);
topLevel = {
options = lib.genAttrs publicAttrs.topLevel (_: lib.mkOption { });
config = lib.genAttrs publicAttrs.topLevel (
name: config.clan.${name} or (throw "Output: clan.${name} not found.")
);
};
};
in in
{ {
options.clan = lib.mkOption { # Backwards compatibility
default = { }; imports = [
type = types.submoduleWith { (lib.mkRenamedOptionModule [ "clan" ] [ "flake" "clan" ])
specialArgs = { ];
inherit clan-core self; # Our module is completely public, so we dont need to map it
inherit (inputs) nixpkgs nix-darwin; # Mapped top level outputs
# TODO: inject the inventory interface options.flake = {
# inventoryInterface = {}; # Backwards compat
clanInternals = lib.mkOption {
description = "Internals as used by the clan cli. Deprecated use clan.clanInternals";
visible = false;
readOnly = true;
default = config.flake.clan.clanInternals;
apply = lib.warn "Use clan.clanInternals instead";
};
# The one and only clan module
clan = lib.mkOption {
description = "The evaluated clan module";
default = { };
type = types.submoduleWith {
specialArgs = {
inherit clan-core self;
inherit (inputs) nixpkgs nix-darwin;
# TODO: inject the inventory interface
# inventoryInterface = {};
};
modules = [
buildClanModule.flakePartsModule
];
}; };
modules = [ };
buildClanModule.flakePartsModule
]; # Mapped flake toplevel outputs
darwinConfigurations = lib.mkOption {
type = types.lazyAttrsOf types.raw;
description = "darwinConfigurations produced by clan for a specific machine";
};
darwinModules = lib.mkOption {
type = types.lazyAttrsOf types.deferredModule;
description = "darwinModules produced by clan for a specific machine";
}; };
}; };
# Use normal prio, to allow merging with user values
options.flake = { config.flake = {
clan = lib.mkOption { type = types.raw; }; inherit (config.flake.clan)
} // outputModule.topLevel.options; nixosConfigurations
nixosModules
config = { darwinConfigurations
flake = { darwinModules
clan = outputModule.clan; ;
} // outputModule.topLevel.config;
}; };
_file = __curPos.file; _file = __curPos.file;