From 020de59fcffd44c3ce6d53fcfce7b4e36236be3e Mon Sep 17 00:00:00 2001 From: centdix <40307056+centdix@users.noreply.github.com> Date: Mon, 16 Mar 2026 15:12:52 +0100 Subject: [PATCH] make flake dev env vars respect per-worktree overrides (#8374) Co-authored-by: Claude Opus 4.6 --- .envrc | 6 ++++++ flake.nix | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.envrc b/.envrc index 3550a30f2d..f905841649 100644 --- a/.envrc +++ b/.envrc @@ -1 +1,7 @@ use flake + +# Per-worktree overrides (ports, DATABASE_URL, etc.) written by webmux/workmux +# post-create hooks. Must come after `use flake` so they take precedence over +# the flake's defaults. +# shellcheck source=/dev/null +[ -f .env.local ] && source .env.local diff --git a/flake.nix b/flake.nix index 135005b83d..5f644d93dc 100644 --- a/flake.nix +++ b/flake.nix @@ -229,13 +229,20 @@ # --------------------------------------------------------------- devEnvVars = { - DATABASE_URL = "postgres://postgres:changeme@127.0.0.1:5432/windmill?sslmode=disable"; - REMOTE = "http://127.0.0.1:8000"; - REMOTE_LSP = "http://127.0.0.1:3001"; NODE_ENV = "development"; NODE_OPTIONS = "--max-old-space-size=16384"; }; + # Connection-specific defaults — set via shellHook so they respect + # pre-existing values (e.g. from webmux runtime.env / .env.local). + # Nix attrs are injected unconditionally and would override per-worktree + # values set by webmux before the interactive shell starts. + devShellHook = '' + export DATABASE_URL="''${DATABASE_URL:-postgres://postgres:changeme@127.0.0.1:5432/windmill?sslmode=disable}" + export REMOTE="''${REMOTE:-http://127.0.0.1:8000}" + export REMOTE_LSP="''${REMOTE_LSP:-http://127.0.0.1:3001}" + ''; + # --------------------------------------------------------------- # Helper scripts — base set (default + full) # --------------------------------------------------------------- @@ -402,6 +409,7 @@ # ============================================================= devShells.default = pkgs.mkShell (buildEnvVars // commonRuntimeVars // devEnvVars // browserVars // { + shellHook = devShellHook; buildInputs = coreBuildInputs; packages = helperScriptsBase ++ [ playwrightWrapper ]; @@ -413,6 +421,7 @@ # ============================================================= devShells.full = pkgs.mkShell (buildEnvVars // commonRuntimeVars // extraRuntimeVars // devEnvVars // browserVars // { + shellHook = devShellHook; buildInputs = coreBuildInputs ++ extraRuntimes ++ (with pkgs; [ # Python extras poetry