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;
}