Hi all,
I’ve recently started my Nix journey and am looking for some advice. I’ve managed to prepare a flake that provides a Python development environment with a Python package not in Nixpkgs, matplotlib-set-diagrams:
{
description = "A Python development environment for Linux";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
outputs = { nixpkgs, ... }: let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
python = pkgs.python312.withPackages (ps: with ps; [
buildPythonPackage rec {
pname = "matplotlib_set_diagrams";
version = "0.0.2";
src = fetchPypi {
inherit pname version;
sha256 = "sha256-CdkFSoVThCO1k7ZpjAVoBjxpbWvvT3etAajC4OGjVA0=";
};
doCheck = false;
format = "pyproject";
nativeBuildInputs = [ setuptools ];
propagatedBuildInputs = [
numpy
scipy
matplotlib
shapely
wordcloud
];
}
]);
in {
devShells."${system}".default = pkgs.mkShell {
packages = [
pkgs.black
pkgs.python312Packages.matplotlib
pkgs.python312Packages.numpy
python
];
};
};
}
However, it feels like a clunky way to do it. I’d rather define matplotlib-set-diagrams separately from the Python package itself and list it as a package similarly to how the Nixpkg ones work (eg numpy), but I can’t figure out how to do that.
Can anyone recommend a better way to write this flake, either along the lines I’m thinking, or a different approach that you have?