-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
120 lines (99 loc) · 3.53 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
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
{
description = "Flake for the Django-based `agl-anonymizer` service with CUDA support";
nixConfig = {
substituters = [
"https://cache.nixos.org"
"https://cuda-maintainers.cachix.org"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E="
];
extra-substituters = "https://cache.nixos.org https://nix-community.cachix.org https://cuda-maintainers.cachix.org";
extra-trusted-public-keys = "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=";
};
inputs = {
# Use a single nixpkgs input to avoid conflicts
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# poetry2nix should follow the same nixpkgs
poetry2nix.url = "github:nix-community/poetry2nix";
poetry2nix.inputs.nixpkgs.follows = "nixpkgs";
cachix = {
url = "github:cachix/cachix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, cachix, ... } @ inputs:
let
nvidiaCache = cachix.lib.mkCachixCache {
inherit (pkgs) lib;
name = "nvidia";
publicKey = "nvidia.cachix.org-1:dSyZxI8geDCJrwgvBfPH3zHMC+PO6y/BT7O6zLBOv0w=";
secretKey = null; # not needed for pulling from the cache
};
system = "x86_64-linux";
self = inputs.self;
# Import nixpkgs with desired configuration
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfree = true;
cudaSupport = true;
};
};
pypkgs-build-requirements = {
gender-guesser = [ "setuptools" ];
conllu = [ "setuptools" ];
janome = [ "setuptools" ];
pptree = [ "setuptools" ];
wikipedia-api = [ "setuptools" ];
django-flat-theme = [ "setuptools" ];
django-flat-responsive = [ "setuptools" ];
};
poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix { inherit pkgs;};
lib = pkgs.lib;
p2n-overrides = poetry2nix.defaultPoetryOverrides.extend (final: prev:
builtins.mapAttrs (package: build-requirements:
(builtins.getAttr package prev).overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ (
builtins.map (pkg:
if builtins.isString pkg then builtins.getAttr pkg prev else pkg
) build-requirements
);
})
) pypkgs-build-requirements
// { ###################### DELETE?!
pytorch = prev.pytorch.override {
cudaSupport = true;
cudatoolkit = pkgs.cudatoolkit; # Adjust this version if necessary
};
}
);
in {
packages.x86_64-linux.poetryApp = poetry2nix.mkPoetryApplication {
python = pkgs.python311;
projectDir = ./.;
src = lib.cleanSource ./.;
overrides = p2n-overrides;
preferWheels = true; # required for transformers via p2n
propagatedBuildInputs = with pkgs.python311Packages; [
pillow
];
buildInputs = with pkgs; [];
};
devShells.x86_64-linux.default = pkgs.mkShell {
inputsFrom = [ self.packages.x86_64-linux.poetryApp ];
packages = [ pkgs.poetry ];
};
nixConfig = {
binary-caches = [
nvidiaCache.binaryCachePublicUrl
];
binary-cache-public-keys = [
nvidiaCache.publicKey
];
# enable cuda support
cudaSupport = true;
};
};
}