My collection of nix configurations
at main 112 lines 2.5 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 bun, 6 nodejs, 7}: 8 9let 10 version = "0.2.1"; 11 12 # Fixed-output derivation to fetch node_modules with network access 13 nodeModules = stdenv.mkDerivation { 14 name = "opencode-forge-session-title-node-modules-${version}"; 15 16 src = fetchFromGitHub { 17 owner = "pedropombeiro"; 18 repo = "opencode-plugins"; 19 rev = "opencode-forge-session-title-${version}"; 20 hash = "sha256-47jQaBDfwWIEolVPABG5iH/b+A9UOrauOqMgRGOrxm8="; 21 }; 22 23 nativeBuildInputs = [ 24 bun 25 nodejs 26 ]; 27 28 buildPhase = '' 29 export HOME=$TMPDIR 30 export BUN_INSTALL_CACHE_DIR=$TMPDIR/bun-cache 31 # Install from workspace root (no --frozen-lockfile since deps are empty) 32 bun install --no-progress 33 ''; 34 35 installPhase = '' 36 mkdir -p $out 37 cp -r node_modules $out/ 38 ''; 39 40 dontFixup = true; 41 42 outputHashMode = "recursive"; 43 outputHashAlgo = "sha256"; 44 outputHash = "sha256-tKJx5j49wLvfWOyVS+rHgpjEJjrJWt5/xCZYw9erYTs="; 45 }; 46in 47stdenv.mkDerivation rec { 48 pname = "opencode-forge-session-title"; 49 inherit version; 50 51 src = fetchFromGitHub { 52 owner = "pedropombeiro"; 53 repo = "opencode-plugins"; 54 rev = "${pname}-${version}"; 55 hash = "sha256-47jQaBDfwWIEolVPABG5iH/b+A9UOrauOqMgRGOrxm8="; 56 }; 57 58 nativeBuildInputs = [ 59 bun 60 nodejs 61 ]; 62 63 postUnpack = '' 64 # Navigate into the package subdirectory 65 cd $sourceRoot/packages/forge-session-title 66 sourceRoot="." 67 ''; 68 69 configurePhase = '' 70 runHook preConfigure 71 72 export HOME=$TMPDIR 73 # Copy pre-fetched node_modules from workspace root 74 cd ../.. 75 cp -r ${nodeModules}/node_modules . 76 chmod -R u+w node_modules 77 78 # Patch shebangs 79 patchShebangs node_modules/.bin 80 81 # Go back to package directory 82 cd packages/forge-session-title 83 84 runHook postConfigure 85 ''; 86 87 buildPhase = '' 88 runHook preBuild 89 90 # Bundle the TypeScript with Bun 91 mkdir -p dist 92 bun build src/index.ts --outdir dist --target bun --format esm 93 94 runHook postBuild 95 ''; 96 97 installPhase = '' 98 runHook preInstall 99 100 mkdir -p $out/lib/node_modules/${pname} 101 cp -r dist package.json $out/lib/node_modules/${pname}/ 102 cp README.md $out/lib/node_modules/${pname}/ 2>/dev/null || true 103 104 runHook postInstall 105 ''; 106 107 meta = { 108 description = "Session title plugin for OpenCode Forge"; 109 homepage = "https://github.com/pedropombeiro/opencode-plugins"; 110 license = lib.licenses.mit; 111 }; 112}