From 6b4a133e9e758e9a72c36961da479c2cc256e476 Mon Sep 17 00:00:00 2001 From: yuuhikaze Date: Mon, 15 Jun 2026 14:58:58 -0500 Subject: [PATCH 1/2] feat: add Nix flake dev environment Add Nix flake with NixOS-patched Electron binary and direnv integration for reproducible development setup. Co-Authored-By: Claude Opus 4.6 --- .envrc | 1 + .gitignore | 5 ++++- README.md | 27 +++++++++++++++++++++++++-- flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 26 ++++++++++++++++++++++++++ 5 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..a5dbbcba --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake . diff --git a/.gitignore b/.gitignore index 8960c0ec..11b1f504 100644 --- a/.gitignore +++ b/.gitignore @@ -58,4 +58,7 @@ packages/react-devtools-extensions/.tempUserDataDir out # Cursor files -.cursorrules \ No newline at end of file +.cursorrules + +# direnv local cache (committed: .envrc) +.direnv \ No newline at end of file diff --git a/README.md b/README.md index 08874f96..e5ed973b 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,36 @@ An Electron application with React and TypeScript ## Project Setup -### Install +### Using Nix (Recommended for NixOS users) + +With [direnv](https://direnv.net/) and [nix-direnv](https://github.com/nix-community/nix-direnv): + +```bash +direnv allow # one-time, auto-loads the flake on every cd +npm install +npm run dev +``` + +Without direnv: + +```bash +nix develop +npm install +npm run dev +``` + +The flake provides a NixOS-patched Electron binary via `ELECTRON_OVERRIDE_DIST_PATH`, +so no `LD_LIBRARY_PATH` exports are needed. + +### Manual Setup + +#### Install ```bash $ npm install ``` -### Development +#### Development ```bash $ npm run dev diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..6908e251 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1776877367, + "narHash": "sha256-EHq1/OX139R1RvBzOJ0aMRT3xnWyqtHBRUBuO1gFzjI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0726a0ecb6d4e08f6adced58726b95db924cef57", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..7bea0fda --- /dev/null +++ b/flake.nix @@ -0,0 +1,26 @@ +{ + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + outputs = + { nixpkgs, ... }: + let + systems = [ + "x86_64-linux" + "aarch64-linux" + ]; + forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system}); + in + { + devShells = forAllSystems (pkgs: { + default = pkgs.mkShell { + packages = [ pkgs.nodejs pkgs.electron ]; + # Use the NixOS-patched Electron instead of the pre-built npm binary. + # pkgs.electron has correct RPATHs baked in, supports native Wayland + # (ozone/Chromium), and needs no LD_LIBRARY_PATH workarounds. + # electron-vite reads ELECTRON_EXEC_PATH before falling back to + # node_modules/electron/dist/electron. + ELECTRON_EXEC_PATH = "${pkgs.electron}/bin/electron"; + }; + }); + }; +} From f9ebaa0761f46220314357f8e33f0f0da82abd6a Mon Sep 17 00:00:00 2001 From: yuuhikaze Date: Tue, 16 Jun 2026 08:30:19 -0500 Subject: [PATCH 2/2] fix: correct env variable name in README MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ELECTRON_OVERRIDE_DIST_PATH → ELECTRON_EXEC_PATH to match flake.nix. Co-Authored-By: Claude Opus 4.6 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e5ed973b..8d7a0d05 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ npm install npm run dev ``` -The flake provides a NixOS-patched Electron binary via `ELECTRON_OVERRIDE_DIST_PATH`, +The flake provides a NixOS-patched Electron binary via `ELECTRON_EXEC_PATH`, so no `LD_LIBRARY_PATH` exports are needed. ### Manual Setup