modules: fix modular services with strict nixpkgs modules - #9708
modules: fix modular services with strict nixpkgs modules#9708DaVinci42 wants to merge 1 commit into
Conversation
Call the imported systemd service module with only the arguments it accepts so Home Manager does not fail when nixpkgs rejects extra module arguments.
f54bcc8 to
e70de1e
Compare
|
hey there, sorry again for NixOS/nixpkgs#518860 having broken downstream consumption like here. for what it's worth, the underlying breaking change was reverted at NixOS/nixpkgs#545519, and the refile at NixOS/nixpkgs#545521 would lack the breaking change. i think the underlying issue here is in file-based imports being fragile, hence i'd filed a few PRs to shift toward going thru root-level entrypoints instead:
on the approach proposed in the current PR, i think the tough part is that the breaking change in this particular case was maybe less about adding or removing an argument, more about the module there getting wrapped in a closure, which then maybe raises the question for me on whether the approach here wouldn't like break again with the (now-landed) revert at NixOS/nixpkgs#545519 - or, for that matter, with the refile at NixOS/nixpkgs#545521. in that sense, i wonder if the fix here would help more than just that revert upstream. |
Thanks for the context! Since the follow up PRs are still pending, I’ll hold off for now. |
|
Tested again with the latest nixpkgs, and the build works fine now. |
Just FYI, neither the revert or refile landed in the latest nixpkgs-unstable, breaking evaluation in a very significant way. Is there a way to avoid this with home-manager right now? |
Description
Fixes evaluation of modular services when the imported nixpkgs systemd service module does not accept every argument passed by the Home Manager module system.
Minimal reproducer:
Build command:
nix build .#homeConfigurations.repro.activationPackage --show-traceThis currently fails while generating the Home Manager manpage/options:
This happens because
modules/services-modular/service.niximports the nixpkgs systemd service module as a module path. The module system then calls it with the full Home Manager argument set. Some nixpkgs revisions expose that file as a stricter function and reject extra arguments such asliborspecialArgs.The fix imports the nixpkgs module function explicitly and calls it with only the arguments declared by that function. This preserves compatibility with different nixpkgs signatures while avoiding accidental argument injection by the module system.
Checklist
nix fmtornix-shell -A dev --run treefmt.nix build .#test-allor a targeted
nix run .#tests -- <pattern>.