Skip to content

Instantly share code, notes, and snippets.

@Vaisakhkm2625
Last active October 12, 2023 18:29
Show Gist options
  • Save Vaisakhkm2625/0cda1d758129296d806ba543213ee8b0 to your computer and use it in GitHub Desktop.
Save Vaisakhkm2625/0cda1d758129296d806ba543213ee8b0 to your computer and use it in GitHub Desktop.
Nix dev environment python

Using pip and virtualenv

mkdir projectname
cd projectname

initating the template

nix flake init --template github:the-nix-way/dev-template#python  # this should be in bash

creating virtual env

virtualenv .

activating the virtual environment

source bin/activate

now you have a python dev enrinment in nix

Using poetry and poetry2nix as a flake

mkdir projectname
cd projectname

first get temp shell with poetry (this is for making poetry.lock file)

nix-shell -p python3 poetry --command zsh

initialze the project (answer the questions)

poetry init

generate lock file

poetry lock

exit dev shell

exit

now initate a flake with poetry2nix (use bash)

nix flake init --template templates#python

now enter the dev environment

nix develop --command zsh

now you have a python dev enrinment in nix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment