2023-07-26 06:29:34 +00:00
|
|
|
{ pkgs
|
|
|
|
, lib
|
|
|
|
, python3
|
|
|
|
, ruff
|
|
|
|
, runCommand
|
|
|
|
, installShellFiles
|
|
|
|
, zerotierone
|
|
|
|
, bubblewrap
|
2023-07-26 13:21:57 +00:00
|
|
|
, sops
|
|
|
|
, age
|
2023-07-26 07:27:48 +00:00
|
|
|
, self
|
2023-07-20 23:08:11 +00:00
|
|
|
}:
|
|
|
|
let
|
2023-07-20 16:07:27 +00:00
|
|
|
pyproject = builtins.fromTOML (builtins.readFile ./pyproject.toml);
|
|
|
|
name = pyproject.project.name;
|
|
|
|
|
|
|
|
src = lib.cleanSource ./.;
|
|
|
|
|
|
|
|
dependencies = lib.attrValues {
|
2023-07-20 23:08:11 +00:00
|
|
|
inherit (python3.pkgs)
|
|
|
|
argcomplete
|
|
|
|
;
|
2023-07-20 16:07:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
devDependencies = lib.attrValues {
|
|
|
|
inherit (pkgs) ruff;
|
|
|
|
inherit (python3.pkgs)
|
|
|
|
black
|
|
|
|
mypy
|
|
|
|
pytest
|
|
|
|
pytest-cov
|
2023-07-21 00:01:39 +00:00
|
|
|
pytest-subprocess
|
2023-07-20 16:07:27 +00:00
|
|
|
setuptools
|
|
|
|
wheel
|
|
|
|
;
|
|
|
|
};
|
|
|
|
|
|
|
|
package = python3.pkgs.buildPythonPackage {
|
|
|
|
inherit name src;
|
|
|
|
format = "pyproject";
|
|
|
|
nativeBuildInputs = [
|
|
|
|
python3.pkgs.setuptools
|
2023-07-20 23:08:11 +00:00
|
|
|
installShellFiles
|
2023-07-20 16:07:27 +00:00
|
|
|
];
|
|
|
|
propagatedBuildInputs =
|
|
|
|
dependencies
|
|
|
|
++ [ ];
|
2023-07-25 16:54:26 +00:00
|
|
|
passthru.tests = { inherit clan-mypy clan-pytest; };
|
2023-07-20 16:07:27 +00:00
|
|
|
passthru.devDependencies = devDependencies;
|
2023-07-25 11:46:58 +00:00
|
|
|
|
|
|
|
makeWrapperArgs = [
|
2023-07-26 07:27:48 +00:00
|
|
|
"--set CLAN_FLAKE ${self}"
|
2023-07-25 11:46:58 +00:00
|
|
|
];
|
|
|
|
|
2023-07-20 23:08:11 +00:00
|
|
|
postInstall = ''
|
|
|
|
installShellCompletion --bash --name clan \
|
|
|
|
<(${python3.pkgs.argcomplete}/bin/register-python-argcomplete --shell bash clan)
|
|
|
|
installShellCompletion --fish --name clan.fish \
|
|
|
|
<(${python3.pkgs.argcomplete}/bin/register-python-argcomplete --shell fish clan)
|
|
|
|
'';
|
2023-07-24 14:49:32 +00:00
|
|
|
meta.mainProgram = "clan";
|
2023-07-20 16:07:27 +00:00
|
|
|
};
|
|
|
|
|
2023-07-21 09:23:10 +00:00
|
|
|
checkPython = python3.withPackages (_ps: devDependencies ++ dependencies);
|
2023-07-20 16:07:27 +00:00
|
|
|
|
2023-07-21 11:31:13 +00:00
|
|
|
clan-mypy = runCommand "${name}-mypy" { } ''
|
2023-07-20 16:07:27 +00:00
|
|
|
cp -r ${src} ./src
|
|
|
|
chmod +w -R ./src
|
|
|
|
cd src
|
|
|
|
${checkPython}/bin/mypy .
|
2023-07-21 11:31:13 +00:00
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
|
2023-07-25 11:46:58 +00:00
|
|
|
clan-pytest = runCommand "${name}-tests"
|
|
|
|
{
|
2023-07-26 13:21:57 +00:00
|
|
|
nativeBuildInputs = [ zerotierone bubblewrap sops age ];
|
2023-07-25 11:46:58 +00:00
|
|
|
} ''
|
2023-07-21 11:31:13 +00:00
|
|
|
cp -r ${src} ./src
|
|
|
|
chmod +w -R ./src
|
|
|
|
cd src
|
2023-07-25 17:00:16 +00:00
|
|
|
${checkPython}/bin/python -m pytest ./tests
|
2023-07-20 16:07:27 +00:00
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
package
|