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

lib.hiPrio gets erased after calling override or overrideAttrs #323624

Open
andrewhamon opened this issue Jun 30, 2024 · 3 comments
Open

lib.hiPrio gets erased after calling override or overrideAttrs #323624

andrewhamon opened this issue Jun 30, 2024 · 3 comments
Labels
0.kind: bug Something is broken

Comments

@andrewhamon
Copy link
Contributor

andrewhamon commented Jun 30, 2024

Describe the bug

lib.hiPrio and related functions update meta using simple merging.

If a package later has an override applied, though, the updated meta is discarded. This can be really surprising, particularly to those less well-versed in nix.

Steps To Reproduce

Try this in a REPL:

(pkgs.lib.hiPrio pkgs.cowsay).meta.priority
# => -10

((pkgs.lib.hiPrio pkgs.cowsay).overrideAttrs { }).meta.priority or "priority is not set"
# => "priority is not set"

# also impacts `override`
((pkgs.lib.hiPrio pkgs.cowsay).override { }).meta.priority or "priority is not set"
# => "priority is not set"

Expected behavior

Functions that "mutate" derivations should do so using overrideAttrs, so that later invocations of overrideAttrs don't discard information.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

Notify maintainers

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"aarch64-darwin"`
 - host os: `Darwin 23.5.0, macOS 14.5`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.22.0`
 - nixpkgs: `/nix/store/rhg90jpryc286xn9xjy6qjiaap6pjgdc-source`

Add a 👍 reaction to issues you find important.

@andrewhamon andrewhamon added the 0.kind: bug Something is broken label Jun 30, 2024
@andrewhamon
Copy link
Contributor Author

Similar issue from long ago where this is mentioned: #7425

@eclairevoyant
Copy link
Contributor

Why not move the hiPrio outside the override?

@andrewhamon
Copy link
Contributor Author

Yes, that's an easy workaround to apply, if you know what the problem is. But if you don't know already, I don't think the solution is obvious.

Do you see any downsides to adopting a merge function such as this?

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
Projects
None yet
Development

No branches or pull requests

2 participants