about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/applications/misc/flavours/default.nix2
-rw-r--r--pkgs/applications/misc/genact/default.nix4
-rw-r--r--pkgs/applications/misc/inlyne/default.nix2
-rw-r--r--pkgs/applications/misc/leetcode-cli/default.nix2
-rw-r--r--pkgs/applications/version-management/git-absorb/default.nix1
-rw-r--r--pkgs/applications/version-management/jujutsu/default.nix2
-rw-r--r--pkgs/applications/virtualization/youki/default.nix3
-rw-r--r--pkgs/by-name/ab/ab-av1/package.nix4
-rw-r--r--pkgs/by-name/as/ast-grep/package.nix2
-rw-r--r--pkgs/by-name/cl/clipcat/package.nix2
-rw-r--r--pkgs/by-name/co/codeberg-cli/package.nix2
-rw-r--r--pkgs/by-name/di/diesel-cli/package.nix2
-rw-r--r--pkgs/by-name/el/elf2nucleus/package.nix3
-rw-r--r--pkgs/by-name/en/engage/package.nix7
-rw-r--r--pkgs/by-name/jo/joshuto/package.nix2
-rw-r--r--pkgs/by-name/ma/maa-cli/package.nix1
-rw-r--r--pkgs/by-name/pa/pace/package.nix3
-rw-r--r--pkgs/by-name/pi/pixi/package.nix2
-rw-r--r--pkgs/by-name/qr/qrtool/package.nix2
-rw-r--r--pkgs/by-name/re/release-plz/package.nix2
-rw-r--r--pkgs/by-name/sn/sn0int/package.nix2
-rw-r--r--pkgs/by-name/so/solana-cli/package.nix2
-rw-r--r--pkgs/by-name/st/steamguard-cli/package.nix3
-rw-r--r--pkgs/by-name/zo/zola/package.nix2
-rw-r--r--pkgs/development/compilers/jrsonnet/default.nix3
-rw-r--r--pkgs/development/tools/cocogitto/default.nix2
-rw-r--r--pkgs/development/tools/espup/default.nix2
-rw-r--r--pkgs/development/tools/fnm/default.nix2
-rw-r--r--pkgs/development/tools/rust/cargo-show-asm/default.nix2
-rw-r--r--pkgs/development/tools/rust/cauwugo/default.nix4
-rw-r--r--pkgs/development/tools/rust/typeshare/default.nix3
-rw-r--r--pkgs/development/tools/sentry-cli/default.nix2
-rw-r--r--pkgs/development/tools/snazy/default.nix3
-rw-r--r--pkgs/development/tools/tokio-console/default.nix3
-rw-r--r--pkgs/development/tools/volta/default.nix2
-rw-r--r--pkgs/development/web/deno/default.nix2
-rw-r--r--pkgs/servers/http/dufs/default.nix2
-rw-r--r--pkgs/tools/misc/charasay/default.nix3
-rw-r--r--pkgs/tools/misc/dotter/default.nix2
-rw-r--r--pkgs/tools/misc/intermodal/default.nix2
-rw-r--r--pkgs/tools/misc/miniserve/default.nix2
-rw-r--r--pkgs/tools/misc/onefetch/default.nix2
-rw-r--r--pkgs/tools/misc/sheldon/default.nix2
-rw-r--r--pkgs/tools/misc/starship/default.nix8
-rw-r--r--pkgs/tools/misc/topgrade/default.nix2
-rw-r--r--pkgs/tools/misc/trashy/default.nix4
-rw-r--r--pkgs/tools/misc/tremor-rs/default.nix1
-rw-r--r--pkgs/tools/misc/twm/default.nix2
-rw-r--r--pkgs/tools/misc/zellij/default.nix1
-rw-r--r--pkgs/tools/networking/magic-wormhole-rs/default.nix2
-rw-r--r--pkgs/tools/nix/fh/default.nix2
-rw-r--r--pkgs/tools/package-management/nix-template/default.nix1
-rw-r--r--pkgs/tools/security/bws/default.nix2
-rw-r--r--pkgs/tools/security/jwt-cli/default.nix2
-rw-r--r--pkgs/tools/security/kbs2/default.nix1
-rw-r--r--pkgs/tools/security/prs/default.nix3
-rw-r--r--pkgs/tools/security/rbw/default.nix1
-rw-r--r--pkgs/tools/security/sheesy-cli/default.nix2
-rw-r--r--pkgs/tools/security/shisho/default.nix3
-rw-r--r--pkgs/tools/text/languagetool-rust/default.nix2
-rw-r--r--pkgs/tools/text/termbook/default.nix2
61 files changed, 84 insertions, 61 deletions
diff --git a/pkgs/applications/misc/flavours/default.nix b/pkgs/applications/misc/flavours/default.nix
index ffb329129d8e..98146e6bfdf3 100644
--- a/pkgs/applications/misc/flavours/default.nix
+++ b/pkgs/applications/misc/flavours/default.nix
@@ -17,7 +17,7 @@ rustPlatform.buildRustPackage rec {
 
   nativeBuildInputs = [ installShellFiles ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd flavours \
       --zsh <($out/bin/flavours --completions zsh) \
       --fish <($out/bin/flavours --completions fish) \
diff --git a/pkgs/applications/misc/genact/default.nix b/pkgs/applications/misc/genact/default.nix
index 8591b749a406..d2abfc02ba77 100644
--- a/pkgs/applications/misc/genact/default.nix
+++ b/pkgs/applications/misc/genact/default.nix
@@ -1,4 +1,4 @@
-{ lib, rustPlatform, fetchFromGitHub, installShellFiles }:
+{ lib, rustPlatform, fetchFromGitHub, installShellFiles, stdenv }:
 
 rustPlatform.buildRustPackage rec {
   pname = "genact";
@@ -15,7 +15,7 @@ rustPlatform.buildRustPackage rec {
 
   nativeBuildInputs = [ installShellFiles ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     $out/bin/genact --print-manpage > genact.1
     installManPage genact.1
 
diff --git a/pkgs/applications/misc/inlyne/default.nix b/pkgs/applications/misc/inlyne/default.nix
index b333f5342263..f896b4518790 100644
--- a/pkgs/applications/misc/inlyne/default.nix
+++ b/pkgs/applications/misc/inlyne/default.nix
@@ -51,7 +51,7 @@ rustPlatform.buildRustPackage rec {
     "--skip=watcher::tests::the_gauntlet"
   ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd inlyne \
       --bash completions/inlyne.bash \
       --fish completions/inlyne.fish \
diff --git a/pkgs/applications/misc/leetcode-cli/default.nix b/pkgs/applications/misc/leetcode-cli/default.nix
index f2e217404eb4..9bc7c7cbe34a 100644
--- a/pkgs/applications/misc/leetcode-cli/default.nix
+++ b/pkgs/applications/misc/leetcode-cli/default.nix
@@ -34,7 +34,7 @@ rustPlatform.buildRustPackage rec {
     sqlite
   ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd leetcode \
       --bash <($out/bin/leetcode completions bash) \
       --fish <($out/bin/leetcode completions fish) \
diff --git a/pkgs/applications/version-management/git-absorb/default.nix b/pkgs/applications/version-management/git-absorb/default.nix
index aecc19f0aa16..49d4a0a67ad2 100644
--- a/pkgs/applications/version-management/git-absorb/default.nix
+++ b/pkgs/applications/version-management/git-absorb/default.nix
@@ -19,6 +19,7 @@ rustPlatform.buildRustPackage rec {
 
   postInstall = ''
     installManPage Documentation/git-absorb.1
+  '' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd git-absorb \
       --bash <($out/bin/git-absorb --gen-completions bash) \
       --fish <($out/bin/git-absorb --gen-completions fish) \
diff --git a/pkgs/applications/version-management/jujutsu/default.nix b/pkgs/applications/version-management/jujutsu/default.nix
index 98d1a8f8e144..35a71c30444f 100644
--- a/pkgs/applications/version-management/jujutsu/default.nix
+++ b/pkgs/applications/version-management/jujutsu/default.nix
@@ -52,7 +52,7 @@ rustPlatform.buildRustPackage rec {
     libiconv
   ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     $out/bin/jj util mangen > ./jj.1
     installManPage ./jj.1
 
diff --git a/pkgs/applications/virtualization/youki/default.nix b/pkgs/applications/virtualization/youki/default.nix
index 506179dbf35c..7b7cf4911c90 100644
--- a/pkgs/applications/virtualization/youki/default.nix
+++ b/pkgs/applications/virtualization/youki/default.nix
@@ -6,6 +6,7 @@
 , dbus
 , libseccomp
 , systemd
+, stdenv
 }:
 
 rustPlatform.buildRustPackage rec {
@@ -27,7 +28,7 @@ rustPlatform.buildRustPackage rec {
 
   buildInputs = [ dbus libseccomp systemd ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd youki \
       --bash <($out/bin/youki completion -s bash) \
       --fish <($out/bin/youki completion -s fish) \
diff --git a/pkgs/by-name/ab/ab-av1/package.nix b/pkgs/by-name/ab/ab-av1/package.nix
index 7319c2fa22a8..aa057f69e06b 100644
--- a/pkgs/by-name/ab/ab-av1/package.nix
+++ b/pkgs/by-name/ab/ab-av1/package.nix
@@ -1,4 +1,4 @@
-{ lib, rustPlatform, fetchFromGitHub, installShellFiles }:
+{ lib, rustPlatform, fetchFromGitHub, installShellFiles, stdenv }:
 
 rustPlatform.buildRustPackage rec {
   pname = "ab-av1";
@@ -15,7 +15,7 @@ rustPlatform.buildRustPackage rec {
 
   nativeBuildInputs = [ installShellFiles ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd ab-av1 \
       --bash <($out/bin/ab-av1 print-completions bash) \
       --fish <($out/bin/ab-av1 print-completions fish) \
diff --git a/pkgs/by-name/as/ast-grep/package.nix b/pkgs/by-name/as/ast-grep/package.nix
index 644ef2e284ca..ab33df30035a 100644
--- a/pkgs/by-name/as/ast-grep/package.nix
+++ b/pkgs/by-name/as/ast-grep/package.nix
@@ -25,7 +25,7 @@ rustPlatform.buildRustPackage rec {
     rm .cargo/config.toml
   '';
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd sg \
       --bash <($out/bin/sg completions bash) \
       --fish <($out/bin/sg completions fish) \
diff --git a/pkgs/by-name/cl/clipcat/package.nix b/pkgs/by-name/cl/clipcat/package.nix
index b72baf6e46b5..fe4803bd3eeb 100644
--- a/pkgs/by-name/cl/clipcat/package.nix
+++ b/pkgs/by-name/cl/clipcat/package.nix
@@ -38,7 +38,7 @@ rustPlatform.buildRustPackage rec {
     "--skip=test_x11_primary"
   ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     for cmd in clipcatd clipcatctl clipcat-menu clipcat-notify; do
       installShellCompletion --cmd $cmd \
         --bash <($out/bin/$cmd completions bash) \
diff --git a/pkgs/by-name/co/codeberg-cli/package.nix b/pkgs/by-name/co/codeberg-cli/package.nix
index fce36f682c3d..825731d4d1b4 100644
--- a/pkgs/by-name/co/codeberg-cli/package.nix
+++ b/pkgs/by-name/co/codeberg-cli/package.nix
@@ -39,7 +39,7 @@ rustPlatform.buildRustPackage rec {
       ]
     );
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd berg \
       --bash <($out/bin/berg completion bash) \
       --fish <($out/bin/berg completion fish) \
diff --git a/pkgs/by-name/di/diesel-cli/package.nix b/pkgs/by-name/di/diesel-cli/package.nix
index ad626b57903a..970d4458077a 100644
--- a/pkgs/by-name/di/diesel-cli/package.nix
+++ b/pkgs/by-name/di/diesel-cli/package.nix
@@ -79,7 +79,7 @@ rustPlatform.buildRustPackage rec {
   # Tests currently fail due to *many* duplicate definition errors
   doCheck = false;
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd diesel \
       --bash <($out/bin/diesel completions bash) \
       --fish <($out/bin/diesel completions fish) \
diff --git a/pkgs/by-name/el/elf2nucleus/package.nix b/pkgs/by-name/el/elf2nucleus/package.nix
index fad1d8719971..1e755c629338 100644
--- a/pkgs/by-name/el/elf2nucleus/package.nix
+++ b/pkgs/by-name/el/elf2nucleus/package.nix
@@ -4,6 +4,7 @@
 , lib
 , micronucleus
 , rustPlatform
+, stdenv
 }:
 
 rustPlatform.buildRustPackage rec {
@@ -23,7 +24,7 @@ rustPlatform.buildRustPackage rec {
 
   buildInputs = [ micronucleus ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd elf2nucleus \
       --bash <($out/bin/elf2nucleus --completions bash) \
       --fish <($out/bin/elf2nucleus --completions fish) \
diff --git a/pkgs/by-name/en/engage/package.nix b/pkgs/by-name/en/engage/package.nix
index 8a87e0d46097..585d072dae42 100644
--- a/pkgs/by-name/en/engage/package.nix
+++ b/pkgs/by-name/en/engage/package.nix
@@ -2,6 +2,7 @@
 , installShellFiles
 , rustPlatform
 , fetchFromGitLab
+, stdenv
 }:
 
 let
@@ -25,7 +26,8 @@ rustPlatform.buildRustPackage {
     installShellFiles
   ];
 
-  postInstall = "installShellCompletion --cmd ${pname} "
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) (
+    "installShellCompletion --cmd ${pname} "
     + builtins.concatStringsSep
       " "
       (builtins.map
@@ -35,7 +37,8 @@ rustPlatform.buildRustPackage {
           "fish"
           "zsh"
         ]
-      );
+      )
+    );
 
   meta = {
     description = "Task runner with DAG-based parallelism";
diff --git a/pkgs/by-name/jo/joshuto/package.nix b/pkgs/by-name/jo/joshuto/package.nix
index 08f5429fbb5c..e24a3cd93e8f 100644
--- a/pkgs/by-name/jo/joshuto/package.nix
+++ b/pkgs/by-name/jo/joshuto/package.nix
@@ -25,7 +25,7 @@ rustPlatform.buildRustPackage rec {
     darwin.apple_sdk.frameworks.Foundation
   ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd joshuto \
       --bash <($out/bin/joshuto completions bash) \
       --zsh <($out/bin/joshuto completions zsh) \
diff --git a/pkgs/by-name/ma/maa-cli/package.nix b/pkgs/by-name/ma/maa-cli/package.nix
index e1bfed03e0eb..c6d4177c93a0 100644
--- a/pkgs/by-name/ma/maa-cli/package.nix
+++ b/pkgs/by-name/ma/maa-cli/package.nix
@@ -65,6 +65,7 @@ rustPlatform.buildRustPackage rec {
         ]
       }"
 
+  '' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd maa \
       --bash <($out/bin/maa complete bash) \
       --fish <($out/bin/maa complete fish) \
diff --git a/pkgs/by-name/pa/pace/package.nix b/pkgs/by-name/pa/pace/package.nix
index 738077648c1b..a90ce66f537e 100644
--- a/pkgs/by-name/pa/pace/package.nix
+++ b/pkgs/by-name/pa/pace/package.nix
@@ -3,6 +3,7 @@
   rustPlatform,
   fetchFromGitHub,
   installShellFiles,
+  stdenv,
 }: let
   version = "0.15.2";
 in
@@ -21,7 +22,7 @@ in
 
     nativeBuildInputs = [installShellFiles];
 
-    postInstall = ''
+    postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
       installShellCompletion --cmd pace \
         --bash <($out/bin/pace setup completions bash) \
         --fish <($out/bin/pace setup completions fish) \
diff --git a/pkgs/by-name/pi/pixi/package.nix b/pkgs/by-name/pi/pixi/package.nix
index e6b4c5578392..8fe5169127e6 100644
--- a/pkgs/by-name/pi/pixi/package.nix
+++ b/pkgs/by-name/pi/pixi/package.nix
@@ -80,7 +80,7 @@ rustPlatform.buildRustPackage rec {
     "--skip=cli::shell_hook::tests::test_environment_json"
   ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd pixi \
       --bash <($out/bin/pixi completion --shell bash) \
       --fish <($out/bin/pixi completion --shell fish) \
diff --git a/pkgs/by-name/qr/qrtool/package.nix b/pkgs/by-name/qr/qrtool/package.nix
index c761e4c17863..fe90881fd8d1 100644
--- a/pkgs/by-name/qr/qrtool/package.nix
+++ b/pkgs/by-name/qr/qrtool/package.nix
@@ -1,4 +1,5 @@
 { lib
+, stdenv
 , fetchFromGitHub
 , rustPlatform
 , asciidoctor
@@ -24,6 +25,7 @@ rustPlatform.buildRustPackage rec {
     # Built by ./build.rs using `asciidoctor`
     installManPage ./target/*/release/build/qrtool*/out/*.?
 
+  '' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd qrtool \
       --bash <($out/bin/qrtool --generate-completion bash) \
       --fish <($out/bin/qrtool --generate-completion fish) \
diff --git a/pkgs/by-name/re/release-plz/package.nix b/pkgs/by-name/re/release-plz/package.nix
index 25958a05d8c8..da5b97c8ef47 100644
--- a/pkgs/by-name/re/release-plz/package.nix
+++ b/pkgs/by-name/re/release-plz/package.nix
@@ -28,7 +28,7 @@ rustPlatform.buildRustPackage rec {
   # Tests depend on additional infrastructure to be running locally
   doCheck = false;
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd ${meta.mainProgram} \
       --bash <($out/bin/${meta.mainProgram} generate-completions bash) \
       --fish <($out/bin/${meta.mainProgram} generate-completions fish) \
diff --git a/pkgs/by-name/sn/sn0int/package.nix b/pkgs/by-name/sn/sn0int/package.nix
index 2410fa0cc230..43eadd2c3940 100644
--- a/pkgs/by-name/sn/sn0int/package.nix
+++ b/pkgs/by-name/sn/sn0int/package.nix
@@ -41,7 +41,7 @@ rustPlatform.buildRustPackage rec {
   # in "checkPhase", hence fails in sandbox of "nix".
   doCheck = false;
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform)  ''
     installShellCompletion --cmd sn0int \
       --bash <($out/bin/sn0int completions bash) \
       --fish <($out/bin/sn0int completions fish) \
diff --git a/pkgs/by-name/so/solana-cli/package.nix b/pkgs/by-name/so/solana-cli/package.nix
index b4a56dda78c9..aa7bcd58936d 100644
--- a/pkgs/by-name/so/solana-cli/package.nix
+++ b/pkgs/by-name/so/solana-cli/package.nix
@@ -80,7 +80,7 @@ rustPlatform.buildRustPackage rec {
     Libsystem
   ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd solana \
       --bash <($out/bin/solana completion --shell bash) \
       --fish <($out/bin/solana completion --shell fish) \
diff --git a/pkgs/by-name/st/steamguard-cli/package.nix b/pkgs/by-name/st/steamguard-cli/package.nix
index 38ed7f69b33b..6cbdb77e10b9 100644
--- a/pkgs/by-name/st/steamguard-cli/package.nix
+++ b/pkgs/by-name/st/steamguard-cli/package.nix
@@ -2,6 +2,7 @@
 , lib
 , rustPlatform
 , fetchFromGitHub
+, stdenv
 }:
 
 rustPlatform.buildRustPackage rec {
@@ -18,7 +19,7 @@ rustPlatform.buildRustPackage rec {
   cargoHash = "sha256-LYrn0MKrOYjYPLdBukXRXGW+XWVcGHNAl0vC/qkmkNs=";
 
   nativeBuildInputs = [ installShellFiles ];
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd steamguard \
       --bash <($out/bin/steamguard completion --shell bash) \
       --fish <($out/bin/steamguard completion --shell fish) \
diff --git a/pkgs/by-name/zo/zola/package.nix b/pkgs/by-name/zo/zola/package.nix
index 2b25b1fd346b..9f6152b3397c 100644
--- a/pkgs/by-name/zo/zola/package.nix
+++ b/pkgs/by-name/zo/zola/package.nix
@@ -36,7 +36,7 @@ rustPlatform.buildRustPackage rec {
 
   RUSTONIG_SYSTEM_LIBONIG = true;
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd zola \
       --bash <($out/bin/zola completion bash) \
       --fish <($out/bin/zola completion fish) \
diff --git a/pkgs/development/compilers/jrsonnet/default.nix b/pkgs/development/compilers/jrsonnet/default.nix
index 3c4c5d71c0ce..2031c006de6f 100644
--- a/pkgs/development/compilers/jrsonnet/default.nix
+++ b/pkgs/development/compilers/jrsonnet/default.nix
@@ -1,4 +1,4 @@
-{ lib, rustPlatform, fetchFromGitHub, installShellFiles }:
+{ lib, rustPlatform, fetchFromGitHub, installShellFiles, stdenv }:
 
 rustPlatform.buildRustPackage rec {
   pname = "jrsonnet";
@@ -28,6 +28,7 @@ rustPlatform.buildRustPackage rec {
   postInstall = ''
     ln -s $out/bin/jrsonnet $out/bin/jsonnet
 
+  '' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     for shell in bash zsh fish; do
       installShellCompletion --cmd jrsonnet \
         --$shell <($out/bin/jrsonnet --generate $shell /dev/null)
diff --git a/pkgs/development/tools/cocogitto/default.nix b/pkgs/development/tools/cocogitto/default.nix
index 16bb018e36dd..6760b4754203 100644
--- a/pkgs/development/tools/cocogitto/default.nix
+++ b/pkgs/development/tools/cocogitto/default.nix
@@ -21,7 +21,7 @@ rustPlatform.buildRustPackage rec {
 
   buildInputs = [ libgit2 ] ++ lib.optional stdenv.isDarwin Security;
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd cog \
       --bash <($out/bin/cog generate-completions bash) \
       --fish <($out/bin/cog generate-completions fish) \
diff --git a/pkgs/development/tools/espup/default.nix b/pkgs/development/tools/espup/default.nix
index cbf5c447117d..ca650be0e386 100644
--- a/pkgs/development/tools/espup/default.nix
+++ b/pkgs/development/tools/espup/default.nix
@@ -56,7 +56,7 @@ rustPlatform.buildRustPackage rec {
     "--skip=toolchain::rust::tests::test_xtensa_rust_parse_version"
   ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd espup \
       --bash <($out/bin/espup completions bash) \
       --fish <($out/bin/espup completions fish) \
diff --git a/pkgs/development/tools/fnm/default.nix b/pkgs/development/tools/fnm/default.nix
index 7b521856a3e8..9aafdb4e02c1 100644
--- a/pkgs/development/tools/fnm/default.nix
+++ b/pkgs/development/tools/fnm/default.nix
@@ -27,7 +27,7 @@ rustPlatform.buildRustPackage rec {
 
   doCheck = false;
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd fnm \
       --bash <($out/bin/fnm completions --shell bash) \
       --fish <($out/bin/fnm completions --shell fish) \
diff --git a/pkgs/development/tools/rust/cargo-show-asm/default.nix b/pkgs/development/tools/rust/cargo-show-asm/default.nix
index 02823914e15a..f6d52a2c54c6 100644
--- a/pkgs/development/tools/rust/cargo-show-asm/default.nix
+++ b/pkgs/development/tools/rust/cargo-show-asm/default.nix
@@ -22,7 +22,7 @@ rustPlatform.buildRustPackage rec {
     installShellFiles
   ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd cargo-asm \
       --bash <($out/bin/cargo-asm --bpaf-complete-style-bash) \
       --fish <($out/bin/cargo-asm --bpaf-complete-style-fish) \
diff --git a/pkgs/development/tools/rust/cauwugo/default.nix b/pkgs/development/tools/rust/cauwugo/default.nix
index 10a3432d4dd4..1f497a270b93 100644
--- a/pkgs/development/tools/rust/cauwugo/default.nix
+++ b/pkgs/development/tools/rust/cauwugo/default.nix
@@ -1,4 +1,4 @@
-{ lib, rustPlatform, fetchCrate, installShellFiles }:
+{ lib, rustPlatform, fetchCrate, installShellFiles, stdenv }:
 
 rustPlatform.buildRustPackage rec {
   pname = "cauwugo";
@@ -14,7 +14,7 @@ rustPlatform.buildRustPackage rec {
 
   nativeBuildInputs = [ installShellFiles ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd cauwugo \
       --bash <($out/bin/cauwugo --bpaf-complete-style-bash) \
       --fish <($out/bin/cauwugo --bpaf-complete-style-fish) \
diff --git a/pkgs/development/tools/rust/typeshare/default.nix b/pkgs/development/tools/rust/typeshare/default.nix
index 745784fc0304..1283df16fd00 100644
--- a/pkgs/development/tools/rust/typeshare/default.nix
+++ b/pkgs/development/tools/rust/typeshare/default.nix
@@ -2,6 +2,7 @@
 , rustPlatform
 , fetchFromGitHub
 , installShellFiles
+, stdenv
 }:
 
 rustPlatform.buildRustPackage rec {
@@ -21,7 +22,7 @@ rustPlatform.buildRustPackage rec {
 
   buildFeatures = [ "go" ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd typeshare \
       --bash <($out/bin/typeshare completions bash) \
       --fish <($out/bin/typeshare completions fish) \
diff --git a/pkgs/development/tools/sentry-cli/default.nix b/pkgs/development/tools/sentry-cli/default.nix
index cffe180a92d0..6a031160ffe7 100644
--- a/pkgs/development/tools/sentry-cli/default.nix
+++ b/pkgs/development/tools/sentry-cli/default.nix
@@ -29,7 +29,7 @@ rustPlatform.buildRustPackage rec {
 
   cargoHash = "sha256-9L02ox2T+dBRx+mmFpy5Bktsyp3C/havfZoDaNevIMw=";
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd sentry-cli \
         --bash <($out/bin/sentry-cli completions bash) \
         --fish <($out/bin/sentry-cli completions fish) \
diff --git a/pkgs/development/tools/snazy/default.nix b/pkgs/development/tools/snazy/default.nix
index e77cc4ae0c70..c27942538454 100644
--- a/pkgs/development/tools/snazy/default.nix
+++ b/pkgs/development/tools/snazy/default.nix
@@ -2,6 +2,7 @@
 , rustPlatform
 , fetchFromGitHub
 , installShellFiles
+, stdenv
 }:
 
 rustPlatform.buildRustPackage rec {
@@ -19,7 +20,7 @@ rustPlatform.buildRustPackage rec {
 
   nativeBuildInputs = [ installShellFiles ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd snazy \
       --bash <($out/bin/snazy --shell-completion bash) \
       --fish <($out/bin/snazy --shell-completion fish) \
diff --git a/pkgs/development/tools/tokio-console/default.nix b/pkgs/development/tools/tokio-console/default.nix
index 0618d818de3e..03775abeeb51 100644
--- a/pkgs/development/tools/tokio-console/default.nix
+++ b/pkgs/development/tools/tokio-console/default.nix
@@ -3,6 +3,7 @@
 , installShellFiles
 , rustPlatform
 , protobuf
+, stdenv
 }:
 
 rustPlatform.buildRustPackage rec {
@@ -35,7 +36,7 @@ rustPlatform.buildRustPackage rec {
     "--skip config::tests::toml_example_changed"
   ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd tokio-console \
       --bash <($out/bin/tokio-console --log-dir $(mktemp -d) gen-completion bash) \
       --fish <($out/bin/tokio-console --log-dir $(mktemp -d) gen-completion fish) \
diff --git a/pkgs/development/tools/volta/default.nix b/pkgs/development/tools/volta/default.nix
index e67df485b7f4..15c9c493b797 100644
--- a/pkgs/development/tools/volta/default.nix
+++ b/pkgs/development/tools/volta/default.nix
@@ -32,7 +32,7 @@ rustPlatform.buildRustPackage rec {
 
   HOME = "$TMPDIR";
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd volta \
       --bash <($out/bin/volta completions bash) \
       --fish <($out/bin/volta completions fish) \
diff --git a/pkgs/development/web/deno/default.nix b/pkgs/development/web/deno/default.nix
index f4cd4f91e071..3cf8d1d21696 100644
--- a/pkgs/development/web/deno/default.nix
+++ b/pkgs/development/web/deno/default.nix
@@ -68,7 +68,7 @@ rustPlatform.buildRustPackage rec {
     find ./target -name libswc_common${stdenv.hostPlatform.extensions.sharedLibrary} -delete
   '';
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd deno \
       --bash <($out/bin/deno completions bash) \
       --fish <($out/bin/deno completions fish) \
diff --git a/pkgs/servers/http/dufs/default.nix b/pkgs/servers/http/dufs/default.nix
index e01c923e1cd2..267f1ed38aaa 100644
--- a/pkgs/servers/http/dufs/default.nix
+++ b/pkgs/servers/http/dufs/default.nix
@@ -33,7 +33,7 @@ rustPlatform.buildRustPackage rec {
     "--skip=validate_printed_urls"
   ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd dufs \
       --bash <($out/bin/dufs --completions bash) \
       --fish <($out/bin/dufs --completions fish) \
diff --git a/pkgs/tools/misc/charasay/default.nix b/pkgs/tools/misc/charasay/default.nix
index f52312b387d0..5048b9dd655a 100644
--- a/pkgs/tools/misc/charasay/default.nix
+++ b/pkgs/tools/misc/charasay/default.nix
@@ -2,6 +2,7 @@
 , rustPlatform
 , fetchFromGitHub
 , installShellFiles
+, stdenv
 }:
 
 rustPlatform.buildRustPackage rec {
@@ -23,7 +24,7 @@ rustPlatform.buildRustPackage rec {
     rm .cargo/config.toml
   '';
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd chara \
       --bash <($out/bin/chara completions --shell bash) \
       --fish <($out/bin/chara completions --shell fish) \
diff --git a/pkgs/tools/misc/dotter/default.nix b/pkgs/tools/misc/dotter/default.nix
index ec8232ffc0fd..5dc48bfaf020 100644
--- a/pkgs/tools/misc/dotter/default.nix
+++ b/pkgs/tools/misc/dotter/default.nix
@@ -25,7 +25,7 @@ rustPlatform.buildRustPackage rec {
 
   nativeCheckInputs = [ which installShellFiles ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd dotter \
       --bash <($out/bin/dotter gen-completions --shell bash) \
       --fish <($out/bin/dotter gen-completions --shell fish) \
diff --git a/pkgs/tools/misc/intermodal/default.nix b/pkgs/tools/misc/intermodal/default.nix
index e4a296333569..c15d529279da 100644
--- a/pkgs/tools/misc/intermodal/default.nix
+++ b/pkgs/tools/misc/intermodal/default.nix
@@ -18,7 +18,7 @@ rustPlatform.buildRustPackage rec {
 
   nativeBuildInputs = [ installShellFiles ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd imdl \
       --bash <($out/bin/imdl completions bash) \
       --fish <($out/bin/imdl completions fish) \
diff --git a/pkgs/tools/misc/miniserve/default.nix b/pkgs/tools/misc/miniserve/default.nix
index 0bdbd91a1dc6..937f667c2a9a 100644
--- a/pkgs/tools/misc/miniserve/default.nix
+++ b/pkgs/tools/misc/miniserve/default.nix
@@ -41,7 +41,7 @@ rustPlatform.buildRustPackage rec {
     "--skip=validate_printed_urls"
   ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     $out/bin/miniserve --print-manpage >miniserve.1
     installManPage miniserve.1
 
diff --git a/pkgs/tools/misc/onefetch/default.nix b/pkgs/tools/misc/onefetch/default.nix
index 84762c8b7274..0e7175e6365a 100644
--- a/pkgs/tools/misc/onefetch/default.nix
+++ b/pkgs/tools/misc/onefetch/default.nix
@@ -47,7 +47,7 @@ rustPlatform.buildRustPackage rec {
     git commit -m test
   '';
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd onefetch \
       --bash <($out/bin/onefetch --generate bash) \
       --fish <($out/bin/onefetch --generate fish) \
diff --git a/pkgs/tools/misc/sheldon/default.nix b/pkgs/tools/misc/sheldon/default.nix
index 39c6f2082221..3c0618f3de6f 100644
--- a/pkgs/tools/misc/sheldon/default.nix
+++ b/pkgs/tools/misc/sheldon/default.nix
@@ -50,7 +50,7 @@ rustPlatform.buildRustPackage rec {
     "--skip lock_and_source_profiles"
   ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd sheldon \
       --bash <($out/bin/sheldon completions --shell bash) \
       --zsh <($out/bin/sheldon completions --shell zsh)
diff --git a/pkgs/tools/misc/starship/default.nix b/pkgs/tools/misc/starship/default.nix
index e322e03ed3e2..37d38016b882 100644
--- a/pkgs/tools/misc/starship/default.nix
+++ b/pkgs/tools/misc/starship/default.nix
@@ -34,14 +34,14 @@ rustPlatform.buildRustPackage rec {
   '';
 
   postInstall = ''
+    presetdir=$out/share/starship/presets/
+    mkdir -p $presetdir
+    cp docs/public/presets/toml/*.toml $presetdir
+  '' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd starship \
       --bash <($out/bin/starship completions bash) \
       --fish <($out/bin/starship completions fish) \
       --zsh <($out/bin/starship completions zsh)
-
-    presetdir=$out/share/starship/presets/
-    mkdir -p $presetdir
-    cp docs/public/presets/toml/*.toml $presetdir
   '';
 
   cargoHash = "sha256-yJ32HFaRpujJ9mQa+07b5cQcl1ATO/56dpm1IeKcbzs=";
diff --git a/pkgs/tools/misc/topgrade/default.nix b/pkgs/tools/misc/topgrade/default.nix
index 8b037912a80d..38e1f0d95c1a 100644
--- a/pkgs/tools/misc/topgrade/default.nix
+++ b/pkgs/tools/misc/topgrade/default.nix
@@ -36,7 +36,7 @@ rustPlatform.buildRustPackage rec {
     "AppKit"
   ]);
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd topgrade \
       --bash <($out/bin/topgrade --gen-completion bash) \
       --fish <($out/bin/topgrade --gen-completion fish) \
diff --git a/pkgs/tools/misc/trashy/default.nix b/pkgs/tools/misc/trashy/default.nix
index f9cfdd612761..39c725b3cfcb 100644
--- a/pkgs/tools/misc/trashy/default.nix
+++ b/pkgs/tools/misc/trashy/default.nix
@@ -1,4 +1,4 @@
-{ lib, rustPlatform, fetchCrate, installShellFiles }:
+{ lib, rustPlatform, fetchCrate, installShellFiles, stdenv }:
 
 rustPlatform.buildRustPackage rec {
   pname = "trashy";
@@ -13,7 +13,7 @@ rustPlatform.buildRustPackage rec {
 
   nativeBuildInputs = [ installShellFiles ];
 
-  preFixup = ''
+  preFixup = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd trash \
       --bash <($out/bin/trash completions bash) \
       --fish <($out/bin/trash completions fish) \
diff --git a/pkgs/tools/misc/tremor-rs/default.nix b/pkgs/tools/misc/tremor-rs/default.nix
index 62ddf4e725e6..65ba3a837474 100644
--- a/pkgs/tools/misc/tremor-rs/default.nix
+++ b/pkgs/tools/misc/tremor-rs/default.nix
@@ -50,6 +50,7 @@ rustPlatform.buildRustPackage rec {
     # Copy the standard library to $out/lib
     cp -r ${src}/tremor-script/lib/ $out
 
+  '' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd tremor \
       --bash <($out/bin/tremor completions bash) \
       --fish <($out/bin/tremor completions fish) \
diff --git a/pkgs/tools/misc/twm/default.nix b/pkgs/tools/misc/twm/default.nix
index 213378e41f05..7de3ed1b3b27 100644
--- a/pkgs/tools/misc/twm/default.nix
+++ b/pkgs/tools/misc/twm/default.nix
@@ -25,7 +25,7 @@ rustPlatform.buildRustPackage rec {
   nativeBuildInputs = [ pkg-config installShellFiles ];
   buildInputs = [ openssl ] ++ lib.optionals stdenv.isDarwin [ Security ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd twm \
       --bash <($out/bin/twm --print-bash-completion) \
       --zsh <($out/bin/twm --print-zsh-completion) \
diff --git a/pkgs/tools/misc/zellij/default.nix b/pkgs/tools/misc/zellij/default.nix
index ca2ababb464b..105d35349eb9 100644
--- a/pkgs/tools/misc/zellij/default.nix
+++ b/pkgs/tools/misc/zellij/default.nix
@@ -50,6 +50,7 @@ rustPlatform.buildRustPackage rec {
     mandown docs/MANPAGE.md > zellij.1
     installManPage zellij.1
 
+  '' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd $pname \
       --bash <($out/bin/zellij setup --generate-completion bash) \
       --fish <($out/bin/zellij setup --generate-completion fish) \
diff --git a/pkgs/tools/networking/magic-wormhole-rs/default.nix b/pkgs/tools/networking/magic-wormhole-rs/default.nix
index 77bb8e117e6f..fc0ceebc714e 100644
--- a/pkgs/tools/networking/magic-wormhole-rs/default.nix
+++ b/pkgs/tools/networking/magic-wormhole-rs/default.nix
@@ -28,7 +28,7 @@ rustPlatform.buildRustPackage rec {
   # all tests involve networking and are bound fail
   doCheck = false;
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd wormhole-rs \
       --bash <($out/bin/wormhole-rs completion bash) \
       --fish <($out/bin/wormhole-rs completion fish) \
diff --git a/pkgs/tools/nix/fh/default.nix b/pkgs/tools/nix/fh/default.nix
index 2a3e1d9e5a4d..6bfce50581f9 100644
--- a/pkgs/tools/nix/fh/default.nix
+++ b/pkgs/tools/nix/fh/default.nix
@@ -35,7 +35,7 @@ rustPlatform.buildRustPackage rec {
     NIX_CFLAGS_COMPILE = "-I${lib.getDev libcxx}/include/c++/v1";
   };
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd fh \
       --bash <($out/bin/fh completion bash) \
       --fish <($out/bin/fh completion fish) \
diff --git a/pkgs/tools/package-management/nix-template/default.nix b/pkgs/tools/package-management/nix-template/default.nix
index 60f08b8db6bc..91c1f9b26807 100644
--- a/pkgs/tools/package-management/nix-template/default.nix
+++ b/pkgs/tools/package-management/nix-template/default.nix
@@ -35,6 +35,7 @@ rustPlatform.buildRustPackage rec {
     wrapProgram $out/bin/nix-template \
       --prefix PATH : ${lib.makeBinPath [ nix ]}
 
+  '' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd nix-template \
       --bash <($out/bin/nix-template completions bash) \
       --fish <($out/bin/nix-template completions fish) \
diff --git a/pkgs/tools/security/bws/default.nix b/pkgs/tools/security/bws/default.nix
index aef7a39de280..4621bb1da5d0 100644
--- a/pkgs/tools/security/bws/default.nix
+++ b/pkgs/tools/security/bws/default.nix
@@ -55,7 +55,7 @@ rustPlatform.buildRustPackage rec {
 
   cargoTestFlags = [ "--package" "bws" ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd bws \
       --bash <($out/bin/bws completions bash) \
       --fish <($out/bin/bws completions fish) \
diff --git a/pkgs/tools/security/jwt-cli/default.nix b/pkgs/tools/security/jwt-cli/default.nix
index db049b1fa712..9eb65ffef46f 100644
--- a/pkgs/tools/security/jwt-cli/default.nix
+++ b/pkgs/tools/security/jwt-cli/default.nix
@@ -17,7 +17,7 @@ rustPlatform.buildRustPackage rec {
 
   buildInputs = lib.optional stdenv.isDarwin Security;
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd jwt \
       --bash <($out/bin/jwt completion bash) \
       --fish <($out/bin/jwt completion fish) \
diff --git a/pkgs/tools/security/kbs2/default.nix b/pkgs/tools/security/kbs2/default.nix
index 4f193d4ffccb..ae16b3f00c9a 100644
--- a/pkgs/tools/security/kbs2/default.nix
+++ b/pkgs/tools/security/kbs2/default.nix
@@ -39,6 +39,7 @@ rustPlatform.buildRustPackage rec {
   postInstall = ''
     mkdir -p $out/share/kbs2
     cp -r contrib/ $out/share/kbs2
+  '' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd kbs2 \
       --bash <($out/bin/kbs2 --completions bash) \
       --fish <($out/bin/kbs2 --completions fish) \
diff --git a/pkgs/tools/security/prs/default.nix b/pkgs/tools/security/prs/default.nix
index 39a629cb707c..02f6d0725f90 100644
--- a/pkgs/tools/security/prs/default.nix
+++ b/pkgs/tools/security/prs/default.nix
@@ -10,6 +10,7 @@
 , gtk3
 , libxcb
 , libxkbcommon
+, stdenv
 }:
 
 rustPlatform.buildRustPackage rec {
@@ -44,7 +45,7 @@ rustPlatform.buildRustPackage rec {
     libxkbcommon
   ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     for shell in bash fish zsh; do
       installShellCompletion --cmd prs --$shell <($out/bin/prs internal completions $shell --stdout)
     done
diff --git a/pkgs/tools/security/rbw/default.nix b/pkgs/tools/security/rbw/default.nix
index e46b742ee127..2de9d9ce9d5e 100644
--- a/pkgs/tools/security/rbw/default.nix
+++ b/pkgs/tools/security/rbw/default.nix
@@ -51,6 +51,7 @@ rustPlatform.buildRustPackage rec {
 
   postInstall = ''
     install -Dm755 -t $out/bin bin/git-credential-rbw
+  '' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd rbw \
       --bash <($out/bin/rbw gen-completions bash) \
       --fish <($out/bin/rbw gen-completions fish) \
diff --git a/pkgs/tools/security/sheesy-cli/default.nix b/pkgs/tools/security/sheesy-cli/default.nix
index bbe43cb69770..9df5da79e8a6 100644
--- a/pkgs/tools/security/sheesy-cli/default.nix
+++ b/pkgs/tools/security/sheesy-cli/default.nix
@@ -24,7 +24,7 @@ rustPlatform.buildRustPackage rec {
 
   cargoBuildFlags = [ "--bin" "sy" ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd sy \
       --bash <($out/bin/sy completions bash) \
       --fish <($out/bin/sy completions fish) \
diff --git a/pkgs/tools/security/shisho/default.nix b/pkgs/tools/security/shisho/default.nix
index a4635b0363e5..f5a137a84671 100644
--- a/pkgs/tools/security/shisho/default.nix
+++ b/pkgs/tools/security/shisho/default.nix
@@ -3,6 +3,7 @@
 , rustPlatform
 , installShellFiles
 , rustfmt
+, stdenv
 }:
 
 rustPlatform.buildRustPackage rec {
@@ -24,7 +25,7 @@ rustPlatform.buildRustPackage rec {
     rustfmt
   ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd shisho \
       --bash <($out/bin/shisho completion bash) \
       --fish <($out/bin/shisho completion fish) \
diff --git a/pkgs/tools/text/languagetool-rust/default.nix b/pkgs/tools/text/languagetool-rust/default.nix
index eda1060320c8..1772f9d1e305 100644
--- a/pkgs/tools/text/languagetool-rust/default.nix
+++ b/pkgs/tools/text/languagetool-rust/default.nix
@@ -68,7 +68,7 @@ rustPlatform.buildRustPackage rec {
     "--skip=test_words_delete"
   ];
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd ltrs \
       --bash <($out/bin/ltrs completions bash) \
       --fish <($out/bin/ltrs completions fish) \
diff --git a/pkgs/tools/text/termbook/default.nix b/pkgs/tools/text/termbook/default.nix
index d16dc05cba53..437016e25ec2 100644
--- a/pkgs/tools/text/termbook/default.nix
+++ b/pkgs/tools/text/termbook/default.nix
@@ -43,7 +43,7 @@ rustPlatform.buildRustPackage rec {
     ln -sf ${./Cargo.lock} Cargo.lock
   '';
 
-  postInstall = ''
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
     installShellCompletion --cmd termbook \
       --bash <($out/bin/termbook completions bash) \
       --fish <($out/bin/termbook completions fish) \