refactor: clanLib buildClan

This commit is contained in:
Johannes Kirschbauer
2025-06-26 15:20:05 +02:00
parent 9ef518fa20
commit 761e8b0ec5
5 changed files with 66 additions and 48 deletions

View File

@@ -9,7 +9,7 @@ clan-core:
let
inherit (lib) types;
buildClanModule = clan-core.clanLib.buildClanModule;
clanLib = clan-core.clanLib;
in
{
@@ -40,7 +40,7 @@ in
# inventoryInterface = {};
};
modules = [
buildClanModule.flakePartsModule
clanLib.module
];
};
};

View File

@@ -197,7 +197,7 @@ in
self = throw "set clan.directory in the test";
};
modules = [
clanLib.buildClanModule.flakePartsModule
clanLib.module
{
_prefix = [
"checks"

View File

@@ -8,23 +8,40 @@
# Produces the
# 'clanLib' attribute set
# Wrapped with fix, so we can depend on other clanLib functions without passing the whole flake
lib.fix (clanLib: {
lib.fix (
clanLib:
let
buildClanLib = (
clanLib.callLib ./modules {
clan-core = self;
inherit nixpkgs nix-darwin;
}
);
in
{
module = {
_class = "clan";
_module.args = {
inherit clanLib;
};
imports = [
./modules/clan/default.nix
];
};
inherit (buildClanLib)
buildClan
;
/**
Like callPackage, but doesn't try to automatically detect arguments
'lib' and 'clanLib' are always passed, plus the additional arguments
*/
callLib = file: args: import file ({ inherit lib clanLib; } // args);
# ------------------------------------
buildClan = clanLib.buildClanModule.buildClanWith {
clan-core = self;
inherit nixpkgs nix-darwin;
};
evalService = clanLib.callLib ./modules/inventory/distributed-service/evalService.nix { };
# ------------------------------------
# ClanLib functions
evalClan = clanLib.callLib ./modules/inventory/eval-clan-modules { };
buildClanModule = clanLib.callLib ./modules { };
inventory = clanLib.callLib ./modules/inventory { };
modules = clanLib.callLib ./modules/inventory/frontmatter { };
test = clanLib.callLib ./test { };
@@ -44,4 +61,5 @@ lib.fix (clanLib: {
# deprecated
# remove when https://git.clan.lol/clan/clan-core/pulls/3212 is implemented
inherit (self.inputs.nix-select.lib) select;
})
}
)

View File

@@ -4,19 +4,19 @@
{
lib,
clanLib,
...
clan-core,
nixpkgs,
nix-darwin,
}:
rec {
# TODO: rename to clanModule
flakePartsModule = {
_module.args = {
inherit clanLib;
# ------------------------------------
buildClan = buildClanWith {
inherit
clan-core
nixpkgs
nix-darwin
;
};
imports = [
./clan/default.nix
];
};
/**
A function that takes some arguments such as 'clan-core' and returns the 'buildClan' function.
@@ -61,7 +61,7 @@ rec {
modules = [
# buildClan arguments are equivalent to specifying a module
m
flakePartsModule
clanLib.module
];
};
in

View File

@@ -9,7 +9,7 @@ let
# @enzime why do we need this here?
class = "nixos";
modules = [
clanLib.buildClanModule.flakePartsModule
clanLib.module
];
};
evalDocs = pkgs.nixosOptionsDoc {