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

nix-env: Use pname and version attrs in -q #4463

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jtojnar
Copy link
Contributor

@jtojnar jtojnar commented Jan 18, 2021

Previously1, we started including pname and version keys in nix-env -qa --json output (and thus in packages.json).

But those values were obtained using parseDrvName, which does not work in many cases, for example when a project does not follow Nix’s arbitrary requirement that version names have to start with a digit.

The keys are also misleading as many modern Nixpkgs packages pass identically named attributes to mkDerivation but these keys do not use those values.

Let’s fix this discrepancy by officially recognizing pname and version attributes as special and using them in the JSON output.

This will be useful for Repology as well.

@jtojnar
Copy link
Contributor Author

jtojnar commented Jan 18, 2021

Verified that this patch prints correct values in nix-env -f channel:nixos-unstable-small -qa --json:

Unstable Nix:

1901858:  "vapoursynth": {
1901859:    "name": "vapoursynth-R52",
1901860:    "pname": "vapoursynth-R52",
1901861-    "version": "",

This patch:

1904437:  "vapoursynth": {
1904438:    "name": "vapoursynth-R49",
1904439:    "pname": "vapoursynth",
1904440-    "version": "R49",

@jtojnar
Copy link
Contributor Author

jtojnar commented Jan 18, 2021

Wanted to mark this as closing https://github.com/NixOS/nixos-homepage/issues/306 but that issue disappeared (still accessible through API).

@edolstra
Copy link
Member

I'm hesitant to modify the semantics of nix-env since it's kinda legacy at this point. The replacement (nix profile) does not use the (p)name/version attributes at all.

@jtojnar
Copy link
Contributor Author

jtojnar commented Jan 18, 2021

We still use nix-env output for packages.json which ends up being picked up by Repology. And these keys were only added recently specifically for use on Repology.

@stale
Copy link

stale bot commented Oct 30, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Oct 30, 2021
@r-burns
Copy link
Contributor

r-burns commented Nov 9, 2021

Still relevant

@superherointj
Copy link

superherointj commented Apr 21, 2022

@edolstra

In case this PR is not accepted (which seems so?), a replacement is needed here:
https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/make-tarball.nix#L67

How to use nix profile to replace nix-env for this use case?

With nix-env I'd list packages this way:
nix-env --query --available --meta --json

What would be the equivalent using nix profile?
nix profile list won't list it.

Maybe nix search would be better here but then (1) version is broken as well (2) doesn't provide all of meta information. #3868

image

Previously[1], we started including `pname` and `version` keys
in `nix-env -qa --json` output (and thus in packages.json).

But those values were obtained using parseDrvName, which
does not work in many cases, for example when a project
does not follow Nix’s arbitrary requirement that version names
have to start with a digit.

The keys are also misleading as many modern Nixpkgs packages
pass identically named attributes to mkDerivation but these
keys do not use those values.

Let’s fix this discrepancy by officially recognizing `pname` and
`version` attributes as special and using them in the JSON
output.

This will be useful for Repology as well.

[1]: NixOS@cd933b2
@jtojnar jtojnar force-pushed the nix-env-pname-version-attrs branch from 9b0232a to 60d6edf Compare April 21, 2022 13:21
@fricklerhandwerk fricklerhandwerk added the UX The way in which users interact with Nix. Higher level than UI. label Sep 9, 2022
@Ericson2314
Copy link
Member

Ericson2314 commented Mar 11, 2023

It might be prudent to generate the repology info in a way that is agnostic to nix-env and nix profile. That helps with Nix vs Nixpkgs layering.

@Ericson2314 Ericson2314 added the cli The old and/or new command line interface label Mar 11, 2023
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nixpkgs-cli-working-group/30517/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli The old and/or new command line interface UX The way in which users interact with Nix. Higher level than UI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants