push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,120 @@
# This function downloads and normalizes a patch/diff file.
# This is primarily useful for dynamically generated patches,
# such as GitHub's or cgit's, where the non-significant content parts
# often change with updating of git or cgit.
# stripLen acts as the -p parameter when applying a patch.
{
lib,
fetchurl,
patchutils,
}:
{
relative ? null,
stripLen ? 0,
decode ? "cat", # custom command to decode patch e.g. base64 -d
extraPrefix ? null,
excludes ? [ ],
includes ? [ ],
revert ? false,
postFetch ? "",
nativeBuildInputs ? [ ],
...
}@args:
let
args' =
if relative != null then
{
stripLen = 1 + lib.length (lib.splitString "/" relative) + stripLen;
extraPrefix = lib.optionalString (extraPrefix != null) extraPrefix;
}
else
{
inherit stripLen extraPrefix;
};
in
let
inherit (args') stripLen extraPrefix;
in
lib.throwIfNot (excludes == [ ] || includes == [ ])
"fetchpatch: cannot use excludes and includes simultaneously"
fetchurl
(
{
nativeBuildInputs = [ patchutils ] ++ nativeBuildInputs;
postFetch = ''
tmpfile="$TMPDIR/patch"
if [ ! -s "$out" ]; then
echo "error: Fetched patch file '$out' is empty!" 1>&2
exit 1
fi
set +e
${decode} < "$out" > "$tmpfile"
if [ $? -ne 0 ] || [ ! -s "$tmpfile" ]; then
echo 'Failed to decode patch with command "'${lib.escapeShellArg decode}'"' >&2
echo 'Fetched file was (limited to 128 bytes):' >&2
od -A x -t x1z -v -N 128 "$out" >&2
exit 1
fi
set -e
mv "$tmpfile" "$out"
lsdiff \
${lib.optionalString (relative != null) "-p1 -i ${lib.escapeShellArg relative}/'*'"} \
"$out" \
| sort -u | sed -e 's/[*?]/\\&/g' \
| xargs -I{} --delimiter='\n' \
filterdiff \
--include={} \
--strip=${toString stripLen} \
${
lib.optionalString (extraPrefix != null) ''
--addoldprefix=a/${lib.escapeShellArg extraPrefix} \
--addnewprefix=b/${lib.escapeShellArg extraPrefix} \
''
} \
--clean "$out" > "$tmpfile"
if [ ! -s "$tmpfile" ]; then
echo "error: Normalized patch '$tmpfile' is empty (while the fetched file was not)!" 1>&2
echo "Did you maybe fetch a HTML representation of a patch instead of a raw patch?" 1>&2
echo "Fetched file was:" 1>&2
cat "$out" 1>&2
exit 1
fi
filterdiff \
-p1 \
${toString (map (x: "-x ${lib.escapeShellArg x}") excludes)} \
${toString (map (x: "-i ${lib.escapeShellArg x}") includes)} \
"$tmpfile" > "$out"
if [ ! -s "$out" ]; then
echo "error: Filtered patch '$out' is empty (while the original patch file was not)!" 1>&2
echo "Check your includes and excludes." 1>&2
echo "Normalized patch file was:" 1>&2
cat "$tmpfile" 1>&2
exit 1
fi
''
+ lib.optionalString revert ''
interdiff "$out" /dev/null > "$tmpfile"
mv "$tmpfile" "$out"
''
+ postFetch;
}
// removeAttrs args [
"relative"
"stripLen"
"decode"
"extraPrefix"
"excludes"
"includes"
"revert"
"postFetch"
"nativeBuildInputs"
]
)

View File

@@ -0,0 +1,69 @@
{ testers, fetchpatch, ... }:
let
isFetchpatch2 = fetchpatch.version == 2;
in
{
simple = testers.invalidateFetcherByDrvHash fetchpatch {
url = "https://github.com/facebook/zstd/pull/2724/commits/e1f85dbca3a0ed5ef06c8396912a0914db8dea6a.patch";
sha256 =
if isFetchpatch2 then
"sha256-w4yU0wt64d0WkuBQPeGf8vn5TH6qSBJvNIgka9QK+/Q="
else
"sha256-PuYAqnJWAE+L9bsroOnnBGJhERW8LHrGSLtIEkKU9vg=";
};
relative = testers.invalidateFetcherByDrvHash fetchpatch {
url = "https://github.com/boostorg/math/commit/7d482f6ebc356e6ec455ccb5f51a23971bf6ce5b.patch";
relative = "include";
sha256 =
if isFetchpatch2 then
"sha256-1TtmuKeNIl/Yp+sfzBMR8Ue78tPIgjqGgjasa5IN52o="
else
"sha256-KlmIbixcds6GyKYt1fx5BxDIrU7msrgDdYo9Va/KJR4=";
};
full = testers.invalidateFetcherByDrvHash fetchpatch {
url = "https://github.com/boostorg/math/commit/7d482f6ebc356e6ec455ccb5f51a23971bf6ce5b.patch";
relative = "test";
stripLen = 1;
extraPrefix = "foo/bar/";
excludes = [ "foo/bar/bernoulli_no_atomic_mp.cpp" ];
revert = true;
sha256 =
if isFetchpatch2 then
"sha256-+UKmEbr2rIAweCav/hR/7d4ZrYV84ht/domTrHtm8sM="
else
"sha256-+UKmEbr2rIAweCav/hR/7d4ZrYV84ht/domTrHtm8sM=";
};
decode = testers.invalidateFetcherByDrvHash fetchpatch {
name = "gcc.patch";
url = "https://chromium.googlesource.com/aosp/platform/external/libchrome/+/f37ae3b1a873d74182a2ac31d96742ead9c1f523^!?format=TEXT";
decode = "base64 -d";
sha256 =
if isFetchpatch2 then
"sha256-oMvPlmzE51ArI+EvFxONXkqmNee39106/O1ikG0Bdso="
else
"sha256-SJHk8XrutqAyoIdORlhCpBCN626P+uzed7mjKz5eQYY=";
};
fileWithSpace = testers.invalidateFetcherByDrvHash fetchpatch {
url = "https://github.com/jfly/annoying-filenames/commit/1e86a219f5fc9c4137b409bc9c38036f3922724b.patch";
sha256 =
if isFetchpatch2 then
"sha256-RB6pjigoXtzHILkGFXYd3Lz2aM9DvO0NRmLdey1N6gg="
else
"sha256-aptUvVojqIIIVNuHqkl+C+dZBGFfs+1MUd0FNV+4j4E=";
};
fileWithApostrophe = testers.invalidateFetcherByDrvHash fetchpatch {
url = "https://github.com/jfly/annoying-filenames/commit/8b6d8f8d7094ce646523b3369cfdf5030289c66c.patch";
sha256 =
if isFetchpatch2 then
"sha256-CrQFmVvLEvWpo2ucVrWyLb5qk2GVOxyUbFN3hp9sV68="
else
"sha256-CrQFmVvLEvWpo2ucVrWyLb5qk2GVOxyUbFN3hp9sV68=";
};
}