From 465071d8232e74b1690280a38a86d435269fc35d Mon Sep 17 00:00:00 2001 From: cashmere Date: Thu, 30 Jul 2026 20:12:09 +0200 Subject: build: replace flake with npins, add Nix packages for web and desktop - npins pins nixpkgs-unstable + Inter font tarball; shell.nix replaces the flake devshell - nix/bun-deps.nix: fixed-output bun install of the workspace (hash tied to bun.lock) - nix/web.nix: static Next.js export; next/font/google patched to local Inter for offline builds - nix/desktop.nix: tsc-built Electron app embedding the web export, wrapped with nixpkgs electron; ffmpeg-static satisfied by nixpkgs ffmpeg --- nix/web.nix | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 nix/web.nix (limited to 'nix/web.nix') diff --git a/nix/web.nix b/nix/web.nix new file mode 100644 index 00000000..eb464a2a --- /dev/null +++ b/nix/web.nix @@ -0,0 +1,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; + }; +} -- cgit v1.3.1