refactor: clan expose the clan module as is
This commit is contained in:
@@ -11,23 +11,26 @@ 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
|
||||||
|
imports = [
|
||||||
|
(lib.mkRenamedOptionModule [ "clan" ] [ "flake" "clan" ])
|
||||||
|
];
|
||||||
|
# Our module is completely public, so we dont need to map it
|
||||||
|
# Mapped top level outputs
|
||||||
|
options.flake = {
|
||||||
|
# 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 = { };
|
default = { };
|
||||||
type = types.submoduleWith {
|
type = types.submoduleWith {
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
@@ -42,14 +45,24 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
options.flake = {
|
# Mapped flake toplevel outputs
|
||||||
clan = lib.mkOption { type = types.raw; };
|
darwinConfigurations = lib.mkOption {
|
||||||
} // outputModule.topLevel.options;
|
type = types.lazyAttrsOf types.raw;
|
||||||
|
description = "darwinConfigurations produced by clan for a specific machine";
|
||||||
config = {
|
};
|
||||||
flake = {
|
darwinModules = lib.mkOption {
|
||||||
clan = outputModule.clan;
|
type = types.lazyAttrsOf types.deferredModule;
|
||||||
} // outputModule.topLevel.config;
|
description = "darwinModules produced by clan for a specific machine";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
# Use normal prio, to allow merging with user values
|
||||||
|
config.flake = {
|
||||||
|
inherit (config.flake.clan)
|
||||||
|
nixosConfigurations
|
||||||
|
nixosModules
|
||||||
|
darwinConfigurations
|
||||||
|
darwinModules
|
||||||
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
_file = __curPos.file;
|
_file = __curPos.file;
|
||||||
|
|||||||
Reference in New Issue
Block a user