From 77b6afd0340550a7526cfa684b3fbac500336ce0 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Sun, 30 Mar 2025 15:56:54 +0200 Subject: [PATCH] chore(lib): prepare for refactoring into clanLib --- lib/default.nix | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index 692579a99..64355d074 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,25 +1,38 @@ { lib, - clan-core, + self, nixpkgs, ... }: -let +# Produces the +# 'clanLib' attribute set +# Wrapped with fix, so we can depend on other clanLib functions without passing the whole flake +lib.fix (clanLib: { + # TODO: + # SSome bad lib functions that depend on something in 'self'. + # We should reduce the dependency on 'self' aka the 'flake' object + # This makes it easier to test + # most of the time passing the whole flake is unnecessary evalClan = import ./eval-clan-modules { - inherit clan-core lib; + inherit lib; + clan-core = self; pkgs = nixpkgs.legacyPackages.x86_64-linux; }; -in -{ - inherit (evalClan) evalClanModules evalClanModulesWithRoles; - buildClan = import ./build-clan { inherit lib nixpkgs clan-core; }; + buildClan = import ./build-clan { + inherit lib nixpkgs; + clan-core = self; + }; + inventory = import ./inventory { + inherit lib; + clan-core = self; + }; + modules = import ./frontmatter { + inherit lib self; + }; + # ------------------------------------ + # Lib functions that don't depend on 'self' facts = import ./facts.nix { inherit lib; }; - inventory = import ./inventory { inherit lib clan-core; }; values = import ./values { inherit lib; }; jsonschema = import ./jsonschema { inherit lib; }; - modules = import ./frontmatter { - inherit lib; - self = clan-core; - }; select = import ./select.nix; -} +})