mirror of
https://github.com/nix-community/home-manager.git
synced 2026-08-26 17:53:59 +00:00
`service.nix` imports the nixpkgs portable systemd service module by file
path, which only works while that file is a plain module. nixpkgs has
shipped it both ways: `541a6f371` wrapped it in a `{ pkgs }:` non-module-
arguments closure, and `ec69cf3f7` reverted that a day later. The module
system cannot apply such a closure itself, so against a nixpkgs pin in
that window every Home Manager evaluation fails during options generation
with `function 'anonymous lambda' called with unexpected argument 'lib'`.
Detect the shape with `lib.functionArgs` and apply the closure by hand
when it is present, rather than assuming either form. The plain module
declares `config`; the closure declares `pkgs` and no module arguments.
`lib.modules.importApply` preserves `_file` so module-system errors still
point at the nixpkgs file, and `lib.intersectAttrs` passes only the
arguments the closure actually declares.
The wrapped branch needs the `pkgs` value, so make `service.nix` itself a
non-module-arguments closure, matching the convention `lib/services` uses
for the module it extends. Keeping `pkgs` out of the module arguments is
what lets service modules stay portable, so it must not go into
`extraRootSpecialArgs` where every user-written service module would see
it. `nixpkgsPath` is dropped from those special arguments: it existed only
to locate this file, and `pkgs.path` supersedes it.
Assisted-by: Claude:claude-opus-5