This repository provides Nix flake templates for quickly bootstrapping reproducible development environments.
Instead of copying flake.nix files around, you can now initialize new projects directly from this repo using nix flake init -- just like official Nix templates.
If you don’t already have Nix installed:
sh <(curl -L https://nixos.org/nix/install) --daemonThen enable flakes (if not already enabled):
mkdir -p ~/.config/nix
echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.confThis repository is structured as a template registry. Each subdirectory
represents a template that can be used with nix flake init.
Current templates:
python/default
From any empty project directory, run:
nix flake init -t github:shahruk10/nixshells#pythonExample:
mkdir my-ml-project
cd my-ml-project
nix flake init -t github:shahruk10/nixshells#pythonThis will generate:
flake.nix
flake.lock
.envrc
If you have direnv installed (very much recommended), the .envrc file will
direct it to automatically activate the shell defined in the flake.nix with your
development environment.
There are multiple shells defined in the python template, one without CUDA support, and one without. Enable which ever one you need. You can view the ones available by running:
nix flake showEach shell will automatically create a .venv directory and initialize a
virtual python environment there. You can install almost all python dependencies
via pip afterwards.
To modify system packages:
- Edit
flake.nix - Add or remove packages from
buildInputs - Reload the shell:
exit
nix developTo update pinned dependencies:
nix flake update- Nix Flakes: https://nixos.wiki/wiki/Flakes
- Nix Packages: https://search.nixos.org/packages
- nixGL: https://github.com/nix-community/nixGL