Hi all! I am excited to share somthing I have been working on internally at Tweag with a few others!
Our goal is to provide a simple solution to extract the dependency graph from any Nix code base (though for now it can only extract from flakes) of all the software packaged. The long term goal is to start building an ecosystem of tools to help operationalize Nix-based packaging.
Exciting ideas from the top of my head:
build a database of all the things ever packaged on nixpkgs
combine with a Nix binary cache to store the closure size of every derivation
combine with a vulnerability database
combine with nix-index to know automatically the proper derivation to get a file
To read more about it:
The current implementation may not be ideal, there will be bugs, but all that will improve as we go. At least that’s how I see things
I immediately went to try using it with nix run- only to find it’s not packaged as a flake. I sort of assumed a flake utility would be packaged as one.
I still hope an effort is made to make this stuff integrate with GitHub - nikstur/bombon: Nix CycloneDX Software Bills of Materials (SBOMs) given that is already there and works quite well. Has it been on Tweag’s radar? It’d be a real shame if two groups of people are developing the exact same thing without any coordination.
As Solène said above, we knew about Bombon before starting Nixtract.
The two project share many similarities, yet as far as I understand they have major differences:
bombon focuses on CycloneDX generation, nixtract aims to be pluggable into many use cases
bombon makes the SBOM for a derivation, nixtract works on a whole flake (it’d be possible to make it more versatile)
bombon builds the SBOM at once, nixtract streams information
bombon builds the closure inside Nix evaluation through recursion, nixtract uses two steps and spawns many small Nix interpreters to limit memory usage
Of course one can take inspiration from the other!
That’s a great point! nix-eval-jobs is very similar. It describes Nix derivations and outputs a JSONL stream. It is even a few steps ahead of nixtract on some technical aspects (commanding the evaluation directly with C++ instead of spawning Nix processes).
Funny thing is, I learned about it quite late after the first working implementation of nixtract, so it is quite interesting to see how the design of nixtract converged in many ways to that of nix-eval-jobs.
To my understanding though, nix-eval-jobs does not recurse into the inputs of the derivation to describe the whole graph of dependencies, which nixtract does (and which introduces some technical challenges).
So they are not quite the same, but they do have many things in common, and I keep that in mind for future development.
There is a --force-recurse option as well, but i you already got some code that can recurse maybe that could be combined somehow. Do you have numbers for peak memory usage? Looking at ofborg if you don’t restart evaluation that could be quite high or can you split evaluation?
This does not display anything for pkg1.
So I still think nixtract does something that nix-eval-jobs does not (yet?).
However it should be possible to improve nixtract using ideas from nix-eval-jobs, especially for performances (nixtract takes a few hours to extract data from the entire nixpkgs).