-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdefault.nix
143 lines (138 loc) · 3.74 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
{
lib,
stdenv,
callPackage,
fetchFromGitHub,
uv2nix,
pyproject-nix,
pyproject-build-systems,
python3,
graphviz,
d2,
makeWrapper,
cacert,
link-arguebase,
}:
let
pdocRepo = fetchFromGitHub {
owner = "mitmproxy";
repo = "pdoc";
tag = "v15.0.1";
hash = "sha256-HDrDGnK557EWbBQtsvDzTst3oV0NjLRm4ilXaxd6/j8=";
};
workspace = uv2nix.lib.workspace.loadWorkspace { workspaceRoot = ./.; };
projectOverlay = workspace.mkPyprojectOverlay {
sourcePreference = "wheel";
};
buildSystemOverlay =
final: prev:
lib.mapAttrs
(
name: value:
prev.${name}.overrideAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ (final.resolveBuildSystem value);
})
)
{
pygraphviz = {
setuptools = [ ];
};
};
packageOverlay =
final: prev:
lib.mapAttrs (name: value: prev.${name}.overrideAttrs value) {
pygraphviz = old: {
buildInputs = (old.buildInputs or [ ]) ++ [ graphviz ];
};
arguebuf = old: {
meta = (old.meta or { }) // {
mainProgram = "arguebuf";
description = "Create and analyze argument graphs and serialize them via Protobuf";
maintainers = with lib.maintainers; [ mirkolenz ];
license = lib.licenses.mit;
homepage = "https://github.com/recap-utr/arguebuf";
platforms = with lib.platforms; darwin ++ linux;
};
passthru = lib.recursiveUpdate (old.passthru or { }) {
tests.pytest = stdenv.mkDerivation {
name = "${final.arguebuf.name}-pytest";
inherit (final.arguebuf) src;
nativeBuildInputs = [
cacert
(final.mkVirtualEnv "arguebuf-test-env" {
arguebuf = [
"all"
"test"
];
})
];
buildInputs = [
graphviz
d2
];
configurePhase = ''
runHook preConfigure
${lib.getExe link-arguebase}
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
pytest --cov-report=html
runHook postBuild
'';
installPhase = ''
runHook preInstall
mv htmlcov $out
runHook postInstall
'';
};
docs = stdenv.mkDerivation {
name = "${final.arguebuf.name}-docs";
inherit (final.arguebuf) src;
nativeBuildInputs = [
cacert
(final.mkVirtualEnv "arguebuf-docs-env" {
arguebuf = [
"all"
"docs"
];
})
];
dontConfigure = true;
buildPhase = ''
runHook preBuild
typer arguebuf.cli.app utils docs --name arguebuf --output cli.md
pdoc \
-d google \
-t ${pdocRepo}/examples/dark-mode \
--math \
-o "$out" \
arguebuf.cli \
arguebuf
runHook postBuild
'';
installPhase = ''
runHook preInstall
cp -rf ./assets "$out/assets"
runHook postInstall
'';
};
};
};
};
baseSet = callPackage pyproject-nix.build.packages {
python = python3;
};
in
{
inherit workspace;
inherit (callPackage pyproject-nix.build.util { }) mkApplication;
pythonSet = baseSet.overrideScope (
lib.composeManyExtensions [
pyproject-build-systems.overlays.default
projectOverlay
buildSystemOverlay
packageOverlay
]
);
}