This only makes sense for CLI packages, not for individual Python modules.
Installing them as a part of your system packages will have no usable effect.
What I believe you actually want is a globally installed Python environment that you can use interactively?
If so what you’ll want to add is something using withPackages
into your systemPackages like so:
environment.systemPackages = [ (python3.withPackages(ps: [ ps.requests ])) ];
Overriding the nixpkgs Python set requires quite a bit of care to do it correctly, a more complete example to achieve this is:
python = pkgs.python39.override {
self = python;
packageOverrides = self: super: {
base16_colorlib = self.buildPythonPackage rec {
pname = "base16_colorlib";
format = "pyproject";
version = "0.2.0";
src = self.fetchPypi {
inherit pname version;
sha256 = "f0e0eeb50e8f9af1a00950577f6178febcf80ab2bf9bad937f9fe8068936432c";
};
doCheck = false;
nativeBuildInputs = [ self.poetry-core ];
};
};
};
This creates an overriden Python interpreter along with a package set which contains our custom package.
Note that we have moved poetry-core to nativeBuildInputs.
To incorporate this into your NixOS config would look something like:
{ pkgs, config, ... }:
let
# Create an overriden python that has our custom package
python = pkgs.python39.override {
self = python;
packageOverrides = self: super: {
base16_colorlib = self.buildPythonPackage rec {
pname = "base16_colorlib";
format = "pyproject";
version = "0.2.0";
src = self.fetchPypi {
inherit pname version;
sha256 = "f0e0eeb50e8f9af1a00950577f6178febcf80ab2bf9bad937f9fe8068936432c";
};
doCheck = false;
nativeBuildInputs = [ self.poetry-core ];
};
};
};
in
{
environment.systemPackages = [
(python.withPackages(ps: [
ps.base16_colorlib
]))
];
}