nixpkgs/pkgs/by-name/fl/flattenReferencesGraph/dev-shell.nix
Adrian Gierakowski 5b4a8db4d9 build-support/docker: customisable layering strategy
Allow customisation of the algorithm used to convert nix references
graph (created from docker image contents) to docker layers.

A collection of building blocks (python functions) is provided, which
use can assembled into a processing pipeline by specifying a list of
operations (and their initial arguments) via a nix list.

Nix references graph if first converted into a python igraph.Graph
object (with each vertex representing a nix path), which is then fed
into the user defined pipeline. Each stage in the pipeline represents a
function call, with initial arguments specified by the user in nix, and
the last argument being the result of the previous stage in the pipeline
(or the initial Graph object). Each step of the pipeline is expected to
produce a data structure consisting of arbitrarily  nested lists/dicts
with Graph objects (representing docker layers) at it's leafs. The
result of the last stage in the pipeline is recursively flattened (with
each dict converted into list of values), until a flat list of Graphs
remains. This is then output as a json array of arrays (each Graph
converted into an array of paths).

This functionality is made available via new `layeringPipeline` argument
to the `streamLayeredImage`/`buildLayeredImage` functions. The default
value of the argument has been chosen to to preserve current layering
behaviour.

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
2024-11-09 16:21:48 +00:00

55 lines
1.7 KiB
Nix

# Start this shell with:
# nix-shell path/to/root/of/nixpkgs -A flattenReferencesGraph.dev-shell
{
mkShell,
callPackage,
python3Packages,
}:
let
helpers = callPackage (import ./helpers.nix) { };
in
mkShell {
inputsFrom = [ (callPackage (import ./package.nix) { }) ];
buildInputs = [
helpers.format
helpers.lint
helpers.unittest
# This is needed to plot graphs when DEBUG_PLOT is set to True.
python3Packages.pycairo
# This can be used on linux to display the graphs.
# On other platforms the image viewer needs to be set with
# DEBUG_PLOT_IMAGE_VIEWER env var.
# pkgs.gwenview
];
shellHook = ''
echo '
**********************************************************************
**********************************************************************
Commands useful for development (should be executed from scr dir):
format
* formats all files in place using autopep8
lint
* lints all files using flake8
unittest
* runs all unit tests
following env vars can be set to enable extra output in tests:
- DEBUG=True - enable debug logging
- DEBUG_PLOT=True - plot graphs processed by split_paths.py and
subcomponent.py
- DEBUG_PLOT_IMAGE_VIEWER=$PATH_OF_IMAGE_VIEWER_APP - app used to
display plots (default: gwenview)
- DEBUG_PLOT_SAVE_BASE_NAME=$SOME_NAME - if set, plots will be saved
to files instead of displayed with image viewer
**********************************************************************
**********************************************************************
'
'';
}