With the popularity of Electron growing, there should be a standard tool for building Electron projects. There is the node2nix
project which helps with building the applications, but it doesn't know about Electron and Electron can't find the packages that node2nix
installs.
From what I can tell, the only Electron apps available in nixpkgs are Atom and nyalas-mail-bin
, and both have very long custom build commands.
Let's work to get Electron apps on NixOS! This includes VSCode, Discord, and many others!
Related to: https://github.com/NixOS/nixpkgs/issues/17073
Perhaps we can borrow from https://github.com/input-output-hk/daedalus ?
Slight aside to the main concern of electron's own challenges. This may be misguided as I only stumbled on this while looking into packaging an Electron app for use on both NixOS/macOS and lack much sense of the pressures shaping the expressions in existing packages.
I see some repetitious work in packages already producing desktop apps for both platforms, which makes me think there may be one or a few missing abstractions/patterns between mkDerivation and something I can imagine the Electron-app-builder sitting atop neatly. An Electron builder might be an ideal time to iron out those patterns/abstractions (before the current patterns spread further...), especially since I imagine Electron apps are a large share of the in-demand cross-platform GUI apps.
I came to this issue from Google looking for ways to wrap Electron apps also, and it seems like a standard that has emerged is to borrow from the libPath in atomEnv: https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/atom/env.nix
Such that one example of getting the rpath for applying patchelf on a given binary of a electron app could be done like so:
Hopefully this helps the next person searching for this.
@justinwoo Why is it called atomEnv
? Shouldn't this be electronEnv
?
Given I don't think any work has been done on in this yet, I think it's too later for this to be part of 19.09. Bumping to 20.03.
I have a similar problem, but for me it is about development of electron apps. I normally run
$ npm install
...
$ npm run build
...
$ ./node_modules/.bin/electron ./dist/main.js
in my projects, but this results in the ENOENT
error as described in my forum post.
I wonder how to work on electron projects locally, where each one may have a different version of electron
normally installed with npm install
at the root of the project.
the problem is that the npm module pulls in a binary during installation, which expects libraries and ELF loader where there aren't any, and force-building it so it gets the correct ones would take a very long time.
Electron is far from the only npm module with this problem. I wonder if we can create a wrapper that detects updated node modules at startup, and scans them for binaries that aren't using the Nix ELF loader, and patches them to use the correct loader and libraries.
For binary packages in nixpkgs there's an automatic patchelf script that does this, but no idea how to call it from outside a builder.
As for detecting updated modules, how about touching each module directory to be 1970 and then doing a quick scan on node startup for changed directories? That should catch freshly installed modules.
I would like to add a new YoutubeMusicDesktop for nixpkgs using node2nix
but I receive the error when installing electron
where it needs to use the internet on the build :/
electron-builder
with regards to properly support both linux and darwin.
Most helpful comment
Given I don't think any work has been done on in this yet, I think it's too later for this to be part of 19.09. Bumping to 20.03.