1{
2 lib,
3 stdenv,
4 deno,
5 nodejs,
6 makeBinaryWrapper,
7 gazesys-modules,
8 PUBLIC_BASE_URL ? "http://localhost:5173",
9}:
10stdenv.mkDerivation {
11 name = "gazesys-website";
12
13 src = lib.fileset.toSource {
14 root = ../.;
15 fileset = lib.fileset.unions [
16 ../src
17 ../static
18 ../deno.lock
19 ../package.json
20 ../postcss.config.js
21 ../svelte.config.js
22 ../tailwind.config.js
23 ../tsconfig.json
24 ../vite.config.ts
25 ];
26 };
27
28 nativeBuildInputs = [makeBinaryWrapper];
29 buildInputs = [deno];
30
31 inherit PUBLIC_BASE_URL;
32
33 dontCheck = true;
34
35 configurePhase = ''
36 runHook preConfigure
37 cp -R --no-preserve=ownership ${gazesys-modules} node_modules
38 find node_modules -type d -exec chmod 755 {} \;
39 substituteInPlace node_modules/.bin/vite \
40 --replace-fail "/usr/bin/env node" "${nodejs}/bin/node"
41 runHook postConfigure
42 '';
43 buildPhase = ''
44 runHook preBuild
45 HOME=$TMPDIR deno run --cached-only build
46 runHook postBuild
47 '';
48 installPhase = ''
49 runHook preInstall
50
51 mkdir -p $out/bin
52 cp -R ./build/* $out
53 cp -R ./node_modules $out
54
55 makeBinaryWrapper ${deno}/bin/deno $out/bin/website \
56 --prefix PATH : ${lib.makeBinPath [ deno ]} \
57 --add-flags "run --allow-all --node-modules-dir=manual --cached-only $out/index.js"
58
59 runHook postInstall
60 '';
61}