Skip to content

Tracking issue: superfluous use of pname #277994

@AndersonTorres

Description

@AndersonTorres

There is a huge quantity of appearances of patterns like . . . = pname, . . . = finalAttrs.pname, ${pname} and alike in Nixpkgs.

After some amount of heated discussions with @SuperSandro2000, I come to the conclusion that this should be discouraged.

There are some reasons I can enumerate for it:

  1. Many, if not all, appearances of pname as an rvalue are basically constants - indeed they are constants since Nix is a functional language. They can be hardcoded with no loss (and some very small performance gains since the compiler will not need to consult the symbol tables).

    • It can be argued that other attributes change constantly, like the ubiquitous version.
      However, they change based on a familiar modification pattern from the upstream project, whereas things like pname rarely change.
  2. Related to the point above, this use of pname creates otherwise superfluous in-code dependencies

    1. This overcomplicates the static reasoning about the code
    2. This overcomplicates the use of override* functionalities
    3. The issues above are especially more pronounced in the context of finalAttrs design pattern
  3. Sometimes - indeed, most of the time - things like GitHub's repo and other source origins are not identical to pname. Some examples:

    • OpenMSX and Bochs.
      • By convention pname is all-lowercase.
        • An exception consecrated by the use is, curiously, SDL.
    • In the old times, PIL - the Python Imaging Library - had pname = pil and src.url = ". . ./Imaging-${version}.tar.gz"
    • Before migration to a dedicated forge, the MIR Project was called Unity-8.
      After being passed from Canonical to the community, it was renamed Lomiri, but the forge did not change his name. Indeed the old, now-frozen repo is still called https://github.com/ubports/unity8.
      Now it lives over https://gitlab.com/ubports/development/core/lomiri
  4. Nix is not a macro language like M4 or the CPP preprocessor.

    1. Just because two things have the same value, we should not treat them as if they are somehow connected
    2. Just because two things are somehow connected, this connection should not necessarily be converted into the code
    3. Pushing to the absurd and linking to the point above, it would be insane to parameterize each occurrence of pname.

References:

Metadata

Metadata

Assignees

No one assigned

    Labels

    5.scope: trackingLong-lived issue tracking long-term fixes or multiple sub-problems6.topic: best practicesDocumentation and discussion around best practices for Nixpkgs development

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions