Skip to content

modules: get flake ref from specialArgs instead of wrapper lambdas#144

Open
JamieMagee wants to merge 1 commit intonvmd:developfrom
JamieMagee:refactor/modules-use-specialargs
Open

modules: get flake ref from specialArgs instead of wrapper lambdas#144
JamieMagee wants to merge 1 commit intonvmd:developfrom
JamieMagee:refactor/modules-use-specialargs

Conversation

@JamieMagee
Copy link
Contributor

@JamieMagee JamieMagee commented Feb 24, 2026

Modules that need the flake self-reference (self) had two different patterns for receiving it:

  1. Standard NixOS module signature with no wrapping
    • Used by modules that didn't need self e.g. bluetooth.nix, display-vc4.nix
  2. A wrapping lambda in flake.nix that manually threaded self through
    • Used by every board module and nixpkgs-rpi

This meant flake.nix had a mix of import ./module.nix and { config, lib, pkgs, ... }: import ./module.nix { inherit config lib pkgs self; } depending on whether the module needed the flake reference. Adding a new module that referenced the flake meant remembering to add the wrapper.

Now all modules use the same pattern: accept nixos-raspberrypi as a regular module argument, provided via specialArgs. nixosSystemRPi injects it automatically, so users of lib.nixosSystem / lib.nixosSystemFull / lib.nixosInstaller need no changes.

Users who call nixpkgs.lib.nixosSystem directly and import board modules must pass nixos-raspberrypi in specialArgs. This was already effectively required (nixosSystemRPi previously asserted its presence) but the assertion is now replaced by auto-injection.

Modules that need the flake self-reference now accept
nixos-raspberrypi from specialArgs (standard NixOS module arg)
instead of having self threaded through ad-hoc wrapping lambdas
in flake.nix.

nixosSystemRPi auto-injects nixos-raspberrypi into specialArgs,
so callers of lib.nixosSystem/nixosSystemFull/nixosInstaller need
no changes. Direct nixpkgs.lib.nixosSystem users must pass
nixos-raspberrypi in specialArgs for board modules to work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant