From 82fc4e99437c35096ecb7e4c61ace65b3fb7483c Mon Sep 17 00:00:00 2001 From: Yuto Nishida Date: Sun, 13 Sep 2026 22:48:44 -0700 Subject: [PATCH] [dsh-everything-edition] add main-any-port target A second `nix run .#main` fails once 3080 is taken. The new target is a thin wrapper that prepends `--port 0`, letting the OS pick a free port; an explicit user `--port` still wins because it lands later on the composed command line. --- experimental/dsh-everything-edition/flake.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/experimental/dsh-everything-edition/flake.nix b/experimental/dsh-everything-edition/flake.nix index a2d440a..5b542b9 100644 --- a/experimental/dsh-everything-edition/flake.nix +++ b/experimental/dsh-everything-edition/flake.nix @@ -132,6 +132,21 @@ description = "dsh web preloaded with this checkout's dsh-plugins/plugins.cordis.yml"; }; }; + + # dsh-main with `--port 0`, so a second run gets an OS-assigned free + # port instead of colliding on 3080. A user-supplied `--port` still + # wins, because it lands after this one on the composed command line. + dsh-main-any-port = pkgs.writeShellApplication { + name = "dsh-main-any-port"; + runtimeInputs = [ dsh-main ]; + text = '' + exec dsh-main --port 0 "$@" + ''; + meta = { + mainProgram = "dsh-main-any-port"; + description = "dsh-main on an OS-assigned free port"; + }; + }; in { # `nix run .#dsh-vanilla-with-pnpm`: plain dsh with pnpm + node on PATH. @@ -140,6 +155,9 @@ # `nix run` (or `nix run .#main`): dsh web with this checkout's plugins loaded. default = dsh-main; main = dsh-main; + + # `nix run .#main-any-port`: `#main`, but on an OS-assigned free port. + main-any-port = dsh-main-any-port; } ); }; -- 2.51.2