From 2b9f5092d8dde27d0cb028b5cb3227caff51384f Mon Sep 17 00:00:00 2001 From: Liet Blue <127093491+lietblue@users.noreply.github.com> Date: Tue, 10 Mar 2026 19:32:19 +0800 Subject: [PATCH] feat(nix): add FHS devShell for running Electron on NixOS (#1245) --- README.md | 9 +++++++++ flake.nix | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f310d5be4..1e09a4f4c 100644 --- a/README.md +++ b/README.md @@ -255,6 +255,15 @@ A Nix package for Tamagotchi is included. To run airi with Nix, first make sure nix run github:moeru-ai/airi ``` +#### NixOS + +Electron requires shared libraries that aren't in standard paths on NixOS. Use the FHS shell defined in `flake.nix`: + +```shell +nix develop .#fhs +pnpm dev:tamagotchi +``` + ### Stage Pocket (Mobile Version) Start the development server for the capacitor: diff --git a/flake.nix b/flake.nix index 1a3af541f..bb18367f6 100644 --- a/flake.nix +++ b/flake.nix @@ -34,7 +34,12 @@ }; devShells = forAllSystems ( - system: with (pkgsForSystem system); { + system: + let + pkgs = pkgsForSystem system; + in + with pkgs; + { default = mkShell { inputsFrom = [ self.packages.${system}.airi ]; packages = [ @@ -45,6 +50,51 @@ python314 ]; }; + + # FHS environment for running Electron on NixOS + # Usage: nix develop .#fhs + fhs = ( + buildFHSEnv { + name = "airi-electron-fhs"; + targetPkgs = + p: with p; [ + nodejs_24 + pnpm + # Electron system library dependencies + # Note: some packages need explicit output refs because the + # default attribute doesn't point to the output with .so files + glib.out # default 'glib' points to 'bin' output + nss + nspr + dbus.lib # libdbus-1.so.3 is in 'lib' output, not 'out' + atk + at-spi2-atk + at-spi2-core + cups.lib # libcups.so.2 is in 'lib' output, not 'out' + libdrm + xorg.libX11 + xorg.libXcomposite + xorg.libXdamage + xorg.libXext + xorg.libXfixes + xorg.libXrandr + xorg.libxcb + xorg.libXcursor + xorg.libXi + xorg.libXtst + expat + libxkbcommon + libgbm # libgbm.so.1 is now a separate package from mesa + alsa-lib + pango.out # default 'pango' points to 'bin' output + cairo + libGL + gtk3 + systemd + ]; + runScript = "bash"; + } + ).env; } ); };