nix.dev
nix.dev copied to clipboard
Guide on packaging stuff that doesn't fit into Nix model (steam, electron)
Here's an example of packaging Sabaki, an Electron app for Go (the game). This runs 100% inside of an fhsUserEnv.
https://github.com/savannidgerinel/nix-shell/blob/sol/sabaki/default.nix
It has one mysterious bug in that disk access causes the app to crash if I launch the app from dmenu. No problems at all if I launch the app from the command line.
Electron has a lot of explicit requirements, and one implicit requirement on udev and libudev. Generally it will crash with a sigtrap if either is missing.
@savannidgerinel how do you then run it inside fhsUserEnv?
oof you're right, this isn't an fhsUserEnv :(. I'm sorry, I mis-remembered how I bundled Sabaki. It is an Electron app, but patchElf is sufficient to make it work.
Apparently I only use fhsUserEnv when I'm running development shell environments where I have to all Electron directly. For that I posted a question and answer to the Discourse a while back: https://discourse.nixos.org/t/unexpected-sigtrap-when-running-electron/7864 . As such, my comments may not be applicable to this in particular.
I am trying to figure out a derivation that wraps, for instance, a copy of electron that I downloaded manually, or a copy of electron that gets installed with npm. It looks like this, but actually running it gives me a SIGTRAP and a core dump with no backtrace information:
let rpath = pkgs.stdenv.lib.makeLibraryPath [ ... lots of libraries ... ]
script = pkgs.writeScript "electron" ''
#!${pkgs.bash}/bin/bash
export LD_LIBRARY_PATH=$PWD:${rpath}
${pkgs.stdenv.cc.bintools.dynamicLinker} $NODE_PATH/electron/dist/electron
'';
in pkgs.stdenv.mkDerivation {
name = "electron_wrapper";
src = script;
dontUnpack = true;
dontBuild = true;
installPhase = ''
mkdir -p $out/bin
cp $src $out/bin/electron
'';
};