-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathflake.nix
58 lines (56 loc) · 1.89 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs-python.url = "github:cachix/nixpkgs-python";
nixpkgs-python.inputs = { nixpkgs.follows = "nixpkgs"; };
devenv.url = "github:cachix/devenv";
};
nixConfig = {
extra-trusted-public-keys =
"devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=";
extra-substituters = "https://devenv.cachix.org";
};
outputs = { self, nixpkgs, devenv, ... }@inputs:
let
system = "x86_64-linux";
pkgs = import nixpkgs { system = system; };
# A list of shell names and their Python versions
pythonVersions = {
python39 = "3.9";
python310 = "3.10";
python311 = "3.11";
python312 = "3.12";
default = "3.10";
};
# A function to make a shell with a python version
makePythonShell = shellName: pythonVersion:
devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
({ pkgs, config, ... }: {
languages.python = {
version = pythonVersion;
libraries = with pkgs; [ stdenv.cc.cc.lib gcc-unwrapped libz ];
enable = true;
venv.enable = true;
poetry = {
enable = true;
activate.enable = true;
package = pkgs.poetry;
install = {
enable = true;
installRootPackage = true;
};
};
};
env.LD_LIBRARY_PATH =
"${pkgs.gcc-unwrapped.lib}/lib64:${pkgs.libz}/lib";
})
];
};
in {
# mapAttrs runs the given function (makePythonShell) against every value
# in the attribute set (pythonVersions) and returns a new set
devShells.x86_64-linux = builtins.mapAttrs makePythonShell pythonVersions;
};
}