2023-08-03 11:07:00 +00:00
|
|
|
{ lib
|
2023-07-26 06:29:34 +00:00
|
|
|
, python3
|
|
|
|
, ruff
|
|
|
|
, runCommand
|
|
|
|
, installShellFiles
|
|
|
|
, zerotierone
|
|
|
|
, bubblewrap
|
2023-07-26 13:21:57 +00:00
|
|
|
, sops
|
|
|
|
, age
|
2023-08-03 11:07:00 +00:00
|
|
|
, black
|
|
|
|
, nix
|
|
|
|
, mypy
|
|
|
|
, setuptools
|
2023-07-26 07:27:48 +00:00
|
|
|
, self
|
2023-08-03 11:07:00 +00:00
|
|
|
, argcomplete
|
|
|
|
, pytest
|
|
|
|
, pytest-cov
|
|
|
|
, pytest-subprocess
|
|
|
|
, wheel
|
2023-07-20 23:08:11 +00:00
|
|
|
}:
|
|
|
|
let
|
2023-08-03 11:07:00 +00:00
|
|
|
dependencies = [ argcomplete ];
|
2023-07-20 16:07:27 +00:00
|
|
|
|
2023-08-03 11:07:00 +00:00
|
|
|
testDependencies = [
|
|
|
|
pytest
|
|
|
|
pytest-cov
|
|
|
|
pytest-subprocess
|
|
|
|
mypy
|
|
|
|
];
|
2023-07-25 11:46:58 +00:00
|
|
|
|
2023-08-03 11:07:00 +00:00
|
|
|
checkPython = python3.withPackages (_ps: dependencies ++ testDependencies);
|
|
|
|
in
|
|
|
|
python3.pkgs.buildPythonPackage {
|
2023-08-08 12:20:45 +00:00
|
|
|
name = "clan-cli";
|
2023-08-03 11:07:00 +00:00
|
|
|
src = lib.cleanSource ./.;
|
|
|
|
format = "pyproject";
|
|
|
|
nativeBuildInputs = [
|
|
|
|
setuptools
|
|
|
|
installShellFiles
|
|
|
|
];
|
|
|
|
propagatedBuildInputs = dependencies;
|
2023-07-25 11:46:58 +00:00
|
|
|
|
2023-08-09 15:59:07 +00:00
|
|
|
preBuild = ''
|
|
|
|
rm ./clan_cli/config/jsonschema
|
|
|
|
cp -r ${self}/lib/jsonschema ./clan_cli/config/jsonschema
|
|
|
|
'';
|
|
|
|
|
2023-08-03 11:07:00 +00:00
|
|
|
passthru.tests = {
|
|
|
|
clan-mypy = runCommand "clan-mypy" { } ''
|
2023-08-09 15:59:07 +00:00
|
|
|
cp -r ${self} ./flake
|
|
|
|
chmod +w -R ./flake
|
|
|
|
cd ./flake/pkgs/clan-cli
|
2023-08-03 11:07:00 +00:00
|
|
|
${checkPython}/bin/mypy .
|
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
clan-pytest = runCommand "clan-tests"
|
|
|
|
{
|
|
|
|
nativeBuildInputs = [ age zerotierone bubblewrap sops nix ];
|
|
|
|
} ''
|
2023-08-09 15:59:07 +00:00
|
|
|
cp -r ${self} ./flake
|
|
|
|
chmod +w -R ./flake
|
|
|
|
cd ./flake/pkgs/clan-cli
|
2023-08-03 11:07:00 +00:00
|
|
|
${checkPython}/bin/python -m pytest ./tests
|
|
|
|
touch $out
|
2023-07-20 23:08:11 +00:00
|
|
|
'';
|
2023-07-20 16:07:27 +00:00
|
|
|
};
|
|
|
|
|
2023-08-03 11:07:00 +00:00
|
|
|
passthru.devDependencies = [
|
|
|
|
ruff
|
|
|
|
black
|
|
|
|
setuptools
|
|
|
|
wheel
|
|
|
|
] ++ testDependencies;
|
2023-07-20 16:07:27 +00:00
|
|
|
|
2023-08-03 11:07:00 +00:00
|
|
|
makeWrapperArgs = [
|
|
|
|
"--set CLAN_FLAKE ${self}"
|
|
|
|
];
|
2023-07-21 11:31:13 +00:00
|
|
|
|
2023-08-03 11:07:00 +00:00
|
|
|
postInstall = ''
|
|
|
|
installShellCompletion --bash --name clan \
|
|
|
|
<(${argcomplete}/bin/register-python-argcomplete --shell bash clan)
|
|
|
|
installShellCompletion --fish --name clan.fish \
|
|
|
|
<(${argcomplete}/bin/register-python-argcomplete --shell fish clan)
|
2023-07-20 16:07:27 +00:00
|
|
|
'';
|
2023-08-03 13:33:08 +00:00
|
|
|
checkPhase = ''
|
|
|
|
PYTHONPATH= $out/bin/clan --help
|
2023-08-09 08:36:46 +00:00
|
|
|
if grep --include \*.py -Rq "breakpoint()" $out; then
|
2023-08-09 08:21:59 +00:00
|
|
|
echo "breakpoint() found in $out:"
|
|
|
|
grep --include \*.py -Rn "breakpoint()" $out
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-08-03 13:33:08 +00:00
|
|
|
'';
|
2023-08-03 11:07:00 +00:00
|
|
|
meta.mainProgram = "clan";
|
|
|
|
}
|