Add working python venv template and modified version using poetry

This commit is contained in:
Evie Litherland-Smith 2023-04-03 09:24:26 +01:00
parent 193245282a
commit 49d0c1b48f
4 changed files with 37 additions and 62 deletions

View file

@ -1,18 +0,0 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.stdenv.mkDerivation {
pname = "indica-notebook";
version = "1.0.0";
buildInputs = with pkgs; [
(python39.withPackages (ps: with ps; [
jupyter
]))
];
configurePhase = '''';
buildPhase = '''';
installPhase = '''';
}

View file

@ -1,30 +0,0 @@
{ tinypkgs ? import
(fetchTarball {
url = "https://gitlab.inria.fr/nix-tutorial/packages-repository/-/archive/master/packages-repository-8e43243635cd8f28c7213205b08c12f2ca2ac74d.tar.gz";
sha256 = "sha256:09l2w3m1z0308zc476ci0bsz5amm536hj1n9xzpwcjm59jxkqpqa";
})
{ }
}:
with tinypkgs; # Put tinypkgs's attributes in the current scope.
with pkgs; # Same for pkgs.
mkShell {
buildInputs = [
chord
# Defines a python + set of packages.
(python3.withPackages (ps: with ps; with python3Packages; [
jupyter
ipython
# Uncomment the following lines to make them available in the shell.
# pandas
# numpy
# matplotlib
]))
];
# Automatically run jupyter when entering the shell.
shellHook = "jupyter notebook";
}

24
templates/poetry.nix Normal file
View file

@ -0,0 +1,24 @@
{ pkgs ? import <nixpkgs> {}, python ? pkgs.python39, ... }:
let
python-packages = ps: with ps; [
pip
setuptools
wheel
];
in
pkgs.mkShell {
nativeBuildInputs = with pkgs; [
(python.withPackages python-packages)
poetry
git
zlib
libgccjit
];
shellHook = ''
export LD_LIBRARY_PATH="${pkgs.zlib}/lib:${pkgs.libgccjit}/lib"
[ ! -d "./.venv" ] && poetry install --sync
source .venv/bin/activate
'';
}

View file

@ -1,4 +1,4 @@
{ pkgs ? import <nixpkgs> { } }:
{ pkgs ? import <nixpkgs> {}, python ? pkgs.python39, ... }:
let
python-packages = ps: with ps; [
@ -7,18 +7,17 @@ let
wheel
];
in
with pkgs;
(buildFHSUserEnv {
name = "python";
targetPkgs = pkgs: [ ];
multiPkgs = pkgs: [
zlib zlib-ng
(python39.withPackages python-packages)
pkgs.mkShell {
nativeBuildInputs = with pkgs; [
(python.withPackages python-packages)
git
zlib
libgccjit
];
runScript = ''
bash -c "{
shellHook = ''
export LD_LIBRARY_PATH="${pkgs.zlib}/lib:${pkgs.libgccjit}/lib"
python -m venv .venv
source .venv/bin/activate
}"
'';
}).env
}