Hi lovely NixOS community,
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? Is there a better way than node2nix to pull in npm packages to my project?
1 Like
Little bit of context and specificity here. The attached nix shell, when run under nix develop
, should give me my dependencies, but instead:
error: attribute 'shell' missing
at /nix/store/cwfpc09sbb3d0l08svlas55nlincg413-source/shell.nix:6:7:
5| node2nix
6| (callPackage ./default.nix {}).shell.nodeDependencies
| ^
7| ];
(use '--show-trace' to show detailed location information)
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
'';
}
Here’s the thing about that: I know that will theoretically work, but I need to be able to pull in arbitrary dependencies with node2nix.
Sorry my bad, how about this example logseq-nix-flake/dev-shell.nix at 4da67d351e7420f176a62c26b97840332292c965 · GTrunSec/logseq-nix-flake · GitHub
@rocky_fuchsian_frog , For the node2nix shell make sure you have got these exprs like nixpkgs/node-packages.nix at master · NixOS/nixpkgs · GitHub