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