Closed zaiste closed 2 years ago
The issue you are having (as you correctly pointed out) is due to a valid version of Python not being supplied to the nodejs
package's nativeBuildInputs
when it is built. To fix it there is a small change to make: Currently you have specified a let
binding called buildInputs
but this doesn't seem to be evaluated anywhere and isn't doing anything. Instead, a fix is to set a python
attribute referring to a valid Python version in the callPackage
invocation (see diff).
To avoid --impure
you can specify nixpkgs
as a flake input, and then when creating the path to nodejs.nix
reference the input rather than using the NIX_PATH notation <nixpkgs>
.
Please see the diff below:
{
description = "virtual environments";
+ inputs.nixpkgs.url = "github:nixos/nixpkgs";
inputs.devshell.url = "github:numtide/devshell";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, flake-utils, devshell, nixpkgs }:
flake-utils.lib.eachDefaultSystem (system: {
devShell =
let
pkgs = import nixpkgs {
inherit system;
overlays = [ devshell.overlay ];
};
- buildInputs = with pkgs; [ python39 ];
-
- buildNodejs = pkgs.callPackage <nixpkgs/pkgs/development/web/nodejs/nodejs.nix> {};
+ buildNodejs = pkgs.callPackage "${nixpkgs}/pkgs/development/web/nodejs/nodejs.nix" {
+ python = pkgs.python39;
+ };
nodejs-8 = buildNodejs {
enableNpm = true;
version = "17.3.1";
sha256 = "cf088f7854aa78d5aef7f9bc58bdb8d7342a0197ba24af62afd2fc3233f21d1c";
};
in
pkgs.devshell.mkShell {
imports = [ (pkgs.devshell.importTOML ./devshell.toml) ];
devshell.packages = [ nodejs-8 ];
};
});
}
Thank you! It works. I'm still new to Nix, but I (slowly) start to understand how all the pieces fit together.
Is there perhaps a way to extract the function (?) signature (i.e. in this case python
) to know what could be overridden, or simply it's a matter of getting familiar with the built-in .nix
files by reading the source code?
I'm trying to build a custom Node.js version for a JS project initated with
devshell
using Flakes.Here's my current
flake.nix
:When run as
nix develop --impure
the correct Node.js version is fetched, but the command returns the following error:I've added the
buildInputs
with the correct Python version, but it doesn't seem to be taken into account.Is it possible to solve this use case with
devshell
? Is it possible to skip the--impure
flag?