Files
0xWheatyz d371ceeec8 build: add numpy and native library dependencies
Add numpy to requirements.txt and configure flake.nix with zlib and
stdenv.cc.cc.lib to support C extension packages. Sets LD_LIBRARY_PATH
for proper runtime linking.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-13 15:36:41 -04:00

64 lines
1.9 KiB
Nix

{
description = "Python dev env (NixOS 25.11) using project-local venv";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
# Pick your Python version here
python = pkgs.python311; # or python312, etc.
in {
devShells.default = pkgs.mkShell {
name = "python-venv-shell";
packages = [
python
pkgs.python311Packages.virtualenv # gives `virtualenv` tool
pkgs.zlib
pkgs.stdenv.cc.cc.lib
];
# Required for numpy and other C extension packages
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
pkgs.zlib
pkgs.stdenv.cc.cc.lib
];
shellHook = ''
echo "== Nix dev shell (Python $(python --version 2>&1)) =="
# Create a venv in .venv if it doesn't exist yet
if [ ! -d ".venv" ]; then
echo "Creating local virtualenv in .venv ..."
python -m venv .venv
fi
# Activate the venv
echo "Activating .venv"
. .venv/bin/activate
# Tell you what Python/pip you're using
echo "Using python: $(which python)"
echo "Using pip: $(which pip)"
# Install / update deps from requirements.txt *into .venv*
if [ -f "requirements.txt" ]; then
echo "Installing dependencies from requirements.txt into .venv ..."
pip install -r requirements.txt
else
echo "No requirements.txt found in $(pwd)"
fi
# Prompt tweak so you can see when venv is active
export NIX_PROJECT_SHELL="SPARC"
'';
};
});
}