diff --git a/flakeModules/clan.nix b/flakeModules/clan.nix index 45f5e382f..b837d92dd 100644 --- a/flakeModules/clan.nix +++ b/flakeModules/clan.nix @@ -3,20 +3,19 @@ clan-core: config, lib, flake-parts-lib, + self, inputs, ... }: let - inherit (lib) mkOption types; + inherit (lib) types; in { options.clan = lib.mkOption { type = types.submoduleWith { - # _module.args = { - # }; specialArgs = { - inherit clan-core; + inherit clan-core self; inherit (inputs) nixpkgs; }; modules = [ diff --git a/lib/build-clan/default.nix b/lib/build-clan/default.nix index ca9ae4572..ed7057e57 100644 --- a/lib/build-clan/default.nix +++ b/lib/build-clan/default.nix @@ -11,6 +11,7 @@ directory, # The directory containing the machines subdirectory # allows to include machine-specific modules i.e. machines.${name} = { ... } # A map from arch to pkgs, if specified this nixpkgs will be only imported once for each system. # This improves performance, but all nipxkgs.* options will be ignored. + # deadnix: skip inventory ? { }, ## Sepcial inputs (not passed to the module system as config) specialArgs ? { }, # Extra arguments to pass to nixosSystem i.e. useful to make self available # A set containing clan meta: name :: string, icon :: string, description :: string @@ -27,14 +28,9 @@ let ; self = directory; }; - meta = attrs.meta or { }; - rest = builtins.removeAttrs attrs [ - "meta" - "specialArgs" - ]; + rest = builtins.removeAttrs attrs [ "specialArgs" ]; in eval { - inventory.meta = lib.mapAttrs (_: lib.mkDefault) meta; imports = [ rest # implementation diff --git a/lib/build-clan/interface.nix b/lib/build-clan/interface.nix index 275aa1664..2e11b531e 100644 --- a/lib/build-clan/interface.nix +++ b/lib/build-clan/interface.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ lib, self, ... }: let types = lib.types; in @@ -7,6 +7,7 @@ in # Required options directory = lib.mkOption { type = types.path; + default = self; description = "The directory containing the clan subdirectory"; }; @@ -26,22 +27,18 @@ in }; # Meta - meta = { - name = lib.mkOption { - type = types.nullOr types.str; - default = null; - description = "Needs to be (globally) unique, as this determines the folder name where the flake gets downloaded to."; - }; - icon = lib.mkOption { - type = types.nullOr types.path; - default = null; - description = "A path to an icon to be used for the clan in the GUI"; - }; - description = lib.mkOption { - type = types.nullOr types.str; - default = null; - description = "A short description of the clan"; - }; + meta = lib.mkOption { + type = types.nullOr ( + types.submodule { + options = { + name = lib.mkOption { + type = types.nullOr types.str; + description = "Needs to be (globally) unique, as this determines the folder name where the flake gets downloaded to."; + }; + }; + } + ); + default = null; }; pkgsForSystem = lib.mkOption { diff --git a/lib/build-clan/module.nix b/lib/build-clan/module.nix index a523e5542..390625248 100644 --- a/lib/build-clan/module.nix +++ b/lib/build-clan/module.nix @@ -201,6 +201,8 @@ in imports = [ # Merge the inventory file { inventory = inventoryLoaded; } + # Merge the meta attributes from the buildClan function + { inventory.meta = if config.meta != null then config.meta else { }; } ]; inherit nixosConfigurations; diff --git a/lib/build-clan/tests.nix b/lib/build-clan/tests.nix index b231cdfdf..eb0250051 100644 --- a/lib/build-clan/tests.nix +++ b/lib/build-clan/tests.nix @@ -15,10 +15,13 @@ in { test_only_required = let - config = evalClan { directory = ./.; }; + config = evalClan { + meta.name = "test"; + imports = [ ./module.nix ]; + }; in { - expr = config.pkgsForSystem null == null; + expr = config.inventory ? meta; expected = true; }; @@ -93,10 +96,9 @@ in in { expr = result.clanInternals.meta; - expected = { - description = "description"; - icon = "icon"; - name = "superclan"; + expectedError = { + type = "ThrownError"; + msg = ""; }; };