Skip to content

Commit 888b192

Browse files
committed
Update nix develop environment
1 parent ed1da76 commit 888b192

File tree

2 files changed

+41
-30
lines changed

2 files changed

+41
-30
lines changed

dev_env_builder.nix

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,43 @@
1-
{ nixpkgs
2-
, system
3-
, cudaSupport
4-
, rocmSupport
5-
}:
1+
{ nixpkgs, system, cudaSupport ? false, rocmSupport ? false
2+
, vulkanSupport ? false }:
63
let
74
pkgs = import nixpkgs {
85
inherit system;
96
config.allowUnfree = true;
107
config.cudaSupport = cudaSupport;
118
config.rocmSupport = rocmSupport;
9+
config.vulkanSupport = vulkanSupport;
1210
};
13-
pythonPackages = pkgs.python3Packages;
14-
in
15-
pkgs.mkShell rec {
11+
in pkgs.mkShell {
1612
name = "impureEvoXPythonEnv";
1713
venvDir = "./.venv";
18-
buildInputs = with pythonPackages; [
19-
python
20-
# This executes some shell code to initialize a venv in $venvDir before
21-
# dropping into the shell
22-
venvShellHook
14+
nativeBuildInputs = with pkgs; [
15+
(python313.withPackages (py-pkgs:
16+
with py-pkgs; [
17+
# This executes some shell code to initialize a venv in $venvDir before
18+
# dropping into the shell
19+
venvShellHook
2320

24-
# Those are dependencies that we would like to use from nixpkgs, which will
25-
# add them to PYTHONPATH and thus make them accessible from within the venv.
26-
numpy
27-
torch
28-
torchvision
29-
] ++ (with pkgs; [
21+
# Those are dependencies that we would like to use from nixpkgs, which will
22+
# add them to PYTHONPATH and thus make them accessible from within the venv.
23+
numpy
24+
(if cudaSupport then
25+
torchWithCuda
26+
else if rocmSupport then
27+
torchWithRocm
28+
else if vulkanSupport then
29+
torchWithVulkan
30+
else
31+
torch)
32+
torchvision
33+
]))
3034
pre-commit
3135
ruff
32-
]);
36+
];
3337

3438
# Run this command, only after creating the virtual environment
3539
postVenvCreation = ''
3640
unset SOURCE_DATE_EPOCH
37-
pip install -e .
3841
'';
3942

4043
# Now we can execute any commands within the virtual environment.
@@ -43,5 +46,4 @@ pkgs.mkShell rec {
4346
# allow pip to install wheels
4447
unset SOURCE_DATE_EPOCH
4548
'';
46-
4749
}

flake.nix

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
description = "evox";
33
inputs = {
4-
nixpkgs.url = "nixpkgs/nixos-24.11";
4+
nixpkgs.url = "nixpkgs/nixos-unstable";
55
utils.url = "github:numtide/flake-utils";
66
};
77

@@ -11,15 +11,24 @@
1111
eachSystem (with system; [ x86_64-linux ]) (system:
1212
let
1313
builder = import ./dev_env_builder.nix;
14-
cuda-env = builder { inherit system nixpkgs; cudaSupport = true; rocmSupport = false; };
15-
rocm-env = builder { inherit system nixpkgs; cudaSupport = false; rocmSupport = true; };
16-
cpu-env = builder { inherit system nixpkgs; cudaSupport = false; rocmSupport = false; };
17-
in
18-
{
14+
cuda-env = builder {
15+
inherit system nixpkgs;
16+
cudaSupport = true;
17+
};
18+
rocm-env = builder {
19+
inherit system nixpkgs;
20+
rocmSupport = true;
21+
};
22+
vulkan-env = builder {
23+
inherit system nixpkgs;
24+
vulkanSupport = true;
25+
};
26+
cpu-env = builder { inherit system nixpkgs; };
27+
in {
1928
devShells.default = cpu-env;
2029
devShells.cpu = cpu-env;
2130
devShells.cuda = cuda-env;
2231
devShells.rocm = rocm-env;
23-
}
24-
);
32+
devShells.vulkan = vulkan-env;
33+
});
2534
}

0 commit comments

Comments
 (0)