summary refs log tree commit diff
diff options
context:
space:
mode:
authorAshelyn Rose <git@ashen.earth>2024-08-20 18:49:12 -0600
committerAshelyn Rose <git@ashen.earth>2024-08-21 23:47:47 -0600
commit43ed4adce7729ede3e2478b6518aa7014f068bff (patch)
treebf57b1b2295d25ee5444a5ded07a6d717c9fd51f
parent33732baede87256ee9d50fb3ca8cb77a1d69c3ce (diff)
Fix issue with missing dependency
-rw-r--r--flake.nix28
1 files changed, 20 insertions, 8 deletions
diff --git a/flake.nix b/flake.nix
index 3e8b340..f514cc6 100644
--- a/flake.nix
+++ b/flake.nix
@@ -31,13 +31,15 @@
 
       packageLock = builtins.fromJSON(builtins.readFile (src + "/package-lock.json"));
 
-      deps = builtins.attrValues (removeAttrs packageLock.packages [ "" ])
-        ++ builtins.attrValues (removeAttrs (packageLock.dependencies or {} ) [ "" ])
-      ;
-      tarballs = map (p: pkgs.fetchurl { url = p.resolved; hash = p.integrity; }) deps;
+      deps = builtins.attrValues (removeAttrs packageLock.packages [ "" ]);
+      depTarballs = map (p: pkgs.fetchurl { url = p.resolved; hash = p.integrity; }) deps;
+      nodeTarball = pkgs.fetchurl {
+        url = "https://nodejs.org/download/release/v20.2.0/node-v20.2.0-headers.tar.gz";
+        hash = "sha256-GxkJoXnN/35mTQXnivQAa942T07t5hTCr4C6j0C3a/k=";
+      };
       tarballsFile = pkgs.writeTextFile {
         name = "tarballs";
-        text = builtins.concatStringsSep "\n" tarballs;
+        text = (builtins.concatStringsSep "\n" depTarballs) + "\n";
       };
 
       tempestdev_modules = pkgs.stdenv.mkDerivation {
@@ -45,23 +47,33 @@
 
         name = "tempestdevnode_modules";
 
-        buildInputs = [ nodejs ];
+        nativeBuildInputs = [ 
+          nodejs
+          pkgs.nodePackages.node-gyp
+          pkgs.vips 
+          pkgs.pkg-config
+          pkgs.python3
+        ];
 
         buildPhase = ''
           export HOME=$PWD/.home
           export npm_config_cache=$PWD/.npm
 
+          echo "Caching Node headers"
+          ${pkgs.nodePackages.node-gyp}/bin/node-gyp install v20.2.0 --tarball=${nodeTarball}
+
+          echo "Caching NPM dependencies"
           while read package
           do
-            echo "caching $(echo $package | sed 's/\/nix\/store\/[^-]*-//')"
             npm cache add "$package"
           done <${tarballsFile}
 
-          ${nodejs}/bin/npm --cache-min 99999999 ci --no-registry
+          ${nodejs}/bin/npm --offline ci --no-registry
         '';
 
         installPhase = ''
           mkdir $out
+          sed --in-place 's|/usr/bin/env node|${nodejs}/bin/node|' ./node_modules/next/dist/bin/next
           mv node_modules $out/node_modules
         '';
       };