forked from clementpoiret/nix-python-devenv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
84 lines (80 loc) · 2.66 KB
/
flake.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
{
description = "Template of a Python project managed by uv";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs-python.url = "github:cachix/nixpkgs-python";
devenv = {
url = "github:cachix/devenv";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ inputs.devenv.flakeModule ];
flake = {
nixConfig = {
extra-substituters = [
"https://nixpkgs-python.cachix.org"
"https://cuda-maintainers.cachix.org"
"https://devenv.cachix.org"
];
extra-trusted-public-keys = [
"nixpkgs-python.cachix.org-1:hxjI7pFxTyuTHn2NkvWCrAUcNZLNS3ZAvfYNuYifcEU="
"cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E="
"devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="
];
};
};
systems = [ "x86_64-linux" ];
perSystem = { config, self', inputs', pkgs, lib, system, ... }: {
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
# overlays = [
# inputs.poetry2nix.overlays.default
# (final: prev: { inherit (inputs.nixpkgs-stable) skopeo; })
# ];
config = {
allowUnfree = true;
cudaSupport = true;
};
};
devenv.shells.default = let
buildInputs = with pkgs; [
cudaPackages.cudatoolkit
cudaPackages.cudnn
cudaPackages.cuda_cudart
pythonManylinuxPackages.manylinux2014Package
stdenv.cc.cc
zlib
];
in {
containers.default = {
name = "jimmy";
startupCommand = "bash";
copyToRoot = null;
};
env = {
LD_LIBRARY_PATH = "${
with pkgs;
lib.makeLibraryPath buildInputs
}:/run/opengl-driver/lib:/run/opengl-driver-32/lib";
XLA_FLAGS =
"--xla_gpu_cuda_data_dir=${pkgs.cudaPackages.cudatoolkit}"; # For tensorflow with GPU support
};
packages = with pkgs; [ bashInteractive uv ];
enterShell = ''
uv sync --extra cuda12
. .venv/bin/activate
'';
languages.python = {
enable = true;
manylinux.enable = false;
package = pkgs.python312;
uv = { enable = true; };
};
};
};
};
}