Skip to content

Commit 0188318

Browse files
committed
dev: Simplify devShells, restore the -extra devShell
1 parent 5da9da4 commit 0188318

File tree

3 files changed

+71
-46
lines changed

3 files changed

+71
-46
lines changed

.devops/nix/devshells.nix

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,48 @@
1+
{ inputs, ... }:
2+
13
{
24
perSystem =
3-
{ config, lib, ... }:
45
{
5-
devShells = lib.pipe (config.packages) [
6-
(lib.concatMapAttrs
7-
(name: package: {
8-
${name} = package.passthru.shell or null;
9-
}))
10-
(lib.filterAttrs (name: value: value != null))
11-
];
6+
config,
7+
lib,
8+
system,
9+
...
10+
}:
11+
{
12+
devShells =
13+
let
14+
pkgs = import inputs.nixpkgs { inherit system; };
15+
stdenv = pkgs.stdenv;
16+
scripts = config.packages.python-scripts;
17+
in
18+
lib.pipe (config.packages) [
19+
(lib.concatMapAttrs (
20+
name: package: {
21+
${name} = pkgs.mkShell {
22+
name = "${name}";
23+
inputsFrom = [ package ];
24+
shellHook = ''
25+
echo "Entering ${name} devShell"
26+
'';
27+
};
28+
"${name}-extra" =
29+
if (name == "python-scripts") then
30+
null
31+
else
32+
pkgs.mkShell {
33+
name = "${name}-extra";
34+
inputsFrom = [
35+
package
36+
scripts
37+
];
38+
shellHook = ''
39+
echo "Entering ${name} devShell"
40+
addToSearchPath "LD_LIBRARY_PATH" "${lib.getLib stdenv.cc.cc}/lib"
41+
'';
42+
};
43+
}
44+
))
45+
(lib.filterAttrs (name: value: value != null))
46+
];
1247
};
1348
}
14-

.devops/nix/package.nix

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
vulkan-loader,
2121
curl,
2222
shaderc,
23-
useBlas ? builtins.all (x: !x) [
24-
useCuda
25-
useMetalKit
26-
useRocm
27-
useVulkan
28-
] && blas.meta.available,
23+
useBlas ?
24+
builtins.all (x: !x) [
25+
useCuda
26+
useMetalKit
27+
useRocm
28+
useVulkan
29+
]
30+
&& blas.meta.available,
2931
useCuda ? config.cudaSupport,
3032
useMetalKit ? stdenv.isAarch64 && stdenv.isDarwin,
3133
# Increases the runtime closure size by ~700M
@@ -214,25 +216,6 @@ effectiveStdenv.mkDerivation (finalAttrs: {
214216
cp $src/include/llama.h $out/include/
215217
'';
216218

217-
# Define the shells here, but don't add in the inputsFrom to avoid recursion.
218-
passthru = {
219-
inherit
220-
useBlas
221-
useCuda
222-
useMetalKit
223-
useMpi
224-
useRocm
225-
useVulkan
226-
;
227-
228-
shell = mkShell {
229-
name = "shell-${finalAttrs.finalPackage.name}";
230-
description = "contains numpy and sentencepiece";
231-
nativeBuildInputs = [ cmake ];
232-
inputsFrom = [ finalAttrs.finalPackage ];
233-
};
234-
};
235-
236219
meta = {
237220
# Configurations we don't want even the CI to evaluate. Results in the
238221
# "unsupported platform" messages. This is mostly a no-op, because

.devops/nix/python-scripts.nix

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
stdenv,
44
buildPythonPackage,
55
poetry-core,
6-
breakpointHook,
76
mkShell,
87
python3Packages,
98
gguf-py,
@@ -18,6 +17,25 @@ let
1817
torchWithoutCuda
1918
gguf-py
2019
tqdm
20+
21+
# for scripts/compare-llama-bench.py
22+
gitpython
23+
tabulate
24+
25+
# for examples/pydantic-models-to-grammar-examples.py
26+
docstring-parser
27+
pydantic
28+
29+
];
30+
31+
llama-python-test-deps = with python3Packages; [
32+
# Server bench
33+
matplotlib
34+
35+
# server tests
36+
openai
37+
behave
38+
prometheus-client
2139
];
2240
in
2341

@@ -43,16 +61,6 @@ buildPythonPackage ({
4361
src = lib.cleanSource ../../.;
4462
};
4563
nativeBuildInputs = [ poetry-core ];
64+
nativeCheckInputs = llama-python-test-deps;
4665
dependencies = llama-python-deps;
47-
48-
passthru = {
49-
shell = mkShell {
50-
name = "shell-python-scripts";
51-
description = "contains numpy and sentencepiece";
52-
buildInputs = llama-python-deps;
53-
shellHook = ''
54-
addToSearchPath "LD_LIBRARY_PATH" "${lib.getLib stdenv.cc.cc}/lib"
55-
'';
56-
};
57-
};
5866
})

0 commit comments

Comments
 (0)