Skip to content

fix: nix dev shell can now run make targets (move away from FHS)#19

Merged
jagrat7 merged 4 commits intojagrat7:mainfrom
RainAfterDark:fix/nix-shell
Mar 20, 2026
Merged

fix: nix dev shell can now run make targets (move away from FHS)#19
jagrat7 merged 4 commits intojagrat7:mainfrom
RainAfterDark:fix/nix-shell

Conversation

@RainAfterDark
Copy link
Copy Markdown
Collaborator

Using an FHS env for the Nix shell was a quick and easy way to get around Nix's non-FHS compliance but it caused sandboxing issues; namely, the flatpak make target just silently fails to build. I decided to take more time to just use mkShell, and patch some things around to get electron and RPM to work nicely. Now, all electron-forge make targets compile on Nix, without FHS! (At least, on my end)

✔ Making distributables
  ✔ Making a zip distributable for linux/x64 [40s]
  ✔ Making a deb distributable for linux/x64 [40s]
  ✔ Making a rpm distributable for linux/x64 [1m31s]
  ✔ Making a flatpak distributable for linux/x64 [4m8s]

I also confirmed that the zip and flatpak builds do work. For deb and rpm, I had to use distrobox. The app does open, but I just couldn't get the linux-wallpaperengine backend to compile due to some dynamic library issues, but I'll assume the generated artifacts for the app are correct.

Also full disclosure that the RPM workaround in here went through some iterative prompting. I at least tried to leave the AI's thought process behind it. The wrappers aren't that complicated but I'll have to admit that I had to rely on a lot of help since I'm unfamiliar with how Fedora's packaging works (and how forge does their magic with it in the maker).

Do let me know if this plays better on your end (non-NixOS running Nix).

- move away from buildFHSEnv
- impl workaround for RPM
- no longer need to inject electron runtime libs
One use case is to use a more latest version of linux-wallpaperengine than the one in nixpkgs
@jagrat7 jagrat7 self-requested a review March 20, 2026 06:28
@jagrat7
Copy link
Copy Markdown
Owner

jagrat7 commented Mar 20, 2026

I tried to launch through the sandbox but i kept running into errors, here a summary of what claude tried

1. nix develop --command is broken by the shellHook

The userShell block in shell.nix unconditionally spawns a user shell and then calls exit, which kills the session before --command gets a chance to run. This also breaks nix develop entirely when the spawned shell exits immediately (e.g. non-interactive contexts).

The fix is to only spawn the user shell in interactive mode:

if [[ $- == *i* ]]; then
  # ... detect and spawn user shell
fi

2. Nix-patched Electron doesn't work on non-NixOS distros

The Electron binary from nixpkgs is patched with NixOS-specific RPATH — it looks for GPU drivers at /run/opengl-driver/ which doesn't exist on other distros. This causes:

MESA-LOADER: failed to open dri: /run/opengl-driver/lib/gbm/dri_gbm.so
Initialization of all EGL display types failed.
Exiting GPU process due to errors during initialization

I tried:

  • ELECTRON_EXTRA_LAUNCH_ARGS="--disable-gpu" — Electron launches but window never appears
  • LIBGL_ALWAYS_SOFTWARE=1 — same result
  • --ozone-platform=wayland — same result
  • app.disableHardwareAcceleration() in main.ts — still fails with libdrm.so.2: cannot open shared object file
  • Symlinking host GPU libs (libEGL, libGL, libGLX, libGLESv2, libgbm, libvulkan, libdrm, etc.) into a temp dir and setting LD_LIBRARY_PATH + LIBGL_DRIVERS_PATH — partially works but keeps hitting missing libraries

The core issue is that nix's Electron is built against NixOS's library layout and can't resolve the host system's GPU stack. This would need something like nixGL to properly wrap the Electron binary on non-NixOS systems.

The dev shell currently only works on NixOS. Would be good to either document this limitation or integrate nixGL for non-NixOS support.

@jagrat7
Copy link
Copy Markdown
Owner

jagrat7 commented Mar 20, 2026

Going to merge it for now because i want to make some big refactors

@jagrat7 jagrat7 merged commit 0b28795 into jagrat7:main Mar 20, 2026
@RainAfterDark RainAfterDark mentioned this pull request Mar 22, 2026
@RainAfterDark
Copy link
Copy Markdown
Collaborator Author

This would need something like nixGL to properly wrap the Electron binary on non-NixOS systems.

Ahhh GPU drivers are definitely a headache on NIx, will try to see if I can spin up a different distro on a spare laptop to see the graphics compat situation.

The dev shell currently only works on NixOS

The fix is to only spawn the user shell in interactive mode

Slight oversight, I never use --comand myself, but #33 should address this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants