Skip to content

Instantly share code, notes, and snippets.

@stefanDeveloper
Last active January 9, 2023 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanDeveloper/8f36828b3aa073237ddb0668ca9da970 to your computer and use it in GitHub Desktop.
Save stefanDeveloper/8f36828b3aa073237ddb0668ca9da970 to your computer and use it in GitHub Desktop.
NFStream Nix-Shell
with import <nixpkgs> { };
let
pythonPackages = python39Packages;
in pkgs.mkShell rec {
venvDir = "./.venv";
name = "nfstream";
requirements = "requirements.txt";
buildInputs = [
# Python
pythonPackages.setuptools
pythonPackages.virtualenv # run virtualenv .
pythonPackages.pip
pythonPackages.pyqt5 # avoid installing via pip
# This execute some shell code to initialize a venv in $venvDir before
# dropping into the shell
pythonPackages.venvShellHook
# C tools
autoconf
autoreconfHook
automake
libtool
pkg-config
zlib
bison
gettext
json_c
libdbusmenu
bluez
libnl
libpcap
flex
];
shellHook = ''
# fixes libstdc++ issues and libgl.so issues
LD_LIBRARY_PATH=${zlib}/lib/:${stdenv.cc.cc.lib}/lib/:/run/opengl-driver/lib/
# fixes xcb issues :
QT_PLUGIN_PATH=${qt5.qtbase}/${qt5.qtbase.qtPluginPrefix}
SOURCE_DATE_EPOCH=$(date +%s)
QT_XCB_GL_INTEGRATION="none"
if [ -d "${venvDir}" ]; then
echo "Skipping venv creation, '${venvDir}' already exists"
else
echo "Creating new venv environment in path: '${venvDir}'"
# Note that the module venv was only introduced in python 3, so for 2.7
# this needs to be replaced with a call to virtualenv
${pythonPackages.python.interpreter} -m venv "${venvDir}"
fi
# Under some circumstances it might be necessary to add your virtual
# environment to PYTHONPATH, which you can do here too;
PYTHONPATH=$PWD/${venvDir}/${pythonPackages.python.sitePackages}/:${pypy}:$PYTHONPATH
source "${venvDir}/bin/activate"
echo "Upgrading pip to latest version"
python -m pip install --upgrade pip
if [ -f "./${requirements}" ]; then
echo "Install '${requirements}'"
pip install -r ${requirements}
fi
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment