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/desktop.nix | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 nix/desktop.nix (limited to 'nix/desktop.nix') diff --git a/nix/desktop.nix b/nix/desktop.nix new file mode 100644 index 00000000..de2c8660 --- /dev/null +++ b/nix/desktop.nix @@ -0,0 +1,86 @@ +# Electron desktop app: tsc-compiled main process + the static web export, +# wrapped with nixpkgs electron (no electron-builder, no asar). +# ffmpeg-static is satisfied by nixpkgs ffmpeg. +{ + lib, + stdenvNoCC, + bun, + nodejs, + callPackage, + electron, + ffmpeg, + makeWrapper, + sources ? import ../npins, +}: + +let + bunDeps = callPackage ./bun-deps.nix { }; + web = callPackage ./web.nix { inherit sources; }; + desktopPkg = builtins.fromJSON (builtins.readFile ../apps/desktop/package.json); +in +stdenvNoCC.mkDerivation { + pname = "opencut-desktop"; + version = desktopPkg.version; + src = lib.cleanSource ../.; + + nativeBuildInputs = [ + bun + nodejs + makeWrapper + ]; + + configurePhase = '' + runHook preConfigure + cp -r ${bunDeps}/node_modules node_modules + cp -r ${bunDeps}/apps/desktop/node_modules apps/desktop/node_modules + chmod -R u+w node_modules apps/desktop/node_modules + patchShebangs node_modules apps/desktop/node_modules + runHook postConfigure + ''; + + buildPhase = '' + runHook preBuild + export HOME=$TMPDIR + cd apps/desktop + bun run build + cd $NIX_BUILD_TOP/source + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + appdir=$out/share/opencut + mkdir -p $appdir/node_modules/ffmpeg-static + cp apps/desktop/package.json $appdir/package.json + cp -r apps/desktop/dist $appdir/dist + cp -r ${web} $appdir/web + + # main.js resolves ffmpeg via require("ffmpeg-static"); point it at nixpkgs ffmpeg. + cp apps/desktop/node_modules/ffmpeg-static/index.js $appdir/node_modules/ffmpeg-static/index.js + cp apps/desktop/node_modules/ffmpeg-static/package.json $appdir/node_modules/ffmpeg-static/package.json + ln -s ${lib.getExe ffmpeg} $appdir/node_modules/ffmpeg-static/ffmpeg + + makeWrapper ${lib.getExe electron} $out/bin/opencut \ + --add-flags "$appdir" + + mkdir -p $out/share/applications + cat > $out/share/applications/opencut.desktop <