From d4109acb630b081f3e91852487efc51fbe7fa097 Mon Sep 17 00:00:00 2001 From: phanirithvij Date: Sat, 5 Jul 2025 11:36:20 +0530 Subject: [PATCH] dprint: installShellFiles when cross compiling Signed-off-by: phanirithvij --- pkgs/by-name/dp/dprint/package.nix | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pkgs/by-name/dp/dprint/package.nix b/pkgs/by-name/dp/dprint/package.nix index b89a9515e2e0..3a6fdc8f552c 100644 --- a/pkgs/by-name/dp/dprint/package.nix +++ b/pkgs/by-name/dp/dprint/package.nix @@ -3,6 +3,7 @@ stdenv, fetchFromGitHub, rustPlatform, + buildPackages, installShellFiles, writableTmpDirAsHomeHook, versionCheckHook, @@ -26,9 +27,7 @@ rustPlatform.buildRustPackage (finalAttrs: { useFetchCargoVendor = true; cargoHash = "sha256-OnrsuVK1gEDweldq+P8lDkkrHjklsG8MRpM0wqWsdlM="; - nativeBuildInputs = lib.optionals (stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ - installShellFiles - ]; + nativeBuildInputs = [ installShellFiles ]; cargoBuildFlags = [ "--package=dprint" @@ -51,15 +50,20 @@ rustPlatform.buildRustPackage (finalAttrs: { ]; postInstall = + let + dprint = + if stdenv.buildPlatform.canExecute stdenv.hostPlatform then + "$out/bin/dprint" + else + lib.getExe buildPackages.dprint; + in '' rm "$out/bin/test-process-plugin" - '' - + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' export DPRINT_CACHE_DIR="$(mktemp -d)" installShellCompletion --cmd dprint \ - --bash <($out/bin/dprint completions bash) \ - --zsh <($out/bin/dprint completions zsh) \ - --fish <($out/bin/dprint completions fish) + --bash <(${dprint} completions bash) \ + --zsh <(${dprint} completions zsh) \ + --fish <(${dprint} completions fish) ''; nativeInstallCheckInputs = [