commit d1f3b83a9c07c217c09d1f9c97b951eb45e341f6 Author: Arthur Wambst Date: Tue May 6 12:22:23 2025 +0200 fisrt push diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..4d92e60 --- /dev/null +++ b/flake.nix @@ -0,0 +1,74 @@ +{ + description = "Reusable Python development environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + + # Python version configuration - easy to change in one place + pythonVersion = pkgs.python311; + + # Define Python packages in a separate variable for clarity + pythonPackages = ps: with ps; [ + # Data science + numpy + pandas + matplotlib + scipy + + # Web and networking + requests + httpx + beautifulsoup4 + + # Development tools + black + pylint + pytest + ipython + + # Add more packages as needed + ]; + + # Create the Python environment with the specified packages + pythonEnv = pythonVersion.withPackages pythonPackages; + in + { + # Development shell for interactive use + devShells.default = pkgs.mkShell { + buildInputs = [ + pythonEnv + pkgs.poetry + pkgs.git + ]; + + shellHook = '' + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo "🐍 Python $(${pythonVersion}/bin/python --version)" + echo "📦 Poetry $(${pkgs.poetry}/bin/poetry --version)" + echo "📂 Working directory: $(pwd)" + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + ''; + }; + + # Make the Python environment available as a package + packages.default = pythonEnv; + + # Add an app that runs Python directly + apps.default = flake-utils.lib.mkApp { + drv = pythonEnv; + name = "python"; + exePath = "/bin/python"; + }; + + # Add formatter for consistent Nix code formatting + formatter = pkgs.nixpkgs-fmt; + } + ); +}