Skip to content

Commit 73fb7b0

Browse files
committed
python3Packages.homf: add checks
1 parent f9fbeb4 commit 73fb7b0

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

pkgs/development/python-modules/homf/default.nix

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{
22
lib,
33
buildPythonPackage,
4+
callPackage,
45
fetchFromGitHub,
56
# pytestCheckHook,
67
pythonOlder,
8+
versionCheckHook,
79

810
hatchling,
911
packaging,
@@ -25,7 +27,6 @@ buildPythonPackage rec {
2527
build-system = [ hatchling ];
2628

2729
pythonRelaxDeps = [ "packaging" ];
28-
2930
dependencies = [ packaging ];
3031

3132
pythonImportsCheck = [
@@ -39,6 +40,11 @@ buildPythonPackage rec {
3940
# nativeCheckInputs = [ pytestCheckHook ];
4041
# pytestFlagsArray = [ "-m 'not network'" ];
4142

43+
nativeBuildInputs = [ versionCheckHook ];
44+
45+
# (Ab)using `callPackage` as a fix-point operator, so tests can use the `homf` drv
46+
passthru.tests = callPackage ./tests.nix { };
47+
4248
meta = with lib; {
4349
description = "Asset download tool for GitHub Releases, PyPi, etc.";
4450
mainProgram = "homf";
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
lib,
3+
runCommand,
4+
testers,
5+
6+
cacert,
7+
homf,
8+
}:
9+
let
10+
# runs homf, putting the fetched artefacts in the drv output
11+
Homf =
12+
subcommand:
13+
{
14+
pkgName,
15+
version,
16+
hash,
17+
}:
18+
# testers.runCommand ensures we have an FOD, so the command has network access,
19+
# yet the test is rerun whenever one of its inputs changes.
20+
testers.runCommand {
21+
name = "homf-${subcommand}-${pkgName}";
22+
script = "homf ${subcommand} --directory $out ${pkgName} ${version}";
23+
nativeBuildInputs = [
24+
cacert
25+
homf
26+
];
27+
inherit hash;
28+
};
29+
in
30+
31+
lib.mapAttrs Homf {
32+
pypi = {
33+
pkgName = "homf";
34+
version = "1.1.1"; # pinned so updating homf won't invalidate hashes
35+
hash = "sha256-zpdt7+zTaGkLG6xYoTZVw/kUek0/MrCqvljfLxNB94A=";
36+
};
37+
38+
github = {
39+
pkgName = "duckinator/homf";
40+
version = "v1.1.1";
41+
hash = "sha256-NeEz8wZqDWYUnrgsknXWHzhWdk8cPW8mknKS3+/dngQ=";
42+
};
43+
}

0 commit comments

Comments
 (0)