blob: eb464a2a5e6f0bfdc822a429521f7cbc74a8e24d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# Static export of the Next.js web app (apps/web/out).
# Deps come from the bun-deps FOD; the Google-font fetch in next/font is
# replaced by the npins-pinned Inter so the build runs offline.
{
lib,
stdenvNoCC,
bun,
nodejs,
callPackage,
sources ? import ../npins,
}:
let
bunDeps = callPackage ./bun-deps.nix { };
webPkg = builtins.fromJSON (builtins.readFile ../apps/web/package.json);
in
stdenvNoCC.mkDerivation {
pname = "opencut-web";
version = webPkg.version;
src = lib.cleanSource ../.;
nativeBuildInputs = [
bun
nodejs
];
postPatch = ''
mkdir -p apps/web/public/fonts
cp ${sources.inter}/web/InterVariable.woff2 apps/web/public/fonts/InterVariable.woff2
substituteInPlace apps/web/src/app/layout.tsx \
--replace-fail 'import { Inter } from "next/font/google";' 'import localFont from "next/font/local";' \
--replace-fail 'const siteFont = Inter({ subsets: ["latin"] });' 'const siteFont = localFont({ src: "../../public/fonts/InterVariable.woff2" });'
'';
configurePhase = ''
runHook preConfigure
cp -r ${bunDeps}/node_modules node_modules
cp -r ${bunDeps}/apps/web/node_modules apps/web/node_modules
chmod -R u+w node_modules apps/web/node_modules
patchShebangs node_modules apps/web/node_modules
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
export HOME=$TMPDIR
export NEXT_TELEMETRY_DISABLED=1
export NODE_ENV=production
cd apps/web
bun run build
runHook postBuild
'';
installPhase = ''
runHook preInstall
cp -r out $out
runHook postInstall
'';
meta = {
description = "OpenCut web app (static export)";
license = lib.licenses.mit;
};
}
|