Skip to content

Replace nix-env metadata scanning with targeted metadata lookup#294

Merged
henrirosten merged 7 commits into
mainfrom
sbomnix-package-root-metadata
May 25, 2026
Merged

Replace nix-env metadata scanning with targeted metadata lookup#294
henrirosten merged 7 commits into
mainfrom
sbomnix-package-root-metadata

Conversation

@henrirosten

@henrirosten henrirosten commented May 19, 2026

Copy link
Copy Markdown
Collaborator

Replace sbomnix’s old nixpkgs metadata path, which relied on a broad nix-env -qa --meta --json style scan, with targeted package metadata lookup.

The new path evaluates compact lookup requests against the relevant package roots and only accepts metadata when the returned derivation/output path matches an SBOM component exactly.

This also removes the legacy nixmeta CLI and its tests, since metadata lookup is now an internal sbomnix implementation detail.

Why?

The old nix-env-based scan was hacky, joined metadata too opportunistically by package name+version, and was slow on cold cache. The new approach is faster, more target-aware, and avoids ambiguous/questionable metadata matches.

Notes

This is an intentional behavior change: broad/opportunistic metadata coverage is lower than earlier because sbomnix no longer scans all nixpkgs metadata and avoids questionable metadata matches.

Fixes: #150

@henrirosten henrirosten force-pushed the sbomnix-package-root-metadata branch from cdc2a4e to 8a86569 Compare May 19, 2026 08:30
@henrirosten henrirosten changed the title Sbomnix package root metadata Replace nix-env metadata scanning with targeted metadata lookup May 19, 2026
@henrirosten henrirosten force-pushed the sbomnix-package-root-metadata branch 2 times, most recently from 3626d8a to 13757f3 Compare May 19, 2026 13:49
@henrirosten henrirosten marked this pull request as ready for review May 19, 2026 14:16
@henrirosten henrirosten requested a review from a team May 19, 2026 14:16
Signed-off-by: Henri Rosten <henri.rosten@unikie.com>
Move flake metadata resolution helpers into sbomnix so the SBOM
metadata pipeline no longer depends on the nixmeta package.

The helper also centralizes local flake reference normalization for
current-flake shorthand and path-based flake references.

Signed-off-by: Henri Rosten <henri.rosten@unikie.com>
Add the Python and Nix helpers used to evaluate package metadata
from package roots and flake package outputs.

The lookup request stays compact and the result includes derivation
and output identities so callers can reject metadata that does not
belong to an SBOM component.

Signed-off-by: Henri Rosten <henri.rosten@unikie.com>
Replace the old name-based nixpkgs metadata join with an exact
component identity match against derivation and output paths.

Cache package-root scans by stable source identity and lookup set,
and scan flake input package roots only for components left
unmatched by the primary source.

Signed-off-by: Henri Rosten <henri.rosten@unikie.com>
Drop --meta-nixpkgs now that metadata enrichment is derived from
the flakeref target and its package roots.

Store-path targets still skip metadata because they do not identify
the nixpkgs source that produced the path; users should use a
flakeref target when metadata is required.

Signed-off-by: Henri Rosten <henri.rosten@unikie.com>
Remove the standalone nixmeta command, its nix packaging entries,
documentation, and tests.

sbomnix now uses its own targeted package metadata resolver instead
of the legacy nix-env metadata scanner, so the CLI is no longer
part of the public tool set.

Signed-off-by: Henri Rosten <henri.rosten@unikie.com>
Signed-off-by: Henri Rosten <henri.rosten@unikie.com>
@henrirosten henrirosten force-pushed the sbomnix-package-root-metadata branch from 13757f3 to d831180 Compare May 20, 2026 11:03
@henrirosten henrirosten merged commit 5854c12 into main May 25, 2026
6 checks passed
@henrirosten henrirosten mentioned this pull request May 25, 2026
@henrirosten henrirosten deleted the sbomnix-package-root-metadata branch May 25, 2026 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Most Haskell packages fail to have their license information extracted

1 participant