Skip to content

Instantly share code, notes, and snippets.

@kidmose
Created June 26, 2020 08:56
Show Gist options
  • Save kidmose/a9dc26ff1bb0fcdbefe09e56a892923a to your computer and use it in GitHub Desktop.
Save kidmose/a9dc26ff1bb0fcdbefe09e56a892923a to your computer and use it in GitHub Desktop.
Nix shell for python with mutable python modules (I.e. `pip install ...` works like in a virtualenv`)
with import <nixpkgs> {};
let
python = pkgs.python38.buildEnv.override {
# throw in some default stuff that is always nice to have
extraLibs = with pkgs.python38Packages; [
numpy
ipython
jupyter
pandas
];
};
in
pkgs.mkShell {
buildInputs = with pkgs; with python.pkgs; [
pip
setuptools
];
shellHook = ''
alias pip="PIP_PREFIX='$(pwd)/_build/pip_packages' \pip"
export PYTHONPATH="$(pwd)/_build/pip_packages/lib/${python.executable}/site-packages:$PYTHONPATH"
export PATH="$(pwd)/_build/pip_packages/bin:$PATH"
unset SOURCE_DATE_EPOCH
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment