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

nixos/nixpkgs: fix assertion text & show def files #343212

Merged
merged 2 commits into from
Sep 20, 2024

Conversation

MattSturgeon
Copy link
Contributor

Description of changes

  • nixos/nixpkgs: fix config assertion text
  • nixos/nixpkgs: show definition files in config assertion

The existing opt.pkgs.isDefined -> cfg.config == {} assertion was printing the nixpkgs.config option instead of the value. This PR fixes that, and in a follow-up commit also prints the defining files.

I was tempted to use lib.options.showDefs, however I felt it made more sense in this instance to show the full and final value in its entirety and then only list the defining files. This avoids an unnecessarily long and repetitive assertion message. Note that showDefs would show part of each definition, each truncated after a few lines.

The assertion in question was introduced in ce87196 (#257458 Sept 2023) by @K900 and hasn't been touched since.

cc (some) original reviewers: @roberth @khaneliman @FRidh @SuperSandro2000

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • 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/)
  • 24.11 Release Notes (or backporting 23.11 and 24.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.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 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/` labels Sep 20, 2024
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 1-10 labels Sep 20, 2024
@roberth
Copy link
Member

roberth commented Sep 20, 2024

This looks alright. I think the mistake was made because opt.foo renders as an option path, but toPretty doesn't do that; not that it matters much.

Could you add a regression test to nixos/modules/misc/nixpkgs/test.nix?

The assertion message should include the `nixpkgs.config` value, however
it currently includes the entire `nixpkgs.config` _option_.

This means the type, declarations, definitions, etc were all printed.
@MattSturgeon
Copy link
Contributor Author

Could you add a regression test to nixos/modules/misc/nixpkgs/test.nix?

Good idea! I've added one based on the existing "ambiguous" test.

Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

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

Awesome ❤️

@roberth roberth merged commit d12ed10 into NixOS:master Sep 20, 2024
9 of 10 checks passed
@roberth
Copy link
Member

roberth commented Sep 20, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants