Created
June 23, 2017 18:43
-
-
Save uskudnik/a45632557fae343f89dc80a66f54dff7 to your computer and use it in GitHub Desktop.
example-python-nix-env.nix
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
let channels = rec { | |
pkgs = import <nixpkgs> {}; | |
pkgs-unstable = import (fetchTarball https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz) {}; | |
}; | |
in with channels; | |
let dependencies = rec { | |
_pip = pkgs.python36Packages.pip; | |
_virtualenv = pkgs.python36Packages.virtualenv; | |
_ipython = pkgs.python36Packages.ipython; | |
_virtualenvwrapper = pkgs-unstable.python36Packages.virtualenvwrapper; | |
_postgresql = pkgs.postgresql96.override { }; | |
_psycopg2 = pkgs.python36Packages.psycopg2; | |
_flask = with pkgs.python36Packages; flask.override { | |
name = "flask-0.12.2"; | |
src = pkgs.fetchurl { | |
url = "https://files.pythonhosted.org/packages/eb/12/1c7bd06fcbd08ba544f25bf2c6612e305a70ea51ca0eda8007344ec3f123/Flask-0.12.2.tar.gz"; | |
sha256 = "49f44461237b69ecd901cc7ce66feea0319b9158743dd27a2899962ab214dac1"; | |
}; | |
}; | |
_flask_sqlalchemy = with pkgs.python36Packages; flask_sqlalchemy.override { | |
name = "flask_SQLAlchemy-2.2"; | |
src = pkgs.fetchurl { | |
url = "https://files.pythonhosted.org/packages/15/f0/0c90391352db8244321e22604d93cb6a4e3c538e9ab512b35ee5359b8d74/Flask-SQLAlchemy-2.2.tar.gz"; | |
sha256 = "f0d8241efba723d7b878f73550f5d3c0fbb042416123b52b36640b7491fa208b"; | |
}; | |
}; | |
}; | |
in with dependencies; | |
pkgs.stdenv.mkDerivation rec { | |
name = "env"; | |
env = pkgs.buildEnv { | |
name = name; | |
paths = buildInputs; | |
}; | |
builder = builtins.toFile "builder.pl" '' | |
source $stdenv/setup; ln -s $env $out | |
''; | |
buildInputs = [ | |
(pkgs.python36.buildEnv.override { | |
ignoreCollisions = true; | |
extraLibs = [ | |
_pip | |
_ipython | |
_virtualenv | |
_virtualenvwrapper | |
_postgresql | |
_psycopg2 | |
_flask | |
_flask_sqlalchemy | |
]; | |
}) | |
]; | |
shellHook = '' | |
mkdir -p $PWD/postgresql | |
mkdir -p $PWD/logs | |
postgres -D `pwd`/postgresql >$PWD/logs/postgresql.log 2>&1 & | |
''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment