simplify clan cli build expression

also re-expose missing age
This commit is contained in:
Jörg Thalheim
2023-08-03 13:07:00 +02:00
parent e603ee6f49
commit cb0197fcf3
2 changed files with 68 additions and 72 deletions

View File

@@ -1,5 +1,4 @@
{ pkgs
, lib
{ lib
, python3
, ruff
, runCommand
@@ -8,45 +7,65 @@
, bubblewrap
, sops
, age
, black
, nix
, mypy
, setuptools
, self
, argcomplete
, pytest
, pytest-cov
, pytest-subprocess
, wheel
}:
let
pyproject = builtins.fromTOML (builtins.readFile ./pyproject.toml);
name = pyproject.project.name;
dependencies = [ argcomplete ];
src = lib.cleanSource ./.;
dependencies = lib.attrValues {
inherit (python3.pkgs)
argcomplete
;
};
devDependencies = lib.attrValues {
inherit (pkgs) ruff;
inherit (python3.pkgs)
black
mypy
testDependencies = [
pytest
pytest-cov
pytest-subprocess
setuptools
wheel
;
};
mypy
];
package = python3.pkgs.buildPythonPackage {
inherit name src;
checkPython = python3.withPackages (_ps: dependencies ++ testDependencies);
in
python3.pkgs.buildPythonPackage {
name = "clan";
src = lib.cleanSource ./.;
format = "pyproject";
nativeBuildInputs = [
python3.pkgs.setuptools
setuptools
installShellFiles
];
propagatedBuildInputs =
dependencies
++ [ ];
passthru.tests = { inherit clan-mypy clan-pytest; };
passthru.devDependencies = devDependencies;
propagatedBuildInputs = dependencies;
passthru.tests = {
clan-mypy = runCommand "clan-mypy" { } ''
cp -r ${./.} ./src
chmod +w -R ./src
cd src
${checkPython}/bin/mypy .
touch $out
'';
clan-pytest = runCommand "clan-tests"
{
nativeBuildInputs = [ age zerotierone bubblewrap sops nix ];
} ''
cp -r ${./.} ./src
chmod +w -R ./src
cd src
${checkPython}/bin/python -m pytest ./tests
touch $out
'';
};
passthru.devDependencies = [
ruff
black
setuptools
wheel
] ++ testDependencies;
makeWrapperArgs = [
"--set CLAN_FLAKE ${self}"
@@ -54,32 +73,9 @@ let
postInstall = ''
installShellCompletion --bash --name clan \
<(${python3.pkgs.argcomplete}/bin/register-python-argcomplete --shell bash clan)
<(${argcomplete}/bin/register-python-argcomplete --shell bash clan)
installShellCompletion --fish --name clan.fish \
<(${python3.pkgs.argcomplete}/bin/register-python-argcomplete --shell fish clan)
<(${argcomplete}/bin/register-python-argcomplete --shell fish clan)
'';
meta.mainProgram = "clan";
};
checkPython = python3.withPackages (_ps: devDependencies ++ dependencies);
clan-mypy = runCommand "${name}-mypy" { } ''
cp -r ${src} ./src
chmod +w -R ./src
cd src
${checkPython}/bin/mypy .
touch $out
'';
clan-pytest = runCommand "${name}-tests"
{
nativeBuildInputs = [ zerotierone bubblewrap sops age ];
} ''
cp -r ${src} ./src
chmod +w -R ./src
cd src
${checkPython}/bin/python -m pytest ./tests
touch $out
'';
in
package
}

View File

@@ -5,7 +5,7 @@
inherit (self'.packages) clan;
};
packages = {
clan = pkgs.callPackage ./default.nix {
clan = pkgs.python3.pkgs.callPackage ./default.nix {
inherit self;
zerotierone = self'.packages.zerotierone;
};