Node2nix issue at `import node-env.nix`: "value is a path while a set was expected"

I’m trying to build a few nodejs packages with node2nix in a flake. Most of the files are automatically generated by node2nix, and they have no problem evaluate in Nixpkgs, and I’m getting:

error: value is a path while a set was expected

       at /home/doron/repos/nixNodeJSPkgs/composition.nix:8:36:

            7| let
            8|   nodeEnv = import ./node-env.nix {
             |                                    ^
            9|     inherit (pkgs) stdenv lib python2 runCommand writeTextFile;

       … while evaluating the attribute 'buildNodePackage'

       at /home/doron/repos/nixNodeJSPkgs/node-env.nix:564:3:

          563|   buildNodeSourceDist = lib.makeOverridable buildNodeSourceDist;
          564|   buildNodePackage = lib.makeOverridable buildNodePackage;
             |   ^
          565|   buildNodeDependencies = lib.makeOverridable buildNodeDependencies;

       … while evaluating the attribute 'balena-cli.override'

       at /home/doron/repos/nixNodeJSPkgs/node-packages.nix:11085:3:

        11084| {
        11085|   balena-cli = nodeEnv.buildNodePackage {
             |   ^
        11086|     name = "balena-cli";

I have in flake.nix:

        packages = import ./default.nix {
          inherit pkgs;
          stdenv = pkgs.stdenv;
          lib = pkgs.lib;
          nodejs = pkgs.nodejs-12_x;

And default.nix is based on what’s in Nixpkgs’ node-packages/default.nix:

{ pkgs ? <nixpkgs>, nodejs ? pkgs.nodejs-12_x, stdenv ? pkgs.stdenv, lib ? pkgs.lib }:

  since = (version: pkgs.lib.versionAtLeast nodejs.version version);
  before = (version: pkgs.lib.versionOlder nodejs.version version);
  super = import ./composition.nix {
    inherit pkgs nodejs;
    inherit (stdenv.hostPlatform) system;
  self = super // {
    balena-cli = super.balena-cli.override {
      buildInputs = [ self.node-pre-gyp self.node-gyp-build ];
      meta = super.balena-cli.meta // {
        maintainers = with lib.maintainers; [ doronbehar ];
in self

The full repository is at: GitHub - doronbehar/nixNodeJSPkgs

I also noticed there’s an old Nix issue related at: error "value is a list while a set was expected" is too vague · Issue #963 · NixOS/nix · GitHub

iirc, I had to call into a kinda arbitrary place to build a flake with node2nix. Let me go check what I did.

Edit: Okay, I think I basically replaced default.nix in my implementation with flake vars, and got it to work. will see if I can post some of it.

I got something like this for the outputs to work:

flake-utils.lib.eachDefaultSystem (system:
    pkgs = nixpkgs.legacyPackages.${system};
    nodejs = pkgs.nodejs;
    nodeEnv = import ./node-env.nix {
      inherit (pkgs) stdenv lib python2 runCommand writeTextFile;
      inherit pkgs nodejs;
      libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
    nodePkgs = import ./node-packages.nix {
      inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
      inherit nodeEnv;
    args = nodePkgs.args // {
      postInstall = ''
        npm run build
        find ./ -maxdepth 1 -type f -delete
        rm -rf $(find ./ -maxdepth 1 -type d -not -name "dist" -not -name '.' -not -name ..')
      devShell =  pkgs.mkShell {
        nativeBuildInputs = with pkgs; [
           # Insert Packages
      packages.testPackage = nodeEnv.buildNodePackage args;

Edit: now why this works, I need to look at the default.nix and stuff to remember. The “find” and “rm” statements in the args were because I was building a static VUE site and so didn’t want anything but the static pages.

Edit 2: rec not needed since I didn’t include the defaultPackage statement.

1 Like

Interesting… I don’t know what is really the issue, but I learned thanks to your suggestion, that:

nix build -Lf. packageName


nix build -L .#packageName

Is not the same thing. The 1st command reads only default.nix, and the 2nd command reads flake.nix. Putting the contents of default.nix inside flake.nix made me realize this. I think this can lead to the source of the issue. Thanks!

1 Like

Glad I could help. I don’t see the issue in your code personally either, looking through everything, but it does look like it should work. Let me know if you figure out what’s causing it please.