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

treewide: use lib.optionalAttrs instead of 'then {}' #235924

Merged
merged 1 commit into from
Jun 13, 2023

Conversation

Stunkymonkey
Copy link
Contributor

@Stunkymonkey Stunkymonkey commented Jun 4, 2023

Description of changes
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.

@Stunkymonkey Stunkymonkey requested a review from peti as a code owner June 4, 2023 12:21
@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 Jun 4, 2023
@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 Jun 4, 2023
Copy link
Contributor

@drupol drupol left a comment

Choose a reason for hiding this comment

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

LGTM

@Stunkymonkey
Copy link
Contributor Author

thanks for your good and thorough reviews 👍

@Stunkymonkey Stunkymonkey added the 12.approvals: 2 This PR was reviewed and approved by two reputable people label Jun 10, 2023
@Stunkymonkey Stunkymonkey changed the title treewide: use use lib.optionalAttrs instead of 'then {}' treewide: use lib.optionalAttrs instead of 'then {}' Jun 10, 2023
@drupol drupol merged commit 7907dd9 into NixOS:master Jun 13, 2023
@vcunat
Copy link
Member

vcunat commented Jun 13, 2023

Aaand again - broke evaluation and is blocking channels.

$ nix eval -f. lispPackages.clsql.outPath
error: 'tail' called on an empty list
[...]

@@ -4,8 +4,7 @@ let
skipBuildPhase = x: {
overrides = y: ((x.overrides y) // { buildPhase = "true"; });
};
multiOverride = l: x: if l == [] then {} else
((builtins.head l) x) // (multiOverride (builtins.tail l) x);
multiOverride = l: x: pkgs.lib.optionalAttrs (l != []) ((builtins.head l) x) // (multiOverride (builtins.tail l) x);
Copy link
Member

Choose a reason for hiding this comment

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

I think missing parentheses here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed in #237631

Copy link
Member

Choose a reason for hiding this comment

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

OK I guess, though I really suspect that that if-then-else version was more readable. Also supported by getting several +1 reviews without noticing that the new code parses wrong. (copied this from chat, for reference)

Copy link
Member

Choose a reason for hiding this comment

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

Possibly relevant to the proposal for <| in NixOS/rfcs#148.

@Stunkymonkey Stunkymonkey deleted the remove-then-{} branch November 22, 2023 21:37
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 on Darwin 10.rebuild-linux: 1-10 12.approvals: 2 This PR was reviewed and approved by two reputable people
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants