Skip to content

stdenv: PURL fetcher introduction#454333

Open
h0nIg wants to merge 2 commits intoNixOS:masterfrom
h0nIg:purl-featureflag
Open

stdenv: PURL fetcher introduction#454333
h0nIg wants to merge 2 commits intoNixOS:masterfrom
h0nIg:purl-featureflag

Conversation

@h0nIg
Copy link
Copy Markdown
Contributor

@h0nIg h0nIg commented Oct 21, 2025

#421125 was merged and reverted later, because of regressions.

the background is described here: #421125 (comment)

@wolfgangwalther outlined the conditions and would like to enhance CI - over time. This is a continuous approach, which is in line with packages which have been found to be defunct and which need a fix. There may be more packages which have problems and we would like to prevent further fallout by a feature flag (prevents accessing + inheritance of drv.src / drv.srcs).

packages list: #453322 (comment)
list of real broken packages: #453322 (comment)
broken packages fix (deferrable PR: #457769)

With the old PR + the broken&platform check fix from #453291 + the feature flag, we enable maintainers to gather experience with PURL and set appropriate information (e.g. jq example, where fetchurl is used instead of fetchFromGithub)

nix-repl> xx = (import /my/nixpkgs {config={derivationPURLInheritance = true;};})
nix-repl> xx.python3Packages.boto3.meta.identifiers
{
  cpeParts = { ... };
  possibleCPEs = [ ... ];
  purl = "pkg:github/boto/boto3@1.40.18";
  purlParts = { ... };
  purls = [ ... ];
  v1 = { ... };
}

nix-repl> xx = (import /my/nixpkgs {})
nix-repl> xx.python3Packages.boto3.meta.identifiers
{
  cpeParts = { ... };
  possibleCPEs = [ ... ];
  purlParts = { ... };
  purls = [ ... ];
  v1 = { ... };
}

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@h0nIg h0nIg mentioned this pull request Oct 21, 2025
13 tasks
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 8.has: changelog This PR adds or changes release notes 6.topic: ruby A dynamic, open source programming language with a focus on simplicity and productivity. 6.topic: fetch Fetchers (e.g. fetchgit, fetchsvn, ...) 6.topic: stdenv Standard environment 8.has: documentation This PR adds or changes documentation labels Oct 21, 2025
@h0nIg
Copy link
Copy Markdown
Contributor Author

h0nIg commented Oct 21, 2025

we need to squash all commits later, just for transparency let's keep the commits separated in order to understand what has been changed.

@h0nIg h0nIg marked this pull request as ready for review October 21, 2025 21:04
@h0nIg h0nIg marked this pull request as draft October 21, 2025 21:04
@h0nIg h0nIg marked this pull request as ready for review October 21, 2025 21:14
@raboof
Copy link
Copy Markdown
Member

raboof commented Mar 3, 2026

i demonstrated which data can get extracted with this patch some time ago: #421125 (comment)

Thank you, it's very helpful to have a concrete example to talk about.

As you know (but repeating for new readers), the main current use case for purls is SBOMs, and there are two general techniques for extracting the dependency relationships from nix trees: evaluating the the nix sources 'in nix', and parsing the drvs from the nix store. Both have their downsides: evaluating 'in nix' currently makes some subtrees unreachable due to NixOS/nix#4677 , while parsing drv files misses useful information from the meta fields until something like #420575 or #466932 would happen.

AFAICT "the jury is still out" on which approach we will land on. Until that time, I think we should not yet merge this PR as-is, as its complex/controversial bits (the propagation between meta and src.meta) only seem useful/necessary for the 'in nix' approach. If we'd land on the drv parsing approach, this propagation is not necessary: I made a small PoC showing that at https://codeberg.org/raboof/nix-build-sbom/src/branch/purl-experiment . Of course that PoC is horrible for several reasons, I'm definitely not suggesting anyone should use that directly, but it does show there are approaches where it's possible to derive purls without having the meta propagation - so it might be premature to introduce it.

The introduction of meta.identifiers.purl/meta.identifiers.purls/drv.src.meta.identifiers.v1.purl(s) in this PR seems more directly useful: for example, for python312Packages.pixelmatch we currently infer something like pkg:generic/pixelmatch-py?vcs_url=https://github.com/whtsky/pixelmatch-py.git@v0.3.0 or pkg:github/whtsky/pixelmatch-py@v0.3.0 as purl, while in fact pkgs:pypi/pixelmatch:0.3.0 would be more accurate. I don't think that information can currently be reasonably inferred, and IMHO it would be great if we could encode that knowledge in meta. This would benefit us immediately for nix-eval-based construction of SBOMs, and also for drv-based construction once we land on a way to expose meta to such tools.

(I have not digested the design decisions of that part of this PR, but it seems to me it might help to discuss those changes in isolation in their own PR, which we might be able to merge more quickly?)

@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Mar 8, 2026
@h0nIg h0nIg force-pushed the purl-featureflag branch 4 times, most recently from 5528902 to 097b483 Compare March 8, 2026 21:28
@nixpkgs-ci nixpkgs-ci bot requested review from a team and infinisil March 8, 2026 21:34
@h0nIg h0nIg force-pushed the purl-featureflag branch 2 times, most recently from ca4dc6c to fed1a8d Compare March 8, 2026 21:47
@h0nIg
Copy link
Copy Markdown
Contributor Author

h0nIg commented Mar 8, 2026

(I have not digested the design decisions of that part of this PR, but it seems to me it might help to discuss those changes in isolation in their own PR, which we might be able to merge more quickly?)

as agreed in our call together with @raboof, i removed the inheritance and its feature flag

@h0nIg h0nIg changed the title stdenv: PURL fetcher introduction & feature flag stdenv: PURL fetcher introduction Mar 8, 2026
@raboof
Copy link
Copy Markdown
Member

raboof commented Mar 24, 2026

Since the transition to Github Actions we no longer have a CI which performs those checks so this needs to be done manually.

You can see the performance report in the PR summary page: https://github.com/NixOS/nixpkgs/actions/runs/18756048808?pr=454333#summary-53508514968

@wolfgangwalther that link is now dead. This PR was significantly simplified since - would it be possible to do another performance check? How would one do that?

@wolfgangwalther
Copy link
Copy Markdown
Contributor

would it be possible to do another performance check? How would one do that?

The performance data is available in every CI run. Just click your way to the details page of the CI jobs listed at the bottom of the PR and scroll your way through.

@raboof
Copy link
Copy Markdown
Member

raboof commented Mar 24, 2026

would it be possible to do another performance check? How would one do that?

The performance data is available in every CI run. Just click your way to the details page of the CI jobs listed at the bottom of the PR and scroll your way through.

Gotcha, for the 'Eval Summary' job, so https://github.com/NixOS/nixpkgs/actions/runs/22830597798?pr=454333 - so no noticeable change in speed, and a size increase of 0.05%-0.3%.

@h0nIg h0nIg force-pushed the purl-featureflag branch from fed1a8d to cd3ff71 Compare March 24, 2026 12:32
@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Mar 24, 2026
@h0nIg h0nIg force-pushed the purl-featureflag branch from cd3ff71 to 3c32661 Compare March 24, 2026 13:01
Copy link
Copy Markdown
Member

@raboof raboof left a comment

Choose a reason for hiding this comment

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

Starting to look attractive! Some comments here and there.


### Package URL {#sec-meta-identifiers-purl}

[Package-URL](https://github.com/package-url/purl-spec) (PURL) is a specification to reliably identify and locate software packages. Through identification of software packages, additional (non-major) use cases are e.g. software license cross-verification via third party databases or initial vulnerability response management. Package URL's shall default to the mkDerivation.src, as the original consumed software package is the single point of truth.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"Package URL's shall default to the mkDerivation.src" is no longer true 'in nixpkgs', but consuming tools are expected to make this association (at least for now). That seems like a good start to me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

src or srcs is implementation specific, the tool outside should not try to guess which one is the right approach. The interface is drv.meta.identifiers.purl and the implementation (the drv) should define the "where to search". I would like to keep this

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am in agreement that we shouldn't push tools to trying to guess. Especially with tools that try to be efficient and can parallelize things, it makes the concurrency more difficult. Imo, it would be great if drv.meta.identifiers.purl defaults to drv.src.meta.identifiers.purl. I know people would be concerned with eval performance.

This attribute contains an attribute set of all parts of the PURL for this package.

* `type` mandatory [type](https://github.com/package-url/purl-spec/blob/18fd3e395dda53c00bc8b11fe481666dc7b3807a/docs/standard/summary.md) which needs to be provided
* `spec` specify the PURL in accordance with the [purl-spec](https://github.com/package-url/purl-spec/blob/18fd3e395dda53c00bc8b11fe481666dc7b3807a/purl-specification.md)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why is this field named 'spec'? what's the motivation for splitting the 'type' and the rest of the purl like this, over 'just' having a purl string? Are you expecting more fields in the future?

Copy link
Copy Markdown

@yyovil yyovil Mar 24, 2026

Choose a reason for hiding this comment

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

what if all the PURL components are defined as attrs here? except the schema being a constant "pkg".

Copy link
Copy Markdown
Contributor Author

@h0nIg h0nIg Mar 24, 2026

Choose a reason for hiding this comment

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

i splitted them to give it a thin structure overall

spec is the implementation of the definition schema: https://github.com/package-url/purl-spec/tree/18fd3e395dda53c00bc8b11fe481666dc7b3807a/types

@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Mar 24, 2026
@h0nIg h0nIg force-pushed the purl-featureflag branch from 3c32661 to c458b18 Compare March 25, 2026 16:35
@h0nIg h0nIg force-pushed the purl-featureflag branch from 0caddcd to c6035ec Compare March 25, 2026 16:37
@h0nIg h0nIg requested review from Eveeifyeve and raboof March 25, 2026 16:39
Copy link
Copy Markdown
Member

@Eveeifyeve Eveeifyeve left a comment

Choose a reason for hiding this comment

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

This looks to good to me, however I would like to see the purl parts be automatically defined by fetchers as well in a followup.

@oneingan oneingan requested review from oneingan and removed request for oneingan March 31, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: wait for branch‐off Waiting for the next Nixpkgs branch‐off 6.topic: fetch Fetchers (e.g. fetchgit, fetchsvn, ...) 6.topic: ruby A dynamic, open source programming language with a focus on simplicity and productivity. 6.topic: stdenv Standard environment 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 3+ This PR was reviewed and approved by three or more persons.

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.