treewide: Simplify use of update-source-version

- `--ignore-same-version` allows us to not call it twice.
- with that, we can also omit version, to allow us updating e.g. `cargoDeps` hash
This commit is contained in:
Jan Tojnar 2024-06-09 19:46:03 +02:00
parent 4627e4849e
commit 0421c816ba
26 changed files with 34 additions and 101 deletions

View File

@ -9,18 +9,14 @@ function set_hash_for_linux() {
local arch=$1
pkg_hash=$(nix-prefetch-url https://www.reaper.fm/files/${reaper_ver%.*}.x/reaper${reaper_ver/./}_linux_$arch.tar.xz)
pkg_hash=$(nix hash to-sri "sha256:$pkg_hash")
# reset the version so the second architecture update doesn't get ignored
update-source-version reaper 0 "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" --system=$arch-linux
update-source-version reaper "${reaper_ver}" "$pkg_hash" --system=$arch-linux
update-source-version reaper "${reaper_ver}" "$pkg_hash" --system=$arch-linux --ignore-same-version
}
function set_hash_for_darwin() {
local arch=$1
pkg_hash=$(nix-prefetch-url https://www.reaper.fm/files/${reaper_ver%.*}.x/reaper${reaper_ver/./}_universal.dmg)
pkg_hash=$(nix hash to-sri "sha256:$pkg_hash")
# reset the version so the second architecture update doesn't get ignored
update-source-version reaper 0 "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" --system=$arch-darwin
update-source-version reaper "${reaper_ver}" "$pkg_hash" --system=$arch-darwin
update-source-version reaper "${reaper_ver}" "$pkg_hash" --system=$arch-darwin --ignore-same-version
}
set_hash_for_linux aarch64

View File

@ -34,7 +34,6 @@ git -C $repo verify-tag v${version}
rm -rf $repo/.git
hash=$(nix hash path $repo)
(cd "$nixpkgs" && update-source-version electrs "$version" "$hash")
sed -i 's|cargoHash = .*|cargoHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";|' "$scriptDir/default.nix"
(cd "$nixpkgs" && update-source-version electrs "$version" "$hash" && update-source-version electrs --ignore-same-version --source-key=cargoDeps)
echo
echo "electrs: $oldVersion -> $version"

View File

@ -25,7 +25,6 @@ git -C "$repo" checkout "tags/v${version}"
rm -rf "${repo}/.git"
hashcheck=$(nix hash path "$repo")
(cd "$nixpkgs" && update-source-version teos "$version" "$hashcheck")
sed -i 's|cargoHash = .*|cargoHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";|' "${scriptDir}/default.nix"
(cd "$nixpkgs" && update-source-version teos "$version" "$hashcheck" && update-source-version teos --ignore-same-version --source-key=cargoDeps)
echo
echo "rust-teos: $oldVersion -> $version"

View File

@ -192,10 +192,7 @@ stdenv.mkDerivation (rec {
fi
for platform in ${lib.escapeShellArgs meta.platforms}; do
# The script will not perform an update when the version attribute is up to date from previous platform run
# We need to clear it before each run
update-source-version "${packageAttribute}.${primaryBinary}" 0 "${lib.fakeSha256}" --file="$versionFile" --version-key=buildVersion --source-key="sources.$platform"
update-source-version "${packageAttribute}.${primaryBinary}" "$latestVersion" --file="$versionFile" --version-key=buildVersion --source-key="sources.$platform"
update-source-version "${packageAttribute}.${primaryBinary}" "$latestVersion" --ignore-same-version --file="$versionFile" --version-key=buildVersion --source-key="sources.$platform"
done
'';
in

View File

@ -42,10 +42,7 @@ in mkDerivation rec {
latestVersion="$(curl -sS https://www.rescuetime.com/release-notes/linux | pup '.release:first-of-type h2 strong text{}' | tr -d '\n')"
for platform in ${lib.concatStringsSep " " meta.platforms}; do
# The script will not perform an update when the version attribute is up to date from previous platform run
# We need to clear it before each run
update-source-version ${pname} 0 $(yes 0 | head -64 | tr -d "\n") --system=$platform
update-source-version ${pname} "$latestVersion" --system=$platform
update-source-version ${pname} "$latestVersion" --system=$platform --ignore-same-version
done
'';

View File

@ -184,10 +184,7 @@ stdenv.mkDerivation (finalAttrs: {
)"
for variant in gtk3 gtk2; do
# The script will not perform an update when the version attribute is up to date from previous platform run
# We need to clear it before each run
update-source-version palemoon-bin 0 "${lib.fakeHash}" --source-key="sources.$variant"
update-source-version palemoon-bin "$version" --source-key="sources.$variant"
update-source-version palemoon-bin "$version" --ignore-same-version --source-key="sources.$variant"
done
'';
};

View File

@ -59,7 +59,6 @@ in writeShellScript "update-${pname}" ''
sha256=$(grep "${name}-$arch-$version.tar.xz" "$HOME/shasums" | cut -d" " -f1)
hash=$(nix hash to-sri --type sha256 "$sha256")
update-source-version "${pname}" "0" "sha256-${lib.fakeSha256}" --source-key="sources.$platform"
update-source-version "${pname}" "$version" "$hash" --source-key="sources.$platform"
update-source-version "${pname}" "$version" "$hash" --ignore-same-version --source-key="sources.$platform"
done
''

View File

@ -8,8 +8,7 @@ version=$(curl -sS https://vivaldi.com/download/ | sed -rne 's/.*vivaldi-stable_
update_hash() {
url="https://downloads.vivaldi.com/stable/vivaldi-stable_$version-1_$2.deb"
hash=$(nix hash to-sri --type sha256 $(nix-prefetch-url --type sha256 "$url"))
update-source-version vivaldi 0 sha256-BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB= --system=$1
update-source-version vivaldi "$version" "$hash" --system=$1
update-source-version vivaldi "$version" "$hash" --system=$1 --ignore-same-version
}
update_hash aarch64-linux arm64

View File

@ -220,8 +220,7 @@ stdenv.mkDerivation {
new_version=$(echo $package_info | jq -r '.data.version_number' | sed -n 's/.*@V//p')
sha256_hash=$(nix-prefetch-url $update_link)
sri_hash=$(nix hash to-sri --type sha256 $sha256_hash)
update-source-version feishu 0 ${lib.fakeSha256} --system=$platform --source-key="sources.$platform"
update-source-version feishu $new_version $sri_hash $update_link --system=$platform --source-key="sources.$platform"
update-source-version feishu $new_version $sri_hash $update_link --system=$platform --ignore-same-version --source-key="sources.$platform"
done
'';
};

View File

@ -63,11 +63,8 @@ stdenvNoCC.mkDerivation {
#!nix-shell -i bash --argstr aarch64Url ${aarch64Url} --argstr x86_64Url ${x86_64Url} --argstr version ${version} ${updateNix}
set -eou pipefail
# reset version first so that both platforms are always updated and in sync
update-source-version libreoffice-bin 0 ${lib.fakeSha256} --file=${defaultNixFile} --system=aarch64-darwin
update-source-version libreoffice-bin $newVersion $newAarch64Sha256 --file=${defaultNixFile} --system=aarch64-darwin
update-source-version libreoffice-bin 0 ${lib.fakeSha256} --file=${defaultNixFile} --system=x86_64-darwin
update-source-version libreoffice-bin $newVersion $newX86_64Sha256 --file=${defaultNixFile} --system=x86_64-darwin
update-source-version libreoffice-bin $newVersion $newAarch64Sha256 --file=${defaultNixFile} --system=aarch64-darwin --ignore-same-version
update-source-version libreoffice-bin $newVersion $newX86_64Sha256 --file=${defaultNixFile} --system=x86_64-darwin --ignore-same-version
'';
meta = with lib; {

View File

@ -196,10 +196,7 @@ stdenv.mkDerivation (rec {
fi
for platform in ${lib.escapeShellArgs meta.platforms}; do
# The script will not perform an update when the version attribute is up to date from previous platform run
# We need to clear it before each run
update-source-version "${packageAttribute}.${primaryBinary}" 0 "${lib.fakeSha256}" --file="$versionFile" --version-key=buildVersion --source-key="sources.$platform"
update-source-version "${packageAttribute}.${primaryBinary}" "$latestVersion" --file="$versionFile" --version-key=buildVersion --source-key="sources.$platform"
update-source-version "${packageAttribute}.${primaryBinary}" "$latestVersion" --ignore-same-version --file="$versionFile" --version-key=buildVersion --source-key="sources.$platform"
done
'';
in

View File

@ -92,14 +92,10 @@ stdenvNoCC.mkDerivation {
X86_64_LINUX_SHA256=$(cat SHA256SUMS | awk '/Linux-x86_64/{print $1}')
# reset version first so that all platforms are always updated and in sync
update-source-version lima-bin 0 ${lib.fakeSha256} --file=${lima-bin} --system=aarch64-darwin
update-source-version lima-bin $LATEST_VERSION $AARCH64_DARWIN_SHA256 --file=${lima-bin} --system=aarch64-darwin
update-source-version lima-bin 0 ${lib.fakeSha256} --file=${lima-bin} --system=x86_64-darwin
update-source-version lima-bin $LATEST_VERSION $X86_64_DARWIN_SHA256 --file=${lima-bin} --system=x86_64-darwin
update-source-version lima-bin 0 ${lib.fakeSha256} --file=${lima-bin} --system=aarch64-linux
update-source-version lima-bin $LATEST_VERSION $AARCH64_LINUX_SHA256 --file=${lima-bin} --system=aarch64-linux
update-source-version lima-bin 0 ${lib.fakeSha256} --file=${lima-bin} --system=x86_64-linux
update-source-version lima-bin $LATEST_VERSION $X86_64_LINUX_SHA256 --file=${lima-bin} --system=x86_64-linux
update-source-version lima-bin $LATEST_VERSION $AARCH64_DARWIN_SHA256 --file=${lima-bin} --ignore-same-version --system=aarch64-darwin
update-source-version lima-bin $LATEST_VERSION $X86_64_DARWIN_SHA256 --file=${lima-bin} --ignore-same-version --system=x86_64-darwin
update-source-version lima-bin $LATEST_VERSION $AARCH64_LINUX_SHA256 --file=${lima-bin} --ignore-same-version --system=aarch64-linux
update-source-version lima-bin $LATEST_VERSION $X86_64_LINUX_SHA256 --file=${lima-bin} --ignore-same-version --system=x86_64-linux
rm SHA256SUMS
'';

View File

@ -20,6 +20,5 @@ do
prefetch=$(nix-prefetch-url "https://github.com/dbeaver/dbeaver/releases/download/$latestVersion/dbeaver-ce-$latestVersion-$2")
hash=$(nix-hash --type sha256 --to-sri $prefetch)
update-source-version dbeaver-bin 0 "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" --system=$1
update-source-version dbeaver-bin $latestVersion $hash --system=$1
update-source-version dbeaver-bin $latestVersion $hash --system=$1 --ignore-same-version
done

View File

@ -99,11 +99,7 @@ stdenv.mkDerivation (finalAttrs: {
fi
for component in src gmic_stdlib; do
# The script will not perform an update when the version attribute is
# up to date from previous platform run; we need to clear it before
# each run
update-source-version "--source-key=$component" "gmic" 0 "${lib.fakeHash}"
update-source-version "--source-key=$component" "gmic" $latestVersion
update-source-version "--source-key=$component" "gmic" $latestVersion --ignore-same-version
done
'';
};

View File

@ -73,8 +73,7 @@ lib.checkListOfEnum "sketchybar-app-font: artifacts" artifacts artifactList
exit 0
fi
for artifact in ${lib.escapeShellArgs (lib.mapAttrsToList(a: _: a) finalAttrs.passthru.sources)}; do
update-source-version "sketchybar-app-font" "0" "${lib.fakeHash}" --source-key="sources.$artifact"
update-source-version "sketchybar-app-font" "$NEW_VERSION" --source-key="sources.$artifact"
update-source-version "sketchybar-app-font" "$NEW_VERSION" --ignore-same-version --source-key="sources.$artifact"
done
'';
};

View File

@ -121,8 +121,7 @@ stdenv'.mkDerivation (finalAttrs: {
exit 0
fi
for platform in ${lib.escapeShellArgs finalAttrs.meta.platforms}; do
update-source-version "yabai" "0" "${lib.fakeHash}" --source-key="sources.$platform"
update-source-version "yabai" "$NEW_VERSION" --source-key="sources.$platform"
update-source-version "yabai" "$NEW_VERSION" --ignore-same-version --source-key="sources.$platform"
done
'';
};

View File

@ -184,14 +184,7 @@ stdenv.mkDerivation (finalAttrs: {
jq
nix
]}
# update-source-version does not allow updating to the same version so we need to clear it temporarily.
# Get the current version so that we can restore it later.
latestVersion=$(nix-instantiate --eval -A librsvg.version | jq --raw-output)
# Clear the version. Provide hash so that we do not need to do pointless TOFU.
# Needs to be a fake SRI hash that is non-zero, since u-s-v uses zero as a placeholder.
# Also cannot be here verbatim or u-s-v would be confused what to replace.
update-source-version librsvg 0 "sha256-${lib.fixedWidthString 44 "B" "="}" --source-key=cargoDeps > /dev/null
update-source-version librsvg "$latestVersion" --source-key=cargoDeps > /dev/null
update-source-version librsvg --ignore-same-version --source-key=cargoDeps > /dev/null
''
];
# Experimental feature: do not copy!

View File

@ -144,8 +144,7 @@ stdenv.mkDerivation (finalAttrs: {
fi
for source in ${lib.concatStringsSep " " (builtins.attrNames finalAttrs.passthru.updateables)}; do
update-source-version "$UPDATE_NIX_ATTR_PATH.updateables.$source" "0" "sha256-${lib.fakeSha256}"
update-source-version "$UPDATE_NIX_ATTR_PATH.updateables.$source" "$NEW_VERSION"
update-source-version "$UPDATE_NIX_ATTR_PATH.updateables.$source" "$NEW_VERSION" --ignore-same-version
done
'';

View File

@ -88,8 +88,7 @@ stdenv.mkDerivation rec {
fi
for platform in ${lib.escapeShellArgs meta.platforms}; do
update-source-version "blackfire" "0" "${lib.fakeSha256}" --source-key="sources.$platform"
update-source-version "blackfire" "$NEW_VERSION" --source-key="sources.$platform"
update-source-version "blackfire" "$NEW_VERSION" --ignore-same-version --source-key="sources.$platform"
done
'';
};

View File

@ -107,8 +107,7 @@ stdenv.mkDerivation (finalAttrs: {
fi
for source in ${lib.concatStringsSep " " (builtins.attrNames finalAttrs.passthru.updateables)}; do
update-source-version "$UPDATE_NIX_ATTR_PATH.updateables.$source" "0" "sha256-${lib.fakeSha256}"
update-source-version "$UPDATE_NIX_ATTR_PATH.updateables.$source" "$NEW_VERSION"
update-source-version "$UPDATE_NIX_ATTR_PATH.updateables.$source" "$NEW_VERSION" --ignore-same-version
done
'';

View File

@ -20,8 +20,7 @@ all_versions=$(jq --exit-status --raw-output \
<<< "$response")
latest_version=$(sort --version-sort <<< "$all_versions" | tail -n 1)
for platform in x86_64-linux x86_64-darwin; do
update-source-version sauce-connect 0 "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" \
--source-key="passthru.sources.$platform"
update-source-version sauce-connect "$latest_version" \
--ignore-same-version \
--source-key="passthru.sources.$platform"
done

View File

@ -75,8 +75,7 @@ stdenvNoCC.mkDerivation rec {
exit 0
fi
for platform in ${lib.escapeShellArgs meta.platforms}; do
update-source-version "bun" "0" "${lib.fakeHash}" --source-key="sources.$platform"
update-source-version "bun" "$NEW_VERSION" --source-key="sources.$platform"
update-source-version "bun" "$NEW_VERSION" --ignore-same-version --source-key="sources.$platform"
done
'';
};

View File

@ -70,10 +70,7 @@ stdenv.mkDerivation rec {
latestSha="$(nix-prefetch-url $dlUrl)"
# The script will not perform an update when the version attribute is up to date from previous platform run
# We need to clear it before each run
update-source-version plexRaw 0 $(yes 0 | head -64 | tr -d "\n") --system=$platform
update-source-version plexRaw "$latestVersion" "$latestSha" --system=$platform
update-source-version plexRaw "$latestVersion" "$latestSha" --system=$platform --ignore-same-version
done
'';

View File

@ -114,8 +114,7 @@ stdenv.mkDerivation rec {
fi
for platform in ${lib.escapeShellArgs meta.platforms}; do
update-source-version "powershell" "0" "${lib.fakeHash}" --source-key="sources.$platform"
update-source-version "powershell" "$NEW_VERSION" --source-key="sources.$platform"
update-source-version "powershell" "$NEW_VERSION" --ignore-same-version --source-key="sources.$platform"
done
'';
};

View File

@ -21,6 +21,5 @@ do
prefetch=$(nix-prefetch-url https://www.archimatetool.com/downloads/archi/$latestVersion/$2)
hash=$(nix-hash --type sha256 --to-sri $prefetch)
update-source-version archi 0 "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" --system=$1
update-source-version archi $latestVersion $hash --system=$1
update-source-version archi $latestVersion $hash --system=$1 --ignore-same-version
done

View File

@ -24,23 +24,8 @@ function get_hash() {
nix hash to-sri "sha256:$pkg_hash"
}
# aarch64-darwin
# reset version first so that all platforms are always updated and in sync
update-source-version recyclarr 0 "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" --system="aarch64-darwin"
update-source-version recyclarr "$latestVersion" $(get_hash osx arm64 "$latestVersion") --system="aarch64-darwin"
# x86_64-darwin
# reset version first so that all platforms are always updated and in sync
update-source-version recyclarr 0 "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" --system="x86_64-darwin"
update-source-version recyclarr "$latestVersion" $(get_hash osx x64 "$latestVersion") --system="x86_64-darwin"
# aarch64-linux
# reset version first so that all platforms are always updated and in sync
update-source-version recyclarr 0 "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" --system="aarch64-linux"
update-source-version recyclarr "$latestVersion" $(get_hash linux arm64 "$latestVersion") --system="aarch64-linux"
# x86_64-linux
# reset version first so that all platforms are always updated and in sync
update-source-version recyclarr 0 "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" --system="x86_64-linux"
update-source-version recyclarr "$latestVersion" $(get_hash linux x64 "$latestVersion") --system="x86_64-linux"
update-source-version recyclarr "$latestVersion" $(get_hash osx arm64 "$latestVersion") --system="aarch64-darwin" --ignore-same-version
update-source-version recyclarr "$latestVersion" $(get_hash osx x64 "$latestVersion") --system="x86_64-darwin" --ignore-same-version
update-source-version recyclarr "$latestVersion" $(get_hash linux arm64 "$latestVersion") --system="aarch64-linux" --ignore-same-version
update-source-version recyclarr "$latestVersion" $(get_hash linux x64 "$latestVersion") --system="x86_64-linux" --ignore-same-version