From 19040e39232c15cf10064a83743f5153ccb123f3 Mon Sep 17 00:00:00 2001 From: Andre-Philippe Paquet Date: Sun, 6 Dec 2026 08:07:31 -0500 Subject: [PATCH] feat(dev): load dotc completions lazily in the dev shell --- flake.nix | 1 + nix/backend.nix | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/flake.nix b/flake.nix index 8e661af0..3daf7dd9 100644 --- a/flake.nix +++ b/flake.nix @@ -253,6 +253,7 @@ backend.cli backend.dotcoreCli + backend.dotcDevCompletions nodejs_24 diff --git a/nix/backend.nix b/nix/backend.nix index 0e44a5bd..9fa7215a 100644 --- a/nix/backend.nix +++ b/nix/backend.nix @@ -174,10 +174,24 @@ let exec nix run .#dotcore -- "$@" ''; }; + + # Fish autoloads a command's completions from `/fish/vendor_completions.d/.fish` + # under every XDG_DATA_DIRS entry, and the dev shell exposes each package's share dir there. + # This file generates dotc's completions from the dev shell's dotc itself, on the first + # completion request, so entering the shell never waits for the dotc build. + dotcDevCompletions = pkgs.runCommand "dotc-dev-completions" { } '' + mkdir -p $out/share/fish/vendor_completions.d + cat > $out/share/fish/vendor_completions.d/dotc.fish <<'EOF' + # The dev shell's dotc builds the CLI on first use, so completions generate from it + # only once fish asks for them. + COMPLETE=fish dotc | source + EOF + ''; in { package = backend; test = backendTest; cli = dotcDevelopmentCommand; dotcoreCli = dotcoreDevelopmentCommand; + dotcDevCompletions = dotcDevCompletions; }