diff --git a/flake.lock b/flake.lock index cac0248..344deab 100644 --- a/flake.lock +++ b/flake.lock @@ -2,16 +2,16 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1760580664, - "narHash": "sha256-/YdfibIrnqXAL8p5kqCU345mzpHoOtuVIkMiI2pF4Dc=", + "lastModified": 1760524057, + "narHash": "sha256-EVAqOteLBFmd7pKkb0+FIUyzTF61VKi7YmvP1tw4nEw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "98ff3f9af2684f6136c24beef08f5e2033fc5389", + "rev": "544961dfcce86422ba200ed9a0b00dd4b1486ec5", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-25.05", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index fc7c3e0..7279353 100644 --- a/flake.nix +++ b/flake.nix @@ -1,21 +1,51 @@ { - description = "Python dev environment using Nix"; + description = "A development shell for Python 3.12 with Pandas and Requests."; - inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; - - outputs = { self, nixpkgs }: let - system = "x86_64-linux"; - pkgs = import nixpkgs { inherit system; }; - in { - devShells.${system}.default = pkgs.mkShell { - packages = [ - (pkgs.python312.withPackages (ps: with ps; [ - pip - virtualenv - black - pytest - ])) - ]; - }; + # Define the inputs (dependencies) for the flake + inputs = { + # Pin nixpkgs to a specific channel (e.g., nixos-unstable) for a reproducible environment + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; }; + + # Define the outputs (what the flake provides) + outputs = { self, nixpkgs, ... }@inputs: + let + # Define the systems this flake supports + supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + + # Create a function that maps the supported systems to the nixpkgs instance + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + + # Get the packages set for all systems + pkgs = forAllSystems (system: import nixpkgs { inherit system; }); + + in + { + # Define the development shells + devShells = forAllSystems (system: { + default = pkgs.${system}.mkShell { + name = "python-312-dev-shell"; + + # 1. Select the specific Python interpreter (Python 3.12) + # 2. Use .withPackages to create an environment that includes the specified libraries + packages = [ + (pkgs.${system}.python312.withPackages (python-pkgs: with python-pkgs; [ + # Python libraries + pandas + requests + + # Optional: Add other helpful dev tools outside of the python-pkgs set if needed + # (e.g., git, pre-commit, bash-completion) + ])) + ]; + + # Optional: Define environment variables for the shell + shellHook = '' + echo "🐍 Entering Python 3.12 development environment." + echo " (Pandas and Requests are available)" + python --version + ''; + }; + }); + }; }