summaryrefslogtreecommitdiffhomepage
path: root/nix/node-modules.nix
diff options
context:
space:
mode:
authorAlbert O'Shea <[email protected]>2025-11-18 17:46:49 +1100
committerGitHub <[email protected]>2025-11-18 00:46:49 -0600
commit5e13527416e183c7ea6d1baa3528b5c30108372e (patch)
tree6d839be0118b84974eacc670a93823974787faba /nix/node-modules.nix
parentaba94c658f5c0987443196a5e850fdf7293d5006 (diff)
downloadopencode-5e13527416e183c7ea6d1baa3528b5c30108372e.tar.gz
opencode-5e13527416e183c7ea6d1baa3528b5c30108372e.zip
feat: nix support for the nix folks (#3924)
Co-authored-by: opencode <[email protected]> Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Diffstat (limited to 'nix/node-modules.nix')
-rw-r--r--nix/node-modules.nix52
1 files changed, 52 insertions, 0 deletions
diff --git a/nix/node-modules.nix b/nix/node-modules.nix
new file mode 100644
index 000000000..7b22ef8e7
--- /dev/null
+++ b/nix/node-modules.nix
@@ -0,0 +1,52 @@
+{ hash, lib, stdenvNoCC, bun, cacert, curl }:
+args:
+stdenvNoCC.mkDerivation {
+ pname = "opencode-node_modules";
+ version = args.version;
+ src = args.src;
+
+ impureEnvVars =
+ lib.fetchers.proxyImpureEnvVars
+ ++ [
+ "GIT_PROXY_COMMAND"
+ "SOCKS_SERVER"
+ ];
+
+ nativeBuildInputs = [ bun cacert curl ];
+
+ dontConfigure = true;
+
+ buildPhase = ''
+ runHook preBuild
+ export HOME=$(mktemp -d)
+ export BUN_INSTALL_CACHE_DIR=$(mktemp -d)
+ bun install \
+ --cpu="*" \
+ --os="*" \
+ --frozen-lockfile \
+ --ignore-scripts \
+ --no-progress \
+ --linker=isolated
+ bun --bun ${args.canonicalizeScript}
+ bun --bun ${args.normalizeBinsScript}
+ runHook postBuild
+ '';
+
+ installPhase = ''
+ runHook preInstall
+ mkdir -p $out
+ while IFS= read -r dir; do
+ rel="''${dir#./}"
+ dest="$out/$rel"
+ mkdir -p "$(dirname "$dest")"
+ cp -R "$dir" "$dest"
+ done < <(find . -type d -name node_modules -prune | sort)
+ runHook postInstall
+ '';
+
+ dontFixup = true;
+
+ outputHashAlgo = "sha256";
+ outputHashMode = "recursive";
+ outputHash = hash;
+}