# flake.nix { description = "A Python development environment"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11"; # Pin to the nixos-25.11 channel flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; # Define Python version and packages pythonVersion = "python311"; # You can change this to python310, python312, etc. pythonPackages = ps: with ps; [ # Core Python pkgs.${pythonVersion} # Common development tools pip setuptools wheel # Example useful packages (uncomment and add as needed) # black # Code formatter # ruff # Fast Python linter # mypy # Static type checker # ipython # Enhanced interactive Python shell # venvwrapper # Virtual environment manager (can be useful even with Nix) ]; in { devShells.default = pkgs.mkShell { name = "python-dev-shell"; packages = pythonPackages pkgs; # Environment variables you might want to set shellHook = '' echo "Welcome to the Python development shell!" export PATH="$HOME/.local/bin:$PATH" # Example: if you install packages globally via pip (not recommended with Nix) # If you are using a specific Python version managed by Nix, you might # want to ensure it's in your PATH. The above `packages` should handle this. # You can also set up virtual environments here if you prefer, # although Nix aims to manage dependencies directly. # Example: using venvwrapper if installed # if [ -f "$(command -v venvwrapper.sh)" ]; then # export WORKON_HOME=$HOME/.virtualenvs # source $(command -v venvwrapper.sh) # fi ''; }; } ); }