diff --git a/flake/system.nix b/flake/system.nix index 80f34c9..5513e3d 100644 --- a/flake/system.nix +++ b/flake/system.nix @@ -6,7 +6,7 @@ inputs, self, ... -}: let +} @ flakeArgs: let cfg = config.nixfiles.systems; inherit (lib) @@ -227,14 +227,22 @@ in { ++ lib.optional config.wsl wslModule; extraConfig = { inherit (config) system modules; - # TODO get rid of specialArgs and pass things as a module - specialArgs = let - inherit (self) outputs; - in { - inherit inputs outputs; - inherit (outerConfig.nixfiles) vars; + specialArgs = { + # TODO this is temporary, i prefer to not use specialArgs because + # it can't be exported. these are still better than my clunky + # "vars" arg that i would arbitrarily add things to. + # + # we need to merge all of the module args like this because the + # module evaluator only calls each module with the args it asks + # for, but we explicitly want *all* args to be made available. + flakeArgs = outerConfig._module.args // outerConfig._module.specialArgs // flakeArgs; + + # still unsure of what the best way to deal with this is. i can + # probably pass this submodule's args for a fairly clean way to + # pass it, but i'd want to refactor it because config.nixpkgs and + # config.home-manager.input are named inconsistently inherit (config) nixpkgs; - inherit (config.home-manager) input; + home-manager = config.home-manager.input; }; }; result = config.nixpkgs.lib.nixosSystem config.extraConfig; diff --git a/hosts/nixos-wsl/configuration.nix b/hosts/nixos-wsl/configuration.nix index 9520473..f6ca490 100644 --- a/hosts/nixos-wsl/configuration.nix +++ b/hosts/nixos-wsl/configuration.nix @@ -2,9 +2,11 @@ pkgs, config, lib, - vars, + flakeConfig, ... -}: { +}: let + inherit (flakeConfig.nixfiles) vars; +in { config = { networking.hostName = "nixos-wsl"; diff --git a/hosts/nullbox/configuration.nix b/hosts/nullbox/configuration.nix index 7096947..37f668f 100644 --- a/hosts/nullbox/configuration.nix +++ b/hosts/nullbox/configuration.nix @@ -6,7 +6,6 @@ config, lib, pkgs, - inputs, ... }: { imports = [ diff --git a/hosts/slab/configuration.nix b/hosts/slab/configuration.nix index a750fb1..aa296cd 100644 --- a/hosts/slab/configuration.nix +++ b/hosts/slab/configuration.nix @@ -6,7 +6,6 @@ config, lib, pkgs, - vars, ... }: { imports = [ diff --git a/system/common/nix.nix b/system/common/nix.nix index 322d2ae..57913eb 100644 --- a/system/common/nix.nix +++ b/system/common/nix.nix @@ -3,10 +3,11 @@ lib, config, options, - inputs, + flakeArgs, nixpkgs, ... }: let + inherit (flakeArgs) inputs; cfg = config.nixfiles.common.nix; in { options.nixfiles.common.nix = { diff --git a/system/default.nix b/system/default.nix index 55e1e82..bc78285 100644 --- a/system/default.nix +++ b/system/default.nix @@ -3,9 +3,9 @@ config, lib, options, + flakeArgs, nixpkgs, home-manager, - inputs, utils, ... } @ args: @@ -14,8 +14,15 @@ # inputs/outputs/overlays/etc into scope. this might even make nixfiles # portable (it still shouldn't be imported by other flakes probably) let + inherit (flakeArgs) inputs; + cfg = config.nixfiles; flakeType = cfg.lib.types.flake; + mkReadOnlyOption = {...} @ args: + lib.mkOption ({ + readOnly = true; + } + // args); in { imports = [ ./common @@ -35,7 +42,15 @@ in { inputs.lanzaboote.nixosModules.lanzaboote ./stylix.nix # imports inputs.stylix ]; - config = {}; + config = { + _module.args.flakeConfig = flakeArgs.config; + }; + options.debug = { + args = mkReadOnlyOption { + description = "all module args"; + default = config._module.args // config._module.specialArgs // args; + }; + }; options.nixfiles = { meta.wayland = lib.mkOption { description = "Whether to prefer wayland applications and configuration"; @@ -44,12 +59,6 @@ in { type = lib.types.bool; }; - utils = lib.mkOption { - description = "nixpkgs `utils` argument passthrough"; - default = utils; - readOnly = true; - }; - workarounds.nvidiaPrimary = lib.mkOption { description = "Whether to enable workarounds for NVIDIA as the primary GPU"; default = false; diff --git a/system/hardware/sound.nix b/system/hardware/sound.nix index 659c8dc..17b03d4 100644 --- a/system/hardware/sound.nix +++ b/system/hardware/sound.nix @@ -2,11 +2,12 @@ config, lib, pkgs, - inputs, + flakeArgs, ... }: let - cfg = config.nixfiles.hardware.sound; + inherit (flakeArgs) inputs; inherit (lib) optionals mkEnableOption mkIf mkDefault; + cfg = config.nixfiles.hardware.sound; in { # Enable sound. # sound.enable = true; diff --git a/system/minecraft.nix b/system/minecraft.nix index dd51793..660846e 100644 --- a/system/minecraft.nix +++ b/system/minecraft.nix @@ -2,9 +2,11 @@ config, lib, pkgs, - inputs, + flakeArgs, ... -}: { +}: let + inherit (flakeArgs) inputs; +in { imports = [ inputs.nix-minecraft.nixosModules.minecraft-servers ]; diff --git a/system/mitigations.nix b/system/mitigations.nix index 3d57e4d..01357f5 100644 --- a/system/mitigations.nix +++ b/system/mitigations.nix @@ -1,11 +1,10 @@ { pkgs, config, - lib, - inputs, - nixpkgs, + flakeArgs, ... }: let + inherit (flakeArgs) inputs; p5 = config.services.xserver.desktopManager.plasma5.enable; p6 = config.services.desktopManager.plasma6.enable; diff --git a/system/package-sets/gaming.nix b/system/package-sets/gaming.nix index 81bd1db..a91d8a5 100644 --- a/system/package-sets/gaming.nix +++ b/system/package-sets/gaming.nix @@ -2,7 +2,6 @@ config, lib, pkgs, - inputs, ... }: let cfg = config.nixfiles.packageSets.gaming; diff --git a/system/profile/base.nix b/system/profile/base.nix index 80c8ea3..fa10659 100644 --- a/system/profile/base.nix +++ b/system/profile/base.nix @@ -2,9 +2,6 @@ config, lib, pkgs, - options, - inputs, - outputs, ... } @ args: let cfg = config.nixfiles.profile.base; diff --git a/system/programs/android.nix b/system/programs/android.nix index bc8dc4e..7f9d64a 100644 --- a/system/programs/android.nix +++ b/system/programs/android.nix @@ -2,10 +2,10 @@ config, lib, pkgs, - outputs, - vars, + flakeConfig, ... } @ args: let + inherit (flakeConfig.nixfiles) vars; cfg = config.nixfiles.programs.adb; in { options.nixfiles.programs.adb = { diff --git a/system/sessions/hyprland.nix b/system/sessions/hyprland.nix index 2d59ff7..1ae29fd 100644 --- a/system/sessions/hyprland.nix +++ b/system/sessions/hyprland.nix @@ -2,9 +2,10 @@ lib, pkgs, config, - inputs, + flakeArgs, ... }: let + inherit (flakeArgs) inputs; cfg = config.nixfiles.sessions.hyprland; flake-package = inputs.hyprland.packages.${pkgs.system}.hyprland; flake-portal = inputs.hyprland.packages.${pkgs.system}.xdg-desktop-portal-hyprland; diff --git a/system/stylix.nix b/system/stylix.nix index 5785b61..d1aa102 100644 --- a/system/stylix.nix +++ b/system/stylix.nix @@ -2,9 +2,11 @@ pkgs, config, lib, - inputs, + flakeArgs, ... -} @ args: { +} @ args: let + inherit (flakeArgs) inputs; +in { imports = [inputs.stylix.nixosModules.stylix]; config = {