Created
March 27, 2018 13:36
-
-
Save danbst/dd641c696f77f5465ef9c827fcbf1e2c to your computer and use it in GitHub Desktop.
Nix + Python + nanomsg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#################################################################################### | |
# Nix shell for nix-powered environments | |
# This is like `virtualenv`, but with fine-defined system dependencies | |
#################################################################################### | |
rec { | |
nanomsg-py = pythonPackages.buildPythonPackage { | |
name = "nanomsg-1.0"; | |
src = pkgs.fetchurl { url = "https://pypi.python.org/packages/0b/b1/3037e0e380d5fab2824e69a59bd374da402c0cef264ccb3fe5d71c230c4b/nanomsg-1.0.tar.gz"; sha256 = "843be41258219d9d319cf434a68cac7669834ab9c993ea4bab5b3d87f62a7a13"; }; | |
doCheck = false; | |
buildInputs = [ pkgs.nanomsg ]; | |
patchPhase = '' | |
sed -i "s|LoadLibrary('libnanomsg.so')|LoadLibrary('${pkgs.nanomsg}/lib/libnanomsg.so')|g" ./_nanomsg_ctypes/__init__.py | |
sed -i "s|LoadLibrary('libnanoconfig.so')|LoadLibrary('${pkgs.nanomsg}/lib/libnanoconfig.so')|g" ./setup.py | |
sed -i "s|LoadLibrary('libnanoconfig.so')|LoadLibrary('${pkgs.nanomsg}/lib/libnanoconfig.so')|g" ./_nanomsg_ctypes/__init__.py | |
''; | |
}; | |
shell = pythonPackages.buildPythonApplication { | |
name = "shared-env"; | |
buildInputs = (with pkgs; [ | |
postgresql | |
libffi | |
bashInteractive | |
nanomsg-py | |
]) ++ (with pythonPackages; [ | |
ipython | |
]); | |
phases = [ "unpackPhase" ]; | |
unpackPhase = '' echo "You should run this in nix-shell, not nix-build! ''; | |
shellHook = '' | |
echo 'Entering shared environmnet' | |
echo 'Run "init" to download requirements' | |
set -v | |
alias pip="PIP_PREFIX='$(pwd)/build/pip_packages' \pip" | |
export PYTHONPATH="$(pwd)/build/pip_packages/lib/python2.7/site-packages:$PYTHONPATH" | |
unset SOURCE_DATE_EPOCH | |
set +v | |
function init { | |
pip install -e . | |
} | |
''; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment