From 1805e26cc1aa5f311f35d020ea4e77d5e0da1a9e Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Thu, 18 May 2023 09:36:17 +0100 Subject: [PATCH] Update python venv template to be more robust Move template into python39 folder in case I add more in the future --- templates/python39/shell.nix | 8 ++++++++ templates/venv.nix | 12 ------------ 2 files changed, 8 insertions(+), 12 deletions(-) create mode 100644 templates/python39/shell.nix delete mode 100644 templates/venv.nix diff --git a/templates/python39/shell.nix b/templates/python39/shell.nix new file mode 100644 index 00000000..a80de335 --- /dev/null +++ b/templates/python39/shell.nix @@ -0,0 +1,8 @@ +{pkgs ? import {}, ...}: +pkgs.mkShell { + nativeBuildInputs = with pkgs; [python39 poetry git]; + shellHook = '' + [ -e .venv/bin/python3 ] && VENV_FLAG="--upgrade" || VENV_FLAG="--clear"; python3 -m venv $VENV_FLAG .venv + [ -e .venv/bin/activate ] && source .venv/bin/activate + ''; +} diff --git a/templates/venv.nix b/templates/venv.nix deleted file mode 100644 index 5eda5735..00000000 --- a/templates/venv.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ - pkgs ? import {}, - python ? pkgs.python39, - ... -}: -pkgs.mkShell { - nativeBuildInputs = with pkgs; [(python.withPackages (ps: with ps; [pip wheel])) poetry git]; - shellHook = '' - [ -d .venv ] || python -m venv .venv - source .venv/bin/activate - ''; -}