Skip to content

nixos/specialisation: Rephrase in terms of extendModules, noUserModules#144094

Merged
roberth merged 1 commit intoNixOS:masterfrom
hercules-ci:nixos-specialisations-use-extendModules
Dec 1, 2021
Merged

nixos/specialisation: Rephrase in terms of extendModules, noUserModules#144094
roberth merged 1 commit intoNixOS:masterfrom
hercules-ci:nixos-specialisations-use-extendModules

Conversation

@roberth
Copy link
Member

@roberth roberth commented Nov 1, 2021

Motivation for this change

By using the new extendModules function #143207 to produce the specialisations,
we avoid reimplementing the eval-config.nix logic in reverse and fix
cross compilation support for specialisations in the process.

This does change the order of the modules, leading to ordering changes in list-typed options such as environment.systemPackages. This is a slight conceptual flaw in the module system, but at least some of us are aware of the potential issue and others have been saved by the fact that in many cases the order does not matter.
Normally I would consider this an acceptable change when refactoring, but I'm a little hesitant to do it right now, considering the imminent 21.11 branch-off.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes (or backporting 21.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

By using the new extendModules function to produce the specialisations,
we avoid reimplementing the eval-config.nix logic in reverse and fix
cross compilation support for specialisations in the process.
@roberth roberth added 0.kind: bug Something is broken 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: cross-compilation Building packages on a different platform than they will be used on labels Nov 1, 2021
@roberth roberth requested review from infinisil and nbp as code owners November 1, 2021 10:11
@github-actions github-actions bot added the 8.has: module (update) This PR changes an existing module in `nixos/` label Nov 1, 2021
children = mapAttrs (childName: childConfig:
(import ../../../lib/eval-config.nix {
inherit lib baseModules specialArgs;
system = config.nixpkgs.initialSystem;
Copy link
Member Author

@roberth roberth Nov 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this to have been insufficient for cross compiled NixOS. (which is fixed by this pr, as mentioned)

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Nov 1, 2021
Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good!

@roberth roberth merged commit 8a129f8 into NixOS:master Dec 1, 2021
@LunNova
Copy link
Member

LunNova commented Dec 2, 2021

Can't build my config which uses specialisations and I think it's after this change went in.

https://gist.github.com/TransLunarInjection/0121aa404aab1786cd2a347d2b80380e - full error trace

error: attribute 'baseModules' missing ...
while evaluating the module argument `baseModules' in "/nix/store/cvcnw3lnf3p76dd697l84qvyj5srql4k-source/nixos/modules/misc/documentation.nix":

@roberth roberth mentioned this pull request Dec 2, 2021
13 tasks
@roberth
Copy link
Member Author

roberth commented Dec 2, 2021

@TransLunarInjection The supposedly legacy args flags was still used and was not passed along correctly. #148315 fixes this at the module system level, at the NixOS level and in the documentation module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0.kind: bug Something is broken 6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants