-
Notifications
You must be signed in to change notification settings - Fork 9
/
default.nix
65 lines (61 loc) · 1.66 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{ pkgs ? import
(fetchTarball {
name = "jpetrucciani-2024-11-23";
url = "https://github.com/jpetrucciani/nix/archive/9615d18512c3cadce8ae2ce4a92c5215296adaa9.tar.gz";
sha256 = "1ibk7xkzwa8ljdm8360rg6nxnwzl06gbxlx93zzz0imv6nsf96kq";
})
{ }
}:
let
name = "gamble";
python = pkgs.poetry-helpers.mkEnv {
projectDir = ./.;
python = pkgs.python312;
editablePackageSources."gamble" = ./gamble;
};
tools = with pkgs; {
cli = [
nixpkgs-fmt
];
python = [
poetry
python
];
scripts = pkgs.lib.attrsets.attrValues scripts;
};
scripts =
let
inherit (pkgs.writers) writeBashBin;
repo = "$(${pkgs.git}/bin/git rev-parse --show-toplevel)";
in
{
test_actions = writeBashBin "test_actions" ''
export DOCKER_HOST=$(${pkgs.docker-client}/bin/docker context inspect --format '{{.Endpoints.docker.Host}}')
${pkgs.act}/bin/act --container-architecture linux/amd64 -r --rm
'';
_test = writeBashBin "_test" ''
export PYTEST_RUNNING=1
${python}/bin/pytest ./tests \
-s \
--cov ${name} \
--cov-report term \
--cov-report html \
--cov-report xml:coverage.xml \
--junitxml=report.xml \
"$@"
'';
docs = writeBashBin "docs" ''
cd "${repo}/docs" || exit 1
rm -rf ./build
${python}/bin/sphinx-build -M html source build
'';
};
paths = pkgs.lib.flatten [ (builtins.attrValues tools) ];
env = python.env.overrideAttrs (_: {
buildInputs = paths;
});
in
(env.overrideAttrs (_: {
inherit name;
NIXUP = "0.0.8";
})) // { inherit scripts; }