-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshell.nix
51 lines (44 loc) · 1.42 KB
/
shell.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
{}:
let
# Update packages with `nixpkgs-update` command
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/4989a246d7a390a859852baddb1013f825435cee.tar.gz") { };
packages' = with pkgs; [
coreutils
python313
uv
ruff
maturin
(lib.optional stdenv.isDarwin libiconv)
(writeShellScriptBin "make" "maturin develop --uv")
(writeShellScriptBin "run-tests" ''
python -m pytest . \
--verbose \
--no-header
'')
(writeShellScriptBin "nixpkgs-update" ''
hash=$(
curl --silent --location \
https://prometheus.nixos.org/api/v1/query \
-d "query=channel_revision{channel=\"nixpkgs-unstable\"}" | \
grep --only-matching --extended-regexp "[0-9a-f]{40}")
sed -i -E "s|/nixpkgs/archive/[0-9a-f]{40}\.tar\.gz|/nixpkgs/archive/$hash.tar.gz|" shell.nix
echo "Nixpkgs updated to $hash"
'')
];
shell' = with pkgs; ''
export PYTHONNOUSERSITE=1
export TZ=UTC
current_python=$(readlink -e .venv/bin/python || echo "")
current_python=''${current_python%/bin/*}
[ "$current_python" != "${python313}" ] && rm -rf .venv/
echo "Installing Python dependencies"
echo "${python313}/bin/python" > .python-version
NIX_ENFORCE_PURITY=0 uv sync --frozen
echo "Activating Python virtual environment"
source .venv/bin/activate
'';
in
pkgs.mkShell {
buildInputs = packages';
shellHook = shell';
}