Files

46 lines
1.3 KiB
Nix
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
description = "Python dev environment with pip, venv, and required C libraries";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
systems = [ "x86_64-linux" "aarch64-linux" ];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system:
f { pkgs = import nixpkgs { inherit system; }; });
in
{
devShells = forAllSystems ({ pkgs }: {
default = pkgs.mkShell {
buildInputs = [
pkgs.python313
pkgs.gcc
pkgs.zlib
pkgs.libffi
];
shellHook = ''
echo "Python dev environment ready 🐍"
# пробрасываем библиотеки для C-расширений
export LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib}/lib:${pkgs.zlib}/lib:${pkgs.libffi}/lib:$LD_LIBRARY_PATH"
if [ ! -d ".venv" ]; then
echo "Creating virtualenv in .venv..."
python -m venv .venv
echo "Activating virtualenv and installing numpy/pandas..."
. .venv/bin/activate
pip install --upgrade pip
pip install numpy pandas scipy
else
. .venv/bin/activate
fi
echo "Virtualenv activated!"
'';
};
});
};
}