Many dependencies of clan-cli are currently dynamically loaded via nix-shell on each execution. This is nice, as it reduces the initial closure size of clan, but the overhead introduced by nix-shell piles up quickly, as some commands shell out many times during their lifetime. For example, when adding a secret git is called 10+ times. This reduces the time of a test which adds a secret from around 50 seconds to 15 seconds. - add run_cmd() as an alternative to nix_shell() - introduce the concept of static dependencies which do not need to go through nix-shell - static dependencies are defined at build time and included into the wrapper for clan-cli - add package: clan-cli-full which statically ships all required dependencies TODO: deprecate nix_shell() in favor of run_cmd()
50 lines
937 B
Nix
50 lines
937 B
Nix
{
|
|
lib,
|
|
nix-unit,
|
|
clan-cli,
|
|
clan-cli-full,
|
|
mkShell,
|
|
ruff,
|
|
python3,
|
|
self',
|
|
}:
|
|
let
|
|
devshellTestDeps =
|
|
clan-cli.passthru.testDependencies
|
|
++ (with python3.pkgs; [
|
|
rope
|
|
setuptools
|
|
wheel
|
|
ipdb
|
|
pip
|
|
]);
|
|
in
|
|
mkShell {
|
|
buildInputs = [
|
|
nix-unit
|
|
ruff
|
|
] ++ devshellTestDeps;
|
|
|
|
inputsFrom = [ self'.devShells.default ];
|
|
|
|
PYTHONBREAKPOINT = "ipdb.set_trace";
|
|
|
|
CLAN_STATIC_PROGRAMS = lib.concatStringsSep ":" (
|
|
lib.attrNames clan-cli-full.passthru.runtimeDependenciesAsSet
|
|
);
|
|
|
|
shellHook = ''
|
|
export GIT_ROOT="$(git rev-parse --show-toplevel)"
|
|
export PKG_ROOT="$GIT_ROOT/pkgs/clan-cli"
|
|
|
|
# Add current package to PYTHONPATH
|
|
export PYTHONPATH="$PKG_ROOT''${PYTHONPATH:+:$PYTHONPATH:}"
|
|
|
|
# Add clan command to PATH
|
|
export PATH="$PKG_ROOT/bin":"$PATH"
|
|
|
|
# Needed for impure tests
|
|
ln -sfT ${clan-cli.nixpkgs} "$PKG_ROOT/clan_cli/nixpkgs"
|
|
'';
|
|
}
|