Repository navigation
Pipeline for Nix - #2209
Pipeline for Nix#2209chinyeungli wants to merge 195 commits into
Conversation
- Get the input and extract content into the from/ codebase. - Build the source and place the built files into the to/ codebase. - Run scans. - Identify sources in from/ that are used in the build. Signed-off-by: Chin Yeung Li <tli@nexb.com>
…ses detected in the codebase #1767 * Introduce new "LICENSE_ISSUE" tag * License deduplication/simplification is not working well; work in progress Signed-off-by: Chin Yeung Li <tli@nexb.com>
This commit is for testing purpose and is definitely not ready. Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: tdruez <tdruez@aboutcode.org>
Signed-off-by: tdruez <tdruez@aboutcode.org>
Signed-off-by: tdruez <tdruez@aboutcode.org>
Signed-off-by: tdruez <tdruez@aboutcode.org>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
* Use Docker for building instead of Cargo * Accept only one PURL as input * Use the .rlib found in .d files for D2D mapping * Remove unnecessary code Signed-off-by: Chin Yeung Li <tli@nexb.com>
* Add comparison logic * Add tests * Update extra_data fields * Better code organization * etc.. Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: tdruez <tdruez@aboutcode.org>
Signed-off-by: tdruez <tdruez@aboutcode.org>
Signed-off-by: tdruez <tdruez@aboutcode.org>
…2101) Signed-off-by: tdruez <tdruez@aboutcode.org>
Signed-off-by: Rishabh Rohil <rishabhrohil024@gmail.com>
Signed-off-by: Rishabh Rohil <rishabhrohil024@gmail.com>
…2102) Signed-off-by: tdruez <tdruez@aboutcode.org>
Signed-off-by: tdruez <tdruez@aboutcode.org>
…#2106) Signed-off-by: tdruez <tdruez@aboutcode.org>
Signed-off-by: tdruez <tdruez@aboutcode.org>
…2124) Signed-off-by: tdruez <tdruez@aboutcode.org>
Signed-off-by: tdruez <tdruez@aboutcode.org>
Signed-off-by: tdruez <tdruez@aboutcode.org>
Signed-off-by: OmAnand857 <allansmith2561@gmail.com>
Signed-off-by: tdruez <tdruez@aboutcode.org>
Signed-off-by: Aayush Kumar <code@aayushk.dev>
Signed-off-by: tdruez <tdruez@aboutcode.org>
Signed-off-by: tdruez <tdruez@aboutcode.org>
Signed-off-by: tdruez <tdruez@aboutcode.org>
Signed-off-by: Chin Yeung Li <tli@nexb.com> Signed-off-by: Chin Yeung <tli@nexb.com> Co-authored-by: tdruez <489057+tdruez@users.noreply.github.com>
Signed-off-by: Stefan Fleckenstein <stefan@fleckenstein.co.uk>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
…d NIXPKGS_TRUSTED_BRANCHES #1938 Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung <tli@nexb.com>
…1938 Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
tdruez
left a comment
There was a problem hiding this comment.
@chinyeungli No need for a new PR: since you merged main, the "Files changed" tab only shows the 26 files of this PR, and there is no conflict.
Most of the previous points are addressed, see my new comments.
I'd prefer to keep them in
utils.pyrather than move them tonix.py, because other pipelines (e.g. Rust) are likely to need the same "run a build in a container" pattern.
Then let's name the module after what it does, pipes/container.py for example. A generic utils.py ends up collecting unrelated helpers.
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
…ure #1938 Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
…1938 Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
…smatch() without lambda #1938 Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
Signed-off-by: Chin Yeung Li <tli@nexb.com>
tdruez
left a comment
There was a problem hiding this comment.
@chinyeungli Let's take a step back on this PR. It has grown too big for a single pipeline, and I should have raised it earlier instead of reviewing it line by line.
To run one pipeline, the PR currently adds:
- An opt-in privileged Docker-in-Docker service in
docker-compose.yml, with TLS certificates and an extra service to fix their permissions. - The Docker CLI in every ScanCode.io image, new Makefile targets, and changes in
docker.env. - 5 new settings.
- A local clone of nixpkgs, file locks, and a Nix store garbage collection run by the pipeline.
- Local builds of the binary when it is not available in the Nix binary cache.
- A new
DiscoveredPackagefield and a migration, for a check only this pipeline uses.
This is overkill for a pipeline that few users will run. It makes the whole stack heavier for everyone, and it's a lot of code to maintain in the long run.
Part of this work will be reused (PURL validation, metadata retrieval, D2D, tests). But rather than adding more rounds on this branch, I'd keep it open for reference and restart with a smaller, clean PR.
Before writing code, let's agree on the plan in #1938. There is no defined approach there yet, only the initial scenario. A first version could be:
- Input: a nix PURL.
- Download the binary from the Nix binary cache, and the source. No local build.
- Run D2D between them, scan the source, and compare the detected licenses with the declared license.
Questions to answer first:
- Do we need Docker at all, or can the pipeline call
nixdirectly? - Is a local nixpkgs clone needed for a first version?
- Which settings are really required?
- Where do we store the license check result without changing the data model?
The other points of the scenario (source repository check, MatchCode matching) can come later.


Issues
Changes
This PR creates a dedicated pipeline for Nix packages.
Requirements
Summary
Notes for deployment to development mapping
As Nix is not tied to a single programming language ecosystem, this pipeline executes all currently supported D2D steps across multiple languages.
Handling Missing Debug Symbols:
For

pkg:nix/nixpkgs/SDL_mixer@1.2.12?system=x86_64-linux, as seen in https://search.devbox.sh/v2/pkg?name=SDL_mixer , there is nodebugbuild found under the "outputs" section. Therefore, even the ELF binary is not stripped:there is no dwarf symbols collected and no development to deployment mapping can be performed
Template File Mapping (.in files):
For
pkg:nix/nixpkgs/openssl@3.6.0?out=debug&system=x86_64-linux, following are some of the dwarf symbols collected:However, these exact header files do not exist in the source codebase; they are generated from GNU Autoconf template files. To complete the mapping, the code has been updated to map to the corresponding .in template files:

Source-Only Scans:

For
pkg:nix/nixpkgs/haskellPackages.aasam@0.2.0.0?system=x86_64-linux&commit=a3ae4cdd64f675cf2580affecdee01c401b43638, this package does not exist on https://search.devbox.sh/, so no binary can be fetched, and the local Nix build fails because the package declares dependencies incompatible with the GHC version in this nixpkgs commit. The pipeline still fetches the patched source tree and runs the license scan; only the D2D mapping is skipped.:Design notes
nix-shell -pfetches the decompressors on every extraction, which hits the CDN's rate limit.nix-eval-cachevolume is pruned withnix-collect-garbage --delete-older-than 12h, at most once every 3 hours, so disk usage stays bounded.Notes
Because the pipeline relies on a Linux-based Docker container (nixos/nix) to build sources, providing a PURL for a non-Linux system (e.g., darwin) triggers a system barrier warning.
When this happens, the pipeline safely falls back to evaluating the source using the container's native Linux environment. The extracted source tree will contain Linux-specific patches rather than macOS patches. The impact on the d2d mapping is expected to be minimal, though a small number of files may remain unmapped due to missing OS-specific structural patches.
Also, there is no Nix Package detected until aboutcode-org/scancode-toolkit#2823 is resolved.
Checklist