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

mkDerivation: Expose pname & version in meta #68620

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkgs/stdenv/generic/check-meta.nix
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ let
# Weirder stuff that doesn't appear in the documentation?
knownVulnerabilities = listOf str;
name = str;
version = str;
pname = str;
version = nullOr str;
tag = str;
updateWalker = bool;
executables = listOf str;
Expand Down
10 changes: 10 additions & 0 deletions pkgs/stdenv/generic/make-derivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,16 @@ in rec {
# lets have a clean always accessible version here.
name = attrs.name or "${attrs.pname}-${attrs.version}";

# Nix only knows of `name` attribute and considers `pname` what parseDrvName
# spits out. Unfortunately, that fails to account for many real-life packages
# that have variants or dashes followed by number in their name.
# Since many of packages in nixpkgs already have pname corresponding
# to project name, we will export it here. We will fallback to the parseDrvName
# algorithm when pname is not present.
# We handle the version similarly.
pname = attrs.pname or (builtins.parseDrvName attrs.name).name;
version = attrs.version or ((x: if x != "" then x else null) (builtins.parseDrvName attrs.name).version);
Copy link
Member

Choose a reason for hiding this comment

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

I agree with @volth that we should not have these fallbacks to parseDrvName because it is surprising to me that it would work like that. pname typically goes into name, so it is weird for name to go into pname in some cases.

Without these fallbacks the change seems quite uncontroversial. You are just saying make the attrs available in meta if they were passed in to mkDerivation.

Copy link
Member

Choose a reason for hiding this comment

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

If we want to make something like nameForRepology in the website export code with this logic, we could do that.


# If the packager hasn't specified `outputsToInstall`, choose a default,
# which is the name of `p.bin or p.out or p`;
# if he has specified it, it will be overridden below in `// meta`.
Expand Down