Just found out that that via the 15.19.1.2.1. Python library packages in Nixpkgs chapter in the Nixpkgs manual that the results of the following shell.nix
scripts when called with nix-shell
are the same:
-
using mkShell
:
{ pkgs ? import <nixpkgs> {} }:
let
pythonEnv =
pkgs.python38.withPackages (
packages:
[ packages.django
packages.psycopg2
]
);
in
pkgs.mkShell {
buildInputs = [
pythonEnv
];
}
-
using (...).env
{ pkgs ? import <nixpkgs> {} }:
(
pkgs.python38.withPackages (
packages:
[ packages.django
packages.psycopg2
]
)
).env
What is the env
attribute? Is it a general one or specific to the result of Pyhon packages?
In this case, it’s a byproduct of using withPackages
(and, more specifically, because withPackages
in turn uses buildEnv
. It isn’t quite general, but (without confirming) I would guess that the other language ecosystems that have withPackages/buildEnv functions have the same attribute.
I’m not sure if there’s a lengthier description somewhere, but I found a reference to this a few sections later:
…
As python.withPackages
simply uses python.buildEnv
under the hood, it also supports the env
attribute. The shell.nix
file from the previous section can thus be also written like this:
1 Like
Thanks! I didn’t read below the 15.19.2. Reference section which was obviously a mistake…