config: replace specialArgs with _modules.args in NixOS config

This commit is contained in:
Gabriel Arazas 2023-12-13 10:00:43 +08:00
parent 231200546d
commit b04a284489
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC
2 changed files with 11 additions and 10 deletions

View File

@ -175,6 +175,9 @@
inputs.nixos-wsl.nixosModules.default inputs.nixos-wsl.nixosModules.default
]; ];
# Set some extra, yeah?
_module.args = extraArgs;
# Find Nix files with these! Even if nix-index is already enabled, it # Find Nix files with these! Even if nix-index is already enabled, it
# is better to make it explicit. # is better to make it explicit.
programs.command-not-found.enable = false; programs.command-not-found.enable = false;
@ -215,7 +218,6 @@
home-manager.useUserPackages = lib.mkDefault true; home-manager.useUserPackages = lib.mkDefault true;
home-manager.useGlobalPkgs = lib.mkDefault true; home-manager.useGlobalPkgs = lib.mkDefault true;
home-manager.sharedModules = [ userSharedConfig ]; home-manager.sharedModules = [ userSharedConfig ];
home-manager.extraSpecialArgs = extraArgs;
# Enabling some things for sops. # Enabling some things for sops.
programs.gnupg.agent = lib.mkDefault { programs.gnupg.agent = lib.mkDefault {
@ -246,6 +248,9 @@
inputs.nix-index-database.hmModules.nix-index inputs.nix-index-database.hmModules.nix-index
]; ];
# Set some extra, yeah?
_module.args = extraArgs;
# Hardcoding this is not really great especially if you consider using # Hardcoding this is not really great especially if you consider using
# other locales but its default values are already hardcoded so what # other locales but its default values are already hardcoded so what
# the hell. For other users, they would have to do set these manually. # the hell. For other users, they would have to do set these manually.
@ -371,7 +376,6 @@
lib'.mapAttrs lib'.mapAttrs
(host: metadata: (host: metadata:
mkHost { mkHost {
inherit extraArgs;
extraModules = [(hostSpecificModule host metadata)]; extraModules = [(hostSpecificModule host metadata)];
system = metadata._system; system = metadata._system;
nixpkgs-channel = metadata.nixpkgs-channel or "nixpkgs"; nixpkgs-channel = metadata.nixpkgs-channel or "nixpkgs";
@ -411,7 +415,7 @@
]; ];
in in
mkHome { mkHome {
inherit pkgs extraModules extraArgs; inherit pkgs extraModules;
home-manager-channel = metadata.home-manager-channel or "home-manager"; home-manager-channel = metadata.home-manager-channel or "home-manager";
}) })
users; users;
@ -449,7 +453,7 @@
format = metadata.format or "iso"; format = metadata.format or "iso";
in in
lib'.nameValuePair name (mkImage { lib'.nameValuePair name (mkImage {
inherit format system pkgs extraArgs; inherit format system pkgs;
extraModules = [(hostSpecificModule host metadata)]; extraModules = [(hostSpecificModule host metadata)];
})) }))
images'); images');

View File

@ -4,27 +4,24 @@
{ {
# A wrapper around the NixOS configuration function. # A wrapper around the NixOS configuration function.
mkHost = { system, extraModules ? [ ], extraArgs ? { }, nixpkgs-channel ? "nixpkgs" }: mkHost = { system, extraModules ? [ ], nixpkgs-channel ? "nixpkgs" }:
(lib.makeOverridable inputs."${nixpkgs-channel}".lib.nixosSystem) { (lib.makeOverridable inputs."${nixpkgs-channel}".lib.nixosSystem) {
# The system of the NixOS system. # The system of the NixOS system.
inherit lib; inherit lib;
specialArgs = extraArgs;
modules = extraModules ++ [{ nixpkgs.hostPlatform = system; }]; modules = extraModules ++ [{ nixpkgs.hostPlatform = system; }];
}; };
# A wrapper around the home-manager configuration function. # A wrapper around the home-manager configuration function.
mkHome = { pkgs, extraModules ? [ ], extraArgs ? { }, home-manager-channel ? "home-manager" }: mkHome = { pkgs, extraModules ? [ ], home-manager-channel ? "home-manager" }:
inputs."${home-manager-channel}".lib.homeManagerConfiguration { inputs."${home-manager-channel}".lib.homeManagerConfiguration {
inherit lib pkgs; inherit lib pkgs;
extraSpecialArgs = extraArgs;
modules = extraModules; modules = extraModules;
}; };
# A wrapper around the nixos-generators `nixosGenerate` function. # A wrapper around the nixos-generators `nixosGenerate` function.
mkImage = { system, pkgs ? null, extraModules ? [ ], extraArgs ? { }, format ? "iso" }: mkImage = { system, pkgs ? null, extraModules ? [ ], format ? "iso" }:
inputs.nixos-generators.nixosGenerate { inputs.nixos-generators.nixosGenerate {
inherit pkgs system format lib; inherit pkgs system format lib;
specialArgs = extraArgs;
modules = extraModules; modules = extraModules;
}; };