-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
64 lines (57 loc) · 2.07 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
{
description = "A Nix-flake-based Python development environment";
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import nixpkgs { inherit system; };
});
in
{
devShells = forEachSupportedSystem ({ pkgs }: {
default = pkgs.mkShell {
packages = with pkgs; [
python313
] ++ (with pkgs.python313Packages; [
uv
pkgs.zsh
pkgs.neovim
pkgs.black
pkgs.texliveFull
pkgs.grpcurl
pkgs.python3
pkgs.protobuf
]);
shellHook = ''
echo "🔧 Setting up Python virtual environment with uv..."
# Add GCC library path to LD_LIBRARY_PATH
export LD_LIBRARY_PATH=${pkgs.gcc.cc.lib}/lib:$LD_LIBRARY_PATH
# Add src to PATH
export PYTHONPATH=$PWD/src:$PYTHONPATH
uv sync --extra dev
# Create venv if it doesn't exist
if [ ! -d ".venv" ]; then
echo "📦 No .venv found, creating with uv..."
uv venv
fi
# Activate the venv
if [ -f ".venv/bin/activate" ]; then
source .venv/bin/activate
echo "✅ Activated Python venv at .venv"
python --version
# Install dependencies from pyproject.toml if it exists
if [ -f "pyproject.toml" ]; then
echo "📦 Installing dependencies from pyproject.toml..."
uv pip install .
else
echo "⚠️ No pyproject.toml found, skipping dependency installation"
fi
else
echo "❌ Failed to activate venv: .venv/bin/activate not found"
fi
'';
};
});
};
}