svanderburg / node2nix

Generate Nix expressions to build NPM packages
MIT License
527 stars 100 forks source link

Shell attribute not found #249

Open rocky-fuchsian-frog opened 3 years ago

rocky-fuchsian-frog commented 3 years ago

Shell Attribute Not Found

The Problem

Today I’ve been struggling to get my site up off the ground, because I need webpack with some pretty specific configuration and plugins, and I want to use nix flakes to declaratively and reproducibly manage those plugins. Once I created my package.json, I ran node2nix to no end; I was then unable to figure out how to create a simple devShell with all my packages in it that I could enter with nix develop. How do I create a flake for node2nix’s shell?

Attempted Solutions

Here’s the flake.nix file I’m using:

{
  description = "my project description";

  inputs.flake-utils.url = "github:numtide/flake-utils";

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem
      (
        system:
          let
            pkgs = nixpkgs.legacyPackages.${system};
          in
            {
              devShell = import ./shell.nix { inherit pkgs; };
            }
      );
}

and the shell.nix:

{ pkgs }: pkgs.mkShell {
  buildInputs = with pkgs;
    with nodePackages; [
      nodejs
      node2nix
      (callPackage ./default.nix {}).shell.nodeDependencies
    ];
  shellHook = ''
    export NODE_PATH=${pkgs.callPackage ./default.nix {}.shell.nodeDependencies}/lib/node_modules
  '';
}