From 1e4f0c95f98ea59fa0a7d1ccfbbbad7de919b2b2 Mon Sep 17 00:00:00 2001 From: FliegendeWurst Date: Sat, 14 Jun 2025 14:34:45 +0200 Subject: [PATCH] docs: fix fetchpatch2 example, warn about short hashes --- pkgs/README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkgs/README.md b/pkgs/README.md index 6201839f23c4..789961fb4c9a 100644 --- a/pkgs/README.md +++ b/pkgs/README.md @@ -529,14 +529,19 @@ In the interest of keeping our maintenance burden and the size of Nixpkgs to a m { patches = [ (fetchpatch2 { - name = "fix-check-for-using-shared-freetype-lib.patch"; - url = "https://cgit.ghostscript.com/cgi-bin/cgit.cgi/ghostpdl.git/patch/?id=8f5d28536e4518716fdfe974e580194c8f57871d"; - hash = "sha256-uRcxaCjd+WAuGrXOmGfFeu79cUILwkRdBu48mwcBE7g="; + name = "make-no-atomics-a-soft-failure.patch"; + url = "https://github.com/boostorg/math/commit/7d482f6ebc356e6ec455ccb5f51a23971bf6ce5b.patch?full_index=1"; + hash = "sha256-9Goa0NTUdSOs1Vm+FnkoSFhw0o8ZLNOw6cLUqCVnF5Y="; }) ]; } ``` +> [!Warning] +> If the patch file contains short commit hashes, use `fetchpatch` instead of `fetchpatch2` ([tracking issue](https://github.com/NixOS/nixpkgs/issues/257446)). +> This is the case if the patch contains a line similar to `index 0c97fcc35..f533e464a 100644`. +> Depending on the patch source it is possible to expand the commit hash, in which case using `fetchpatch2` is acceptable (e.g. GitHub supports appending `?full_index=1` to the URL, as seen above). + If a patch is available online but does not cleanly apply, it can be modified in some fixed ways by using additional optional arguments for `fetchpatch2`. Check [the `fetchpatch` reference](https://nixos.org/manual/nixpkgs/unstable/#fetchpatch) for details. When adding patches in this manner you should be reasonably sure that the used URL is stable. Patches referencing open pull requests will change when the PR is updated and code forges (such as GitHub) usually garbage collect commits that are no longer reachable due to rebases/amends.