From a2469870cea5e861b18685e6915c5782433bd5a1 Mon Sep 17 00:00:00 2001 From: Seungheon Oh Date: Fri, 17 Mar 2023 18:22:09 -0500 Subject: [PATCH] Support npm submodules --- nix/default.nix | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nix/default.nix b/nix/default.nix index 9d364cef1b..b3ea09a2a0 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -20,6 +20,8 @@ , spagoPackages ? "${src}/spago-packages.nix" # Configuration that will be used to generate a `devShell` for the project , shell ? { } + # Path to submodule locations that needs to be copied when making node env +, submodules ? [ ] , ... }: let @@ -36,8 +38,15 @@ let } '' mkdir $out cd $out - cp ${packageLock} ./package-lock.json - cp ${packageJson} ./package.json + cp ${ + pkgs.linkFarm "node-packages-${projectName}-source" ([ + { name = "package.json"; path = packageJson; } + { name = "package-lock.json"; path = packageLock; } + ] ++ builtins.map (path: { + inherit path; + name = builtins.baseNameOf (builtins.toString modulePath); + })) + }/* . -r node2nix ${pkgs.lib.optionalString withDevDeps "--development" } \ --lock ./package-lock.json -i ./package.json '')