dev: Simplify devShells, restore the -extra devShell

This commit is contained in:
ditsuke 2024-08-20 02:57:02 +05:30
parent cd8da29059
commit 06a8547a20
No known key found for this signature in database
GPG key ID: 71B6C31C8A5A9D21
3 changed files with 63 additions and 40 deletions

View file

@ -1,14 +1,48 @@
{ inputs, ... }:
{ {
perSystem = perSystem =
{ config, lib, ... }:
{ {
devShells = lib.pipe (config.packages) [ config,
(lib.concatMapAttrs lib,
(name: package: { system,
${name} = package.passthru.shell or null; ...
})) }:
(lib.filterAttrs (name: value: value != null)) {
]; devShells =
let
pkgs = import inputs.nixpkgs { inherit system; };
stdenv = pkgs.stdenv;
scripts = config.packages.python-scripts;
in
lib.pipe (config.packages) [
(lib.concatMapAttrs (
name: package: {
${name} = pkgs.mkShell {
name = "${name}";
inputsFrom = [ package ];
shellHook = ''
echo "Entering ${name} devShell"
'';
};
"${name}-extra" =
if (name == "python-scripts") then
null
else
pkgs.mkShell {
name = "${name}-extra";
inputsFrom = [
package
scripts
];
shellHook = ''
echo "Entering ${name} devShell"
addToSearchPath "LD_LIBRARY_PATH" "${lib.getLib stdenv.cc.cc}/lib"
'';
};
}
))
(lib.filterAttrs (name: value: value != null))
];
}; };
} }

View file

@ -215,25 +215,6 @@ effectiveStdenv.mkDerivation (finalAttrs: {
cp $src/include/llama.h $out/include/ cp $src/include/llama.h $out/include/
''; '';
# Define the shells here, but don't add in the inputsFrom to avoid recursion.
passthru = {
inherit
useBlas
useCuda
useMetalKit
useMpi
useRocm
useVulkan
;
shell = mkShell {
name = "shell-${finalAttrs.finalPackage.name}";
description = "contains numpy and sentencepiece";
nativeBuildInputs = [ cmake ];
inputsFrom = [ finalAttrs.finalPackage ];
};
};
meta = { meta = {
# Configurations we don't want even the CI to evaluate. Results in the # Configurations we don't want even the CI to evaluate. Results in the
# "unsupported platform" messages. This is mostly a no-op, because # "unsupported platform" messages. This is mostly a no-op, because

View file

@ -3,7 +3,6 @@
stdenv, stdenv,
buildPythonPackage, buildPythonPackage,
poetry-core, poetry-core,
breakpointHook,
mkShell, mkShell,
python3Packages, python3Packages,
gguf-py, gguf-py,
@ -18,6 +17,25 @@ let
torchWithoutCuda torchWithoutCuda
gguf-py gguf-py
tqdm tqdm
# for scripts/compare-llama-bench.py
gitpython
tabulate
# for examples/pydantic-models-to-grammar-examples.py
docstring-parser
pydantic
];
llama-python-test-deps = with python3Packages; [
# Server bench
matplotlib
# server tests
openai
behave
prometheus-client
]; ];
in in
@ -43,16 +61,6 @@ buildPythonPackage ({
src = lib.cleanSource ../../.; src = lib.cleanSource ../../.;
}; };
nativeBuildInputs = [ poetry-core ]; nativeBuildInputs = [ poetry-core ];
nativeCheckInputs = llama-python-test-deps;
dependencies = llama-python-deps; dependencies = llama-python-deps;
passthru = {
shell = mkShell {
name = "shell-python-scripts";
description = "contains numpy and sentencepiece";
buildInputs = llama-python-deps;
shellHook = ''
addToSearchPath "LD_LIBRARY_PATH" "${lib.getLib stdenv.cc.cc}/lib"
'';
};
};
}) })