tiiuae / sbomnix

A suite of utilities to help with software supply chain challenges on nix targets
125 stars 22 forks source link

bring in python devshell with Nix #94

Closed flokli closed 10 months ago

flokli commented 10 months ago

This drops a python.withPackages (…) with the devshell, and reconfigures pytest to add . to PYTHONPATH.

This removes the additional pip install run whenever the shell is entered, so all targets and scripts related to managing that can be removed.

pytest now uses that python for all third-party python dependencies - which required exposing pyrate-limiter and requests-limiter.

Some of the tests were previously "integration-testing the flake outputs", introducing additional complexity and another nix eval - we run the tests inside the dev environment, so there's no need to do that.

If we really want to test the flake outputs still work, it could be a separate "smoketest" (maybe just inside GH actions). pytest should not execute Nix (at least where we can avoid it, which is bringing in the environment we already have).


Changing to this approach exposed some smell - the entrypoints are not really thin entrypoints, rely on and execute other binaries in $PATH, too.

Some of this code should probably be moved to some library code, most pressingly, vulnxscan should not invoke repology_cli (which is another entrypoint), but instead repology-related code should be moved into a lib that can be used by both consumers.

For now, I disabled these three (now failing) pytest tests. In nix-based builds, this doesn't matter and will still work, as we ship all entrypoints in a single $out/bin.

--

Long-term, we might want to decouple the "CLI parsing from process args and preparing result for presentation" part from the actually code that run. (Ideally by moving the "main logic" into lib code too).

Rather than starting another python interpreter and passing CLI args, we could then really test the individual primitives, which should allow more fine-grained testing than just "integration-testing" the whole CLI, which is what we do now.