Hi fellow people,
I was trying out different options managing python environments. For now I am using a flake based on GitHub - kemalmao19/devShell: Dev environment with flake.nix.
However I changed my flake so the python packages are not declared in packages = [ ]
and rather in buildInputs = [ ]
.
This is because otherwise the lsp of helix editor would not work.
Here is my flake:
#
# thanks to:
# https://github.com/kemalmao19/devShell/tree/main
# for inspiration
#
{
description = "This is my python dev: Data Science Libraries Edition";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs, }:
let
# Systems supported
allSystems = [
"x86_64-linux" # 64-bit Intel/AMD Linux
"aarch64-linux" # 64-bit ARM Linux
"x86_64-darwin" # 64-bit Intel macOS
"aarch64-darwin" # 64-bit ARM macOS
];
# Helper to provide system-specific attributes
forAllSystems = f:
nixpkgs.lib.genAttrs allSystems
(system: f { pkgs = import nixpkgs { inherit system; }; });
in {
# Development environment output
devShells = forAllSystems ({ pkgs }: {
default = let
# pint-pandas
# Add units to pandas
# This is fetched directly from pypi because version in nixpkgs is outdated
pint-pandas = with pkgs.python311Packages; buildPythonPackage rec {
pname = "Pint-Pandas";
version = "0.5";
format = "pyproject";
src = fetchPypi {
inherit pname version;
sha256 = "SOyW1Ff4AqNHdj3uHT4aJz8R+Q5OWV3xf9RGE90Uphw=";
};
doCheck = false;
nativeBuildInputs = [
setuptools
setuptools-scm
wheel
];
propagateBuildInputs = [
pint
pandas
];
};
in pkgs.mkShell {
buildInputs = (with pkgs.python311Packages; [
matplotlib
toml
pvlib
pandas
pint
]) ++ ([
pint-pandas
]);
};
});
};
}
And everything seems to work. Is there some danger in putting the python packages into buildInputs instead of packages?