feat(lib/buildClan): turn lib/build-clan into a 'buildClanModule' with sub-features such as 'buildClan' and 'flakePartsModule'

This commit is contained in:
Johannes Kirschbauer
2025-04-01 15:39:02 +02:00
parent 6bc98c14e5
commit 3c2708b263
3 changed files with 54 additions and 33 deletions

View File

@@ -9,6 +9,8 @@ clan-core:
}: }:
let let
inherit (lib) types; inherit (lib) types;
buildClanModule = clan-core.clanLib.buildClanModule;
in in
{ {
@@ -20,8 +22,7 @@ in
inherit (inputs) nixpkgs; inherit (inputs) nixpkgs;
}; };
modules = [ modules = [
../lib/build-clan/interface.nix buildClanModule.flakePartsModule
../lib/build-clan/module.nix
]; ];
}; };
}; };

View File

@@ -6,6 +6,24 @@
nixpkgs, nixpkgs,
clan-core, clan-core,
}: }:
let
clanResultAttributes = [
"clanInternals"
"nixosConfigurations"
];
in
{
inherit clanResultAttributes;
flakePartsModule = {
imports = [
./interface.nix
./module.nix
];
};
/**
Function that returns the same result as the correlated flake-parts module
*/
buildClan =
{ {
## Inputs ## Inputs
self ? lib.warn "Argument: 'self' must be set when using 'buildClan'." null, # Reference to the current flake self ? lib.warn "Argument: 'self' must be set when using 'buildClan'." null, # Reference to the current flake
@@ -29,7 +47,6 @@ let
; ;
inherit specialArgs; inherit specialArgs;
}; };
rest = builtins.removeAttrs attrs [ "specialArgs" ]; rest = builtins.removeAttrs attrs [ "specialArgs" ];
in in
eval { eval {
@@ -38,4 +55,5 @@ eval {
# implementation # implementation
./module.nix ./module.nix
]; ];
};
} }

View File

@@ -20,10 +20,12 @@ lib.fix (clanLib: {
clan-core = self; clan-core = self;
pkgs = nixpkgs.legacyPackages.x86_64-linux; pkgs = nixpkgs.legacyPackages.x86_64-linux;
}; };
buildClan = import ./build-clan {
buildClanModule = import ./build-clan {
inherit lib nixpkgs; inherit lib nixpkgs;
clan-core = self; clan-core = self;
}; };
buildClan = clanLib.buildClanModule.buildClan;
# ------------------------------------ # ------------------------------------
# Lib functions that don't depend on 'self' # Lib functions that don't depend on 'self'
inventory = clanLib.callLib ./inventory { }; inventory = clanLib.callLib ./inventory { };