From 04a31bea67b6449302def380bf5b4f2981aaea32 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Fri, 27 Jun 2025 09:21:19 +0200 Subject: [PATCH] modules: fix consistent nixpkgs and nix-darwin injection --- flakeModules/clan.nix | 16 ++++++++-------- lib/modules/clan/default.nix | 2 -- lib/modules/clan/module.nix | 1 - lib/modules/default.nix | 13 +++++++++++-- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/flakeModules/clan.nix b/flakeModules/clan.nix index 36730d55b..977033c73 100644 --- a/flakeModules/clan.nix +++ b/flakeModules/clan.nix @@ -1,34 +1,34 @@ clan-core: +# Downstream flake arguments { + self, + inputs, config, lib, - self, ... }: let inherit (lib) types; - in { # 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 + # CLI compat clanInternals = lib.mkOption { - description = "Internals as needed by the clan cli."; + description = "Stable nix interface interacted by the clan cli."; default = config.flake.clan.clanInternals; }; - # The one and only clan module + # The clan module clan = lib.mkOption { - description = "The evaluated clan module"; + description = "Clan module. Define your clan inside here"; default = { }; type = types.submoduleWith { specialArgs = { inherit self; + inherit (inputs) nixpkgs nix-darwin; }; modules = [ clan-core.modules.clan.default diff --git a/lib/modules/clan/default.nix b/lib/modules/clan/default.nix index 51a1e37b5..af742cbcc 100644 --- a/lib/modules/clan/default.nix +++ b/lib/modules/clan/default.nix @@ -4,8 +4,6 @@ _module.args = { inherit clan-core; inherit (clan-core) clanLib; - # TODO: This should be set via an option otherwise it is not possible to override - inherit (clan-core.inputs) nixpkgs nix-darwin; }; imports = [ ./module.nix diff --git a/lib/modules/clan/module.nix b/lib/modules/clan/module.nix index de5a88d3a..4ea328dfd 100644 --- a/lib/modules/clan/module.nix +++ b/lib/modules/clan/module.nix @@ -165,7 +165,6 @@ in config = { inventory.modules = clan-core.clanModules; inventory._legacyModules = clan-core.clanModules; - # Merge the meta attributes from the buildClan function inventory.meta = config.meta; outputs.moduleForMachine = lib.mkMerge [ diff --git a/lib/modules/default.nix b/lib/modules/default.nix index d9bd27ce2..1ab56a159 100644 --- a/lib/modules/default.nix +++ b/lib/modules/default.nix @@ -7,18 +7,27 @@ }: rec { buildClan = - module: lib.warn "'buildClan' is deprecated. Use 'clan-core.lib.clan' instead" (clan module).config; + # TODO: Once all templates and docs are migrated add: lib.warn "'buildClan' is deprecated. Use 'clan-core.lib.clan' instead" + module: (clan module).config; clan = { - 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" null, # Reference to the current flake ... }@m: + let + nixpkgs = self.inputs.nixpkgs or clan-core.inputs.nixpkgs; + nix-darwin = self.inputs.nix-darwin or clan-core.inputs.nix-darwin; + in lib.evalModules { specialArgs = { inherit self ; + inherit + nixpkgs + nix-darwin + ; }; modules = [ m