Skip to content

meta.position specification is not overridable via <pkg>.overrideAttrs overriding #295907

Open

Description

@ShamrockLee

Describe the bug

According to Nix Manual and the stdenv.mkDerivation source, meta.position is specified by stdenv.mkDerivation according to several attributes of the package.

As meta.position is also used to update packages automatically, it is sometimes necessary to specify/override with a canonical value. A real-world example can be found in #295828. However, such overriding via <pkg>.overrideAttrs provided by stdenv.mkDerivation seems simply discarded.

Steps To Reproduce

$ nix repl
Welcome to Nix 2.18.1. Type :? for help.

nix-repl> pkgs = import ./. { }

nix-repl> pkgs.hello.meta.position
"/home/shamrock/Projects/NixOS/nixpkgs_timeshift/pkgs/by-name/he/hello/package.nix:34"

nix-repl> pkgs.cowsay.meta.position
"/home/shamrock/Projects/NixOS/nixpkgs_timeshift/pkgs/tools/misc/cowsay/default.nix:46"

nix-repl> (pkgs.hello.overrideAttrs (previousAttrs: { meta = previousAttrs.meta // { position = pkgs.cowsay.meta.position; }; })).meta.position
"/home/shamrock/Projects/NixOS/nixpkgs_timeshift/pkgs/by-name/he/hello/package.nix:34"

Or
nix eval --impure --expr "let pkgs = import ./. { }; in (pkgs.hello.overrideAttrs (previousAttrs: { meta = previousAttrs.meta // { position = pkgs.cowsay.meta.position; }; })).meta.position"

Expected behavior

The meta.position attribute be overridable with <pkg>.overrideAttrs, i.e.

$ nix eval --impure --expr "let pkgs = import ./. { }; in (pkgs.hello.overrideAttrs (previousAttrs: { meta = previousAttrs.meta // { position = pkgs.cowsay.meta.position; }; })).meta.position == pkgs.cowsay.meta.position"
true

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"
output here

Add a 👍 reaction to issues you find important.

Activity

  1. added
    0.kind: bug
    on Mar 14, 2024
  2. changed the title [-]`meta.position` is not overridable by `<pkg>.overrideAttrs`[/-] [+]`meta.position` specification is lost after `<pkg>.overrideAttrs` overriding[/+] on Mar 14, 2024
  3. changed the title [-]`meta.position` specification is lost after `<pkg>.overrideAttrs` overriding[/-] [+]`meta.position` specification is not overridable via `<pkg>.overrideAttrs` overriding[/+] on Mar 14, 2024
  4. wolfgangwalther commented on Jun 16, 2025

    @wolfgangwalther
    Contributor

    You can override the position with pos:

    (pkgs.hello.overrideAttrs { pos = builtins.unsafeGetAttrPos "description" pkgs.cowsay.meta; }).meta.position
    

    But it's a bit annoying, because you'd have to replicate the logic in mkDerivation to get to the actual meta.position of cowsay.

  5. added
    2.status: stale
    on Dec 14, 2025
  6. UlyssesZh commented on Mar 30, 2026

    @UlyssesZh
    Member

    I think this can be closed because overriding pos is the answer, right?

    To be honest, I think we should've used pos from the start instead of meta.position. It is just something that I don't think should be put in meta. Also meta.mainProgram should also not be put in meta.

    And the attr pos of meta.maintainers may be a better default value of pos?

  7. removed
    2.status: stale
    on Mar 30, 2026
  8. eclairevoyant commented on Mar 30, 2026

    @eclairevoyant
    Contributor

    And the attr pos of meta.maintainers may be a better default value of pos?

    That would require a massive refactor as packages now rely on the current behavior. Also, a fair number of packages don't have a maintainer, but nearly all should have a description.

  9. UlyssesZh commented on Mar 30, 2026

    @UlyssesZh
    Member

    Those without maintainers can fall back to descriptions. There is already meta.maintainersPosition. How many packages actually has meta.maintainersPosition set and being different from meta.position?

  10. added
    2.status: stale
    on Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bug2.status: stale6.topic: stdenv

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions