Hi all!
Have you ever wanted to use a specific version of Python using Nix?
Supports all Python versions from 2.7.6 to the latest 3.11.3, updated hourly.
Hi all!
Have you ever wanted to use a specific version of Python using Nix?
Supports all Python versions from 2.7.6 to the latest 3.11.3, updated hourly.
Is it possible to specify which pip packages should be included in the installation?
Took me a moment to digest that flake.nix
, but it just builds the nixpkgs python package with a bunch of overrides for each version of python applied.
In other words, @kzvi, yes - unless I’m very mistaken.
@domenkozar in fact modularized the upstream python definitions to fully accept building various versions, including the passthrus, which include the withPackages
function: https://github.com/domenkozar/nixpkgs/blob/b19f607a1b1d36a02741cf3aefe674bd3848fcf6/pkgs/development/interpreters/python/passthrufun.nix#L86
This is very cool I don’t think it caches pip packages, though, so you’ll need to “build” those downstream?
Exactly.
You can see how I install packages using pip in nixpkgs-python devenv.nix.
you gave some example using flake on your readme, how could i create a simple nix file instead using it? Could you give me an example, please?
Perhaps something like this, depending on how you want to use it:
$ nix-shell
bash-5.2$ python2.7
Python 2.7.18 (default, Jul 12 2023, 15:16:47)
[GCC Clang 11.1.0] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print "statements omg"
statements omg
>>>
bash-5.2$ cat shell.nix
let
pkgs = (import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-23.05.tar.gz") { });
nixpkgs-python = import (fetchTarball "https://github.com/cachix/nixpkgs-python/archive/refs/heads/main.zip");
in
pkgs.mkShell {
buildInputs = [
(nixpkgs-python.packages.aarch64-darwin."2.7")
];
}
bash-5.2$
FYI I added the link to the nixos wiki (in the first section aswell as in the “See also”). Hope that’s fine/correct.