flake-parts/setups/nixos: add specialArgs through declarative setups

This commit is contained in:
Gabriel Arazas 2024-09-28 18:59:13 +08:00
parent e983561f99
commit 9292a75ffa
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360
3 changed files with 39 additions and 0 deletions

View File

@ -39,5 +39,20 @@
allowUnfree = true;
};
};
sharedSpecialArgs = lib.mkOption {
type = with lib.types; attrsOf anything;
description = ''
Shared set of arguments to be assigned as part of `_module.specialArgs`
of each of the declarative setups.
'';
default = { };
example = lib.literalExpression ''
{
location = "Inside of your walls";
utilsLib = import ./lib/utils.nix;
}
'';
};
};
}

View File

@ -170,6 +170,7 @@ let
};
config.nixpkgs.config = cfg.sharedNixpkgsConfig;
config.specialArgs = cfg.sharedSpecialArgs;
config.modules = [
# Bring in the required modules.
@ -209,6 +210,13 @@ in
'';
};
sharedSpecialArgs = options.setups.sharedSpecialArgs // {
description = ''
Shared set of module arguments as part of `_module.specialArgs` of the
configuration.
'';
};
sharedModules = lib.mkOption {
type = with lib.types; listOf deferredModule;
default = [ ];
@ -222,6 +230,7 @@ in
(import ./shared/nix-conf.nix { inherit inputs; })
(import ./shared/config-options.nix { inherit (config) systems; })
./shared/nixpkgs-options.nix
./shared/special-args-options.nix
configType
]);
default = { };
@ -318,6 +327,7 @@ in
in
lib.nameValuePair system (mkHost {
inherit pkgs system;
inherit (metadata) specialArgs;
extraModules = cfg.sharedModules ++ metadata.modules;
})
)

View File

@ -0,0 +1,14 @@
{ config, lib, ... }:
{
options.specialArgs = lib.mkOption {
type = with lib.types; attrsOf anything;
default = { };
example = lib.literalExpression ''
{
location = "Your mom's home";
utilsLib = import ./lib/utils.nix;
}
'';
};
}