fisrt push
This commit is contained in:
commit
d1f3b83a9c
74
flake.nix
Normal file
74
flake.nix
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user