Restricting python version from nixpkgs

Hi

I have the following flake

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
  };

  outputs = { self, nixpkgs, ... }: 
    let
      system = "aarch64-darwin";
      pkgs = import nixpkgs {
        inherit system;
        config = {
          permittedInsecurePackages = [ "nodejs-14.21.3" "openssl-1.1.1w" ];
        };
      };    
    in 
    {
      devShells.${system}.default = pkgs.mkShell {
        buildInputs = with pkgs; [
          nodejs-14_x
        ];
      };
    };
}

when I run nix develop I get

My system python is

image

So I am guessing the flake is pulling the python from

https://search.nixos.org/packages?channel=unstable&show=python3Full&from=0&size=50&sort=relevance&type=packages&query=python3

Is it possible to filter/select nixpkgs in the flake so that an older version of python gets selected?

1 Like

There are many different versions of python 3 available on nixpkgs. Just pick one you like and put it into your buildInputs.

For instance python39 or python310.

I tried that, for example

Still complains about finding Python 3.11

Here is the source for node 14

is that maybe the problem, that the node 14 source is pulling in python3?

I’ve added an overlay to the flake

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
  };

  outputs = { self, nixpkgs, ... }: 
    let
      system = "aarch64-darwin";
      pkgs = import nixpkgs {
        inherit system;
        config = {
          permittedInsecurePackages = [ "nodejs-14.21.3" "openssl-1.1.1w" ];
        };
        overlays = [
          (final: prev: { python3 = prev.python310; })
        ];
      };    
    in 
    {
      devShells.${system}.default = pkgs.mkShell {
        buildInputs = [
          pkgs.nodejs-14_x
        ];
      };
    };
}

my system is now downloading 600mb and building 400 packages. Will report how it went.

1 Like

Ok amazingly this worked. But it seems like a overkill just to install node 14. Should I explore finding a node 14 binary on the net and specifying it as an input to my flake instead? Suggestions from someone more experienced than me? What would something like that look loke?

That appears to be the problem, yes. In my opinion that is a bug in the package. It was probably made when there was no Python 3.11 around.

However that may be, NodeJS 14 has reached end-of-life and might be dropped from nixpkgs at some undefined yet not so distant future date. So it most likely won’t get an update. See this discussion for example:

And it is flagged insecure for a reason, due to its dependency on openssl-1.1

Once it gets removed from nixpkgs you might want to pin your flake inputs to the last git commit with nodejs 14 still in it.

The problem with getting a random node binary from the web might be that you’d have to create a new nix derivation for that if you want to use them the same way, unless someone else already packaged it correctly somewhere.

If you look at the actual builder for nodejs on nixpkgs you will see that this one, too, builds the C++ from source:

Ok. Since it is about to be removed I will just install node14 the old way and revisit flakes for this project once we’ve managed to get it to a supported version of node. Thanks for the help and the time you spent on this.

1 Like