Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 124 lines 2.8 kB view raw
1{ 2 lib, 3 stdenvNoCC, 4 bun, 5 fetchFromGitHub, 6 nix-update-script, 7 writableTmpDirAsHomeHook, 8}: 9 10let 11 models-dev-node-modules-hash = { 12 "aarch64-darwin" = "sha256-099Y+7cLtSQ0s71vxUGEochQSpCv1hbkwYbWx/eOvhY="; 13 "aarch64-linux" = "sha256-fOmp7UyszqpR04f5TW0pU96IO7euaxX9fBMtwoqIMY4="; 14 "x86_64-darwin" = "sha256-OsJDPCsEAAcXzgI/QrtfXXb2jc82pp6ldHuA4Ps8OpM="; 15 "x86_64-linux" = "sha256-Enx27ag7D0Qeb/ss/7zTQ1XSukyPzOMMK7pTYHqQUMs="; 16 }; 17in 18stdenvNoCC.mkDerivation (finalAttrs: { 19 pname = "models-dev"; 20 version = "0-unstable-2025-08-01"; 21 src = fetchFromGitHub { 22 owner = "sst"; 23 repo = "models.dev"; 24 rev = "2e3f718c40e8868c2487b7275131b2e054feb462"; 25 hash = "sha256-P7Q03I68ih2eKNfPkpzkIuvKcHLsrk8yxWbFCw74Pjg="; 26 }; 27 28 node_modules = stdenvNoCC.mkDerivation { 29 pname = "models-dev-node_modules"; 30 inherit (finalAttrs) version src; 31 32 impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [ 33 "GIT_PROXY_COMMAND" 34 "SOCKS_SERVER" 35 ]; 36 37 nativeBuildInputs = [ 38 bun 39 writableTmpDirAsHomeHook 40 ]; 41 42 dontConfigure = true; 43 44 buildPhase = '' 45 runHook preBuild 46 47 export BUN_INSTALL_CACHE_DIR=$(mktemp -d) 48 49 bun install \ 50 --force \ 51 --frozen-lockfile \ 52 --no-progress 53 54 runHook postBuild 55 ''; 56 57 installPhase = '' 58 runHook preInstall 59 60 mkdir -p $out/node_modules 61 cp -R ./node_modules $out 62 63 runHook postInstall 64 ''; 65 66 # Required else we get errors that our fixed-output derivation references store paths 67 dontFixup = true; 68 69 outputHash = models-dev-node-modules-hash.${stdenvNoCC.hostPlatform.system}; 70 outputHashAlgo = "sha256"; 71 outputHashMode = "recursive"; 72 }; 73 74 nativeBuildInputs = [ bun ]; 75 76 patches = [ 77 # In bun 1.2.13 (release-25.05) HTML entrypoints get content hashes 78 # appended → index.html becomes index-pq8vj7za.html in ./dist. So, we 79 # rename the index file back to index.html 80 ./post-build-rename-index-file.patch 81 ]; 82 83 configurePhase = '' 84 runHook preConfigure 85 86 cp -R ${finalAttrs.node_modules}/node_modules . 87 88 runHook postConfigure 89 ''; 90 91 preBuild = '' 92 patchShebangs packages/web/script/build.ts 93 ''; 94 95 buildPhase = '' 96 runHook preBuild 97 98 cd packages/web 99 bun run build 100 101 runHook postBuild 102 ''; 103 104 installPhase = '' 105 runHook preInstall 106 107 mkdir -p $out/dist 108 cp -R ./dist $out 109 110 runHook postInstall 111 ''; 112 113 passthru.updateScript = nix-update-script { 114 extraArgs = [ "--version=branch" ]; 115 }; 116 117 meta = { 118 description = "Comprehensive open-source database of AI model specifications, pricing, and capabilities"; 119 homepage = "https://github.com/sst/models-dev"; 120 license = lib.licenses.mit; 121 platforms = lib.platforms.unix; 122 maintainers = with lib.maintainers; [ delafthi ]; 123 }; 124})