getting flake to work
This commit is contained in:
parent
fec2a451c6
commit
d65f3e119f
2 changed files with 51 additions and 21 deletions
8
flake.lock
generated
8
flake.lock
generated
|
|
@ -2,16 +2,16 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1760580664,
|
"lastModified": 1760524057,
|
||||||
"narHash": "sha256-/YdfibIrnqXAL8p5kqCU345mzpHoOtuVIkMiI2pF4Dc=",
|
"narHash": "sha256-EVAqOteLBFmd7pKkb0+FIUyzTF61VKi7YmvP1tw4nEw=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "98ff3f9af2684f6136c24beef08f5e2033fc5389",
|
"rev": "544961dfcce86422ba200ed9a0b00dd4b1486ec5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"ref": "nixos-25.05",
|
"ref": "nixos-unstable",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
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";
|
# Define the inputs (dependencies) for the flake
|
||||||
|
inputs = {
|
||||||
outputs = { self, nixpkgs }: let
|
# Pin nixpkgs to a specific channel (e.g., nixos-unstable) for a reproducible environment
|
||||||
system = "x86_64-linux";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
pkgs = import nixpkgs { inherit system; };
|
|
||||||
in {
|
|
||||||
devShells.${system}.default = pkgs.mkShell {
|
|
||||||
packages = [
|
|
||||||
(pkgs.python312.withPackages (ps: with ps; [
|
|
||||||
pip
|
|
||||||
virtualenv
|
|
||||||
black
|
|
||||||
pytest
|
|
||||||
]))
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# 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