From a2648f2afb35adc2f4df6a06b6399c93d3320f93 Mon Sep 17 00:00:00 2001 From: DavHau Date: Wed, 9 Aug 2023 18:38:44 +0200 Subject: [PATCH] clan-cli: prepare source in extra derivation Towards not rebuilding clan-cli on each commit --- pkgs/clan-cli/default.nix | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/pkgs/clan-cli/default.nix b/pkgs/clan-cli/default.nix index d590bc77e..9dc255be5 100644 --- a/pkgs/clan-cli/default.nix +++ b/pkgs/clan-cli/default.nix @@ -29,10 +29,19 @@ let ]; checkPython = python3.withPackages (_ps: dependencies ++ testDependencies); + + # - vendor the jsonschema nix lib (copy instead of symlink). + # - lib.cleanSource prevents unnecessary rebuilds when `self` changes. + source = runCommand "clan-cli-source" { } '' + cp -r ${lib.cleanSource ./.} $out + chmod -R +w $out + rm $out/clan_cli/config/jsonschema + cp -r ${lib.cleanSource (self + /lib/jsonschema)} $out/clan_cli/config/jsonschema + ''; in python3.pkgs.buildPythonPackage { name = "clan-cli"; - src = lib.cleanSource ./.; + src = source; format = "pyproject"; nativeBuildInputs = [ setuptools @@ -40,16 +49,11 @@ python3.pkgs.buildPythonPackage { ]; propagatedBuildInputs = dependencies; - preBuild = '' - rm ./clan_cli/config/jsonschema - cp -r ${self}/lib/jsonschema ./clan_cli/config/jsonschema - ''; - passthru.tests = { clan-mypy = runCommand "clan-mypy" { } '' - cp -r ${self} ./flake - chmod +w -R ./flake - cd ./flake/pkgs/clan-cli + cp -r ${source} ./src + chmod +w -R ./src + cd ./src ${checkPython}/bin/mypy . touch $out ''; @@ -57,9 +61,9 @@ python3.pkgs.buildPythonPackage { { nativeBuildInputs = [ age zerotierone bubblewrap sops nix ]; } '' - cp -r ${self} ./flake - chmod +w -R ./flake - cd ./flake/pkgs/clan-cli + cp -r ${source} ./src + chmod +w -R ./src + cd ./src ${checkPython}/bin/python -m pytest ./tests touch $out '';