diff --git a/pkgs/development/compilers/swift/swift-format/default.nix b/pkgs/development/compilers/swift/swift-format/default.nix index f1d435a6cca5..adb76e7a359a 100644 --- a/pkgs/development/compilers/swift/swift-format/default.nix +++ b/pkgs/development/compilers/swift/swift-format/default.nix @@ -1,11 +1,11 @@ { lib, stdenv, - fetchpatch, callPackage, swift, swiftpm, swiftpm2nix, + installShellFiles, Dispatch, Foundation, }: @@ -22,6 +22,7 @@ stdenv.mkDerivation { nativeBuildInputs = [ swift swiftpm + installShellFiles ]; buildInputs = [ Foundation ]; @@ -38,6 +39,16 @@ stdenv.mkDerivation { binPath="$(swiftpmBinPath)" mkdir -p $out/bin cp $binPath/swift-format $out/bin/ + + # Generate shell completions + for shell in bash zsh fish; do + $out/bin/swift-format --generate-completion-script $shell > swift-format.$shell + done + + installShellCompletion --cmd swift-format \ + --bash swift-format.bash \ + --zsh swift-format.zsh \ + --fish swift-format.fish ''; meta = {