My collection of nix configurations
at main 102 lines 2.3 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 bun, 6 nodejs, 7}: 8 9let 10 version = "0.8.3"; 11 12 # Fixed-output derivation to fetch node_modules with network access 13 nodeModules = stdenv.mkDerivation { 14 name = "oh-my-opencode-slim-node-modules-${version}"; 15 16 src = fetchFromGitHub { 17 owner = "alvinunreal"; 18 repo = "oh-my-opencode-slim"; 19 rev = "v${version}"; 20 hash = "sha256-ftRtXNnuEJvzNgSHR37X9ggwWMRTbZIFc0VOm4Hd4XE="; 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 bun install --frozen-lockfile --no-progress 32 33 # Patch shebangs in node_modules before hashing 34 patchShebangs node_modules/.bin 35 ''; 36 37 installPhase = '' 38 mkdir -p $out 39 cp -r node_modules $out/ 40 ''; 41 42 outputHashMode = "recursive"; 43 outputHashAlgo = "sha256"; 44 outputHash = "sha256-1IGzAJkU//VrBdbqtwZqu5tTN+0w7wcMRgYT04F7Yvs="; 45 }; 46in 47stdenv.mkDerivation rec { 48 pname = "oh-my-opencode-slim"; 49 version = "0.8.3"; 50 51 src = fetchFromGitHub { 52 owner = "alvinunreal"; 53 repo = "oh-my-opencode-slim"; 54 rev = "v${version}"; 55 hash = "sha256-ftRtXNnuEJvzNgSHR37X9ggwWMRTbZIFc0VOm4Hd4XE="; 56 }; 57 58 nativeBuildInputs = [ 59 bun 60 nodejs 61 ]; 62 63 configurePhase = '' 64 runHook preConfigure 65 66 export HOME=$TMPDIR 67 # Copy pre-fetched node_modules 68 cp -r ${nodeModules}/node_modules . 69 chmod -R u+w node_modules 70 71 # Patch shebangs in node_modules/.bin 72 patchShebangs node_modules/.bin 73 74 runHook postConfigure 75 ''; 76 77 buildPhase = '' 78 runHook preBuild 79 80 # Run the bun build commands directly, skip tsc and schema generation 81 bun build src/index.ts --outdir dist --target bun --format esm 82 bun build src/cli/index.ts --outdir dist/cli --target bun --format esm 83 84 runHook postBuild 85 ''; 86 87 installPhase = '' 88 runHook preInstall 89 90 mkdir -p $out/lib/node_modules/${pname} 91 cp -r dist package.json $out/lib/node_modules/${pname}/ 92 cp README.md LICENSE $out/lib/node_modules/${pname}/ 2>/dev/null || true 93 94 runHook postInstall 95 ''; 96 97 meta = { 98 description = "Slim variant of oh-my-opencode plugin"; 99 homepage = "https://github.com/alvinunreal/oh-my-opencode-slim"; 100 license = lib.licenses.mit; 101 }; 102}