From 5c8c79a1cc773cacdf72474f2e5dff27d57f69f5 Mon Sep 17 00:00:00 2001 From: Bryan Lai Date: Mon, 24 Feb 2025 18:36:20 +0800 Subject: [PATCH] texpresso, texpresso.tectonic: simplify overrides The previous implementation (overriding `buildRustPackage`) breaks downstream `buildRustPackage.overrides` in subtle ways. It's thus better to use `.overrideAttrs` explicitly and reconstruct `cargoDeps` when needed. This commit should cause no rebuild, but the underlying change is necessary for an upcoming patch on tectonic itself. --- .../typesetting/tex/texpresso/tectonic.nix | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/pkgs/tools/typesetting/tex/texpresso/tectonic.nix b/pkgs/tools/typesetting/tex/texpresso/tectonic.nix index f5550e2a8c82..cd8baeee21b2 100644 --- a/pkgs/tools/typesetting/tex/texpresso/tectonic.nix +++ b/pkgs/tools/typesetting/tex/texpresso/tectonic.nix @@ -1,11 +1,5 @@ -{ tectonic-unwrapped, fetchFromGitHub }: -tectonic-unwrapped.override (old: { - rustPlatform = old.rustPlatform // { - buildRustPackage = - args: - old.rustPlatform.buildRustPackage ( - args - // { +{ tectonic-unwrapped, fetchFromGitHub, rustPlatform }: +tectonic-unwrapped.overrideAttrs (finalAttrs: prevAttrs: { pname = "texpresso-tonic"; src = fetchFromGitHub { owner = "let-def"; @@ -16,10 +10,18 @@ tectonic-unwrapped.override (old: { }; useFetchCargoVendor = true; cargoHash = "sha256-mqhbIv5r/5EDRDfP2BymXv9se2NCKxzRGqNqwqbD9A0="; + # rebuild cargoDeps by hand because `.overrideAttrs cargoHash` + # does not reconstruct cargoDeps (a known limitation): + cargoDeps = rustPlatform.fetchCargoVendor { + inherit (finalAttrs) src; + name = "${finalAttrs.pname}-${finalAttrs.version}"; + hash = finalAttrs.cargoHash; + patches = finalAttrs.cargoPatches; + }; # binary has a different name, bundled tests won't work doCheck = false; postInstall = '' - ${args.postInstall or ""} + ${prevAttrs.postInstall or ""} # Remove the broken `nextonic` symlink # It points to `tectonic`, which doesn't exist because the exe is @@ -27,7 +29,4 @@ tectonic-unwrapped.override (old: { rm $out/bin/nextonic ''; meta.mainProgram = "texpresso-tonic"; - } - ); - }; })