Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module system: Clean up and improve an error message #242812

Merged
merged 11 commits into from
Jul 11, 2023

Conversation

roberth
Copy link
Member

@roberth roberth commented Jul 11, 2023

Description of changes

This is mostly about refactoring away byName which was a non-abstraction.

Most of the commits are the small refactoring steps, separated out so they can be followed and checked.

The only commits that aren't pure refactoring are the ones titled

  • lib/modules.nix: Make entire definition list strict in config check
    • see commit message for argumentation why this is fine
  • lib.mergeModules: Add context to error message
    • an incremental improvement; see todo comment. I don't want to increase the scope of this PR.

These changes were motivated by #242339 (comment)

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, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.11 Release Notes (or backporting 23.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.

roberth added 9 commits July 11, 2023 11:37
byName is not an abstraction. This is the first commit in a series
that refactors it away.
This is a non-trivial refactor that slightly changes the semantics
of the internal definition lists.
Whereas previously only individual list items would trigger the exception,
now the error is promoted to the whole list.
This is mostly ok, because we compute the value, it is wrong to ignore a definition.
However, we don't always compute the value. For instance `readOnly`
only needs to count definitions. That won't be possible anymore when
the error is raised for one of the items. As a consequence, an error
will be raised for the errant definition instead of the number of
definitions.
@github-actions github-actions bot added 6.topic: module system About "NixOS" module system internals 6.topic: lib The Nixpkgs function library labels Jul 11, 2023
@roberth roberth force-pushed the modules-remove-byName-obfuscation branch from 5505bdb to 8014460 Compare July 11, 2023 11:04
checkedConfigs =
assert
lib.all
(c:
Copy link
Member Author

Choose a reason for hiding this comment

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

This is called module in the other functions, which seems like a really bad name for something that's only remotely module-like.
I've scoped out renaming more of it because I think we should first get our definitions straight and then rename it everywhere. Meanwhile, I can't approve of module so I just called it c for config.

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Jul 11, 2023
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.

Looking good!

@infinisil infinisil merged commit 0b339c8 into NixOS:master Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: lib The Nixpkgs function library 6.topic: module system About "NixOS" module system internals 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants