64cdc0dd3c
Reproducible development environment for NixOS/Nix contributors: - Dev shell with Node 22, system Electron, Playwright, LD_LIBRARY_PATH for X11/Wayland/audio libs, activated automatically via direnv - buildNpmPackage derivation wrapping system Electron with desktop file and hicolor icons - NixOS module (programs.openscreen.enable) with xdg-desktop-portal - Home Manager module for per-user installation - Overlay for composing with other flakes Tested: nix flake show, nix develop, nix build, nixos-rebuild switch
131 lines
3.4 KiB
Nix
131 lines
3.4 KiB
Nix
{
|
|
lib,
|
|
buildNpmPackage,
|
|
nodejs_22,
|
|
electron,
|
|
makeWrapper,
|
|
makeDesktopItem,
|
|
copyDesktopItems,
|
|
}:
|
|
|
|
buildNpmPackage {
|
|
nodejs = nodejs_22;
|
|
pname = "openscreen";
|
|
version = "1.3.0";
|
|
|
|
src =
|
|
let
|
|
fs = lib.fileset;
|
|
maybe = fs.maybeMissing;
|
|
in
|
|
fs.toSource {
|
|
root = ../.;
|
|
fileset = fs.difference ../. (
|
|
fs.unions [
|
|
../nix
|
|
../flake.nix
|
|
../flake.lock
|
|
(maybe ../release)
|
|
(maybe ../test-results)
|
|
(maybe ../playwright-report)
|
|
(maybe ../.github)
|
|
(maybe ../.vscode)
|
|
(maybe ../.idea)
|
|
(maybe ../.kiro)
|
|
(maybe ../.envrc)
|
|
(maybe ../.direnv)
|
|
(fs.fileFilter (file: file.hasExt "md") ../.)
|
|
]
|
|
);
|
|
};
|
|
|
|
npmDepsHash = "sha256-Pd6J9TuggA9vM4s/LjdoK4MoBEivSzAWc/G2+pFOM2U=";
|
|
|
|
env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
|
|
|
|
# electron-builder is not needed — we wrap system electron directly
|
|
npmFlags = [ "--ignore-scripts" ];
|
|
makeCacheWritable = true;
|
|
|
|
# vite-plugin-electron compiles electron/ sources into dist-electron/
|
|
# tsconfig has noEmit — tsc is type-check only
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
npx vite build
|
|
runHook postBuild
|
|
'';
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
mkdir -p "$out/lib/openscreen"
|
|
|
|
# Renderer build output (index.html, JS chunks, copied public/ assets)
|
|
cp -r dist "$out/lib/openscreen/"
|
|
|
|
# Main process + preload (compiled by vite-plugin-electron)
|
|
cp -r dist-electron "$out/lib/openscreen/"
|
|
|
|
# Package manifest (electron reads "main" field to find entry point)
|
|
cp package.json "$out/lib/openscreen/"
|
|
|
|
# Strip devDependencies (electron, vitest, biome, playwright, etc.)
|
|
npm prune --omit=dev --no-save
|
|
cp -r node_modules "$out/lib/openscreen/"
|
|
|
|
# Asset resolution: when app.isPackaged is false, the main process resolves
|
|
# assets at <appPath>/public/assets/. Mirror the electron-builder
|
|
# extraResources layout so wallpapers load correctly.
|
|
mkdir -p "$out/lib/openscreen/public/assets"
|
|
cp -r public/wallpapers "$out/lib/openscreen/public/assets/wallpapers"
|
|
|
|
# Wrap system electron with the app directory
|
|
mkdir -p "$out/bin"
|
|
makeWrapper "${electron}/bin/electron" "$out/bin/openscreen" \
|
|
--add-flags "$out/lib/openscreen" \
|
|
--set ELECTRON_IS_DEV 0
|
|
|
|
# Install icons to hicolor theme
|
|
for size in 16 24 32 48 64 128 256 512 1024; do
|
|
icon="icons/icons/png/''${size}x''${size}.png"
|
|
if [ -f "$icon" ]; then
|
|
install -Dm644 "$icon" \
|
|
"$out/share/icons/hicolor/''${size}x''${size}/apps/openscreen.png"
|
|
fi
|
|
done
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
nativeBuildInputs = [
|
|
makeWrapper
|
|
copyDesktopItems
|
|
];
|
|
|
|
desktopItems = [
|
|
(makeDesktopItem {
|
|
name = "openscreen";
|
|
desktopName = "OpenScreen";
|
|
genericName = "Screen Recorder";
|
|
exec = "openscreen %U";
|
|
icon = "openscreen";
|
|
comment = "Desktop screen recorder with built-in editor";
|
|
categories = [
|
|
"AudioVideo"
|
|
"Video"
|
|
"Recorder"
|
|
];
|
|
startupWMClass = "Openscreen";
|
|
terminal = false;
|
|
})
|
|
];
|
|
|
|
meta = {
|
|
description = "Desktop screen recorder with built-in editor";
|
|
homepage = "https://github.com/siddharthvaddem/openscreen";
|
|
license = lib.licenses.mit;
|
|
mainProgram = "openscreen";
|
|
platforms = lib.platforms.linux;
|
|
};
|
|
}
|