Skip to content

Commit

Permalink
fluxcd: fix update script breakage caused by NixOS#341924
Browse files Browse the repository at this point in the history
  • Loading branch information
superherointj authored and mkg20001 committed Oct 10, 2024
1 parent 87ee97a commit b836809
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions pkgs/by-name/fl/fluxcd/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

let
version = "2.4.0";
hash = "sha256-b4mu/iijfALBm+7OIdKgZs55fR6xWfPgL6OMOgIOi3w=";
srcHash = "sha256-b4mu/iijfALBm+7OIdKgZs55fR6xWfPgL6OMOgIOi3w=";
vendorHash = "sha256-rVyirt6+D1qedbTvPZjLog16sMAq+zyFUmbjnJIieRg=";
manifestsSha256 = "sha256-85Ykc6B+DP9PVqwGbvqsQCUHpx/IzIP9TgOt3id7P5g=";
manifestsHash = "sha256-85Ykc6B+DP9PVqwGbvqsQCUHpx/IzIP9TgOt3id7P5g=";

manifests = fetchzip {
url = "https://github.com/fluxcd/flux2/releases/download/v${version}/manifests.tar.gz";
hash = manifestsSha256;
hash = manifestsHash;
stripRoot = false;
};
in
Expand All @@ -28,7 +28,7 @@ buildGoModule rec {
owner = "fluxcd";
repo = "flux2";
rev = "v${version}";
inherit hash;
hash = srcHash;
};

postUnpack = ''
Expand Down
16 changes: 8 additions & 8 deletions pkgs/by-name/fl/fluxcd/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ LATEST_TAG=$(curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} --silent https://api
LATEST_VERSION=$(echo "${LATEST_TAG}" | sed 's/^v//')

if [ ! "$OLD_VERSION" = "$LATEST_VERSION" ]; then
SHA256=$(nix-prefetch-url --quiet --unpack "https://github.com/fluxcd/flux2/archive/refs/tags/${LATEST_TAG}.tar.gz")
SHA256=$(nix hash convert --hash-algo sha256 --to sri "$SHA256")
SPEC_SHA256=$(nix-prefetch-url --quiet --unpack "https://github.com/fluxcd/flux2/releases/download/${LATEST_TAG}/manifests.tar.gz")
SPEC_SHA256=$(nix hash convert --hash-algo sha256 --to sri "$SPEC_SHA256")
SRC_SHA256=$(nix-prefetch-url --quiet --unpack "https://github.com/fluxcd/flux2/archive/refs/tags/${LATEST_TAG}.tar.gz")
SRC_HASH=$(nix hash convert --hash-algo sha256 --to sri "$SRC_SHA256")
MANIFESTS_SHA256=$(nix-prefetch-url --quiet --unpack "https://github.com/fluxcd/flux2/releases/download/${LATEST_TAG}/manifests.tar.gz")
MANIFESTS_HASH=$(nix hash convert --hash-algo sha256 --to sri "$MANIFESTS_SHA256")

setKV () {
sed -i "s|$1 = \".*\"|$1 = \"${2:-}\"|" "${FLUXCD_PATH}/package.nix"
}

setKV version "${LATEST_VERSION}"
setKV sha256 "${SHA256}"
setKV manifestsSha256 "${SPEC_SHA256}"
setKV srcHash "${SRC_HASH}"
setKV manifestsHash "${MANIFESTS_HASH}"
setKV vendorHash "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" # The same as lib.fakeHash

set +e
VENDOR_HASH=$(nix-build --no-out-link -A fluxcd "$NIXPKGS_PATH" 2>&1 >/dev/null | grep "got:" | cut -d':' -f2 | sed 's| ||g')
VENDOR_HASH=$(nix hash convert --hash-algo sha256 --to sri "$VENDOR_HASH")
VENDOR_SHA256=$(nix-build --no-out-link -A fluxcd "$NIXPKGS_PATH" 2>&1 >/dev/null | grep "got:" | cut -d':' -f2 | sed 's| ||g')
VENDOR_HASH=$(nix hash convert --hash-algo sha256 --to sri "$VENDOR_SHA256")
set -e

if [ -n "${VENDOR_HASH:-}" ]; then
Expand Down

0 comments on commit b836809

Please sign in to comment.