getting flake to work
This commit is contained in:
parent
fec2a451c6
commit
d65f3e119f
2 changed files with 51 additions and 21 deletions
64
flake.nix
64
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
|
||||
'';
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue