-
Notifications
You must be signed in to change notification settings - Fork 9
/
flake.nix
65 lines (51 loc) · 1.92 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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/master";
# cross-platform convenience
flake-utils.url = "github:numtide/flake-utils";
# backwards compatibility with nix-build and nix-shell
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
};
outputs = { self, nixpkgs, flake-utils, flake-compat }:
# resolve for all platforms in turn
flake-utils.lib.eachDefaultSystem (system:
let
# packages for this system platform
pkgs = nixpkgs.legacyPackages.${system};
# control versions
# get these python packages from nix
python_packages = python-packages: [
python-packages.pip
];
# use this pyton version, and include the abvoe packages
python = pkgs.python312.withPackages python_packages;
in {
devShell = pkgs.stdenv.mkDerivation {
name = "devshell";
buildInputs = with pkgs; [
# version to use + default packages are declared above
python
# linters
shellcheck
# for scripts
bash
fswatch
rsync
] ++ lib.optionals (pkgs.stdenv.isDarwin) [
# for python watchdog package
darwin.apple_sdk.frameworks.CoreServices
];
shellHook = ''
export PYTHON_VERSION="$(python -c 'import platform; import re; print(re.sub(r"\.\d+$", "", platform.python_version()))')"
# replicate virtualenv behaviour
export PIP_PREFIX="$PWD/vendor/python/$PYTHON_VERSION/packages"
export PYTHONPATH="$PIP_PREFIX/lib/python$PYTHON_VERSION/site-packages:$PYTHONPATH"
unset SOURCE_DATE_EPOCH
export PATH="$PIP_PREFIX/bin:$PATH"
# hack: can't find libstdc++.so.8 otherwise
export LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib}/lib"
'';
};
}
);
}