1c29673fcc
In 787af0f79f
I had to change ${go-modules} to $goModules to allow overrideAttrs to work;
However, env vars cannot contain -, so i had to change go-modules too.
This in turn broke nix-update because it uses the go-modules attr.
Instead of making nix-update more complicated, make go-modules naming match cargoDeps.
`fd --type f | xargs sd '\bgo-modules\b' 'goModules'`
and revert change to pkgs/applications/misc/dstask/default.nix
and pkgs/servers/http/dave/default.nix
and pkgs/os-specific/darwin/plistwatch/default.nix
release note added
39 lines
1.6 KiB
Bash
Executable file
39 lines
1.6 KiB
Bash
Executable file
#!/usr/bin/env nix-shell
|
|
#!nix-shell -i bash -p curl common-updater-scripts jq nix nix-prefetch-scripts moreutils
|
|
|
|
set -euxo pipefail
|
|
|
|
FILE="$(nix-instantiate --eval -E 'with import ./. {}; (builtins.unsafeGetAttrPos "version" grafana).file' | tr -d '"')"
|
|
replaceHash() {
|
|
old="${1?old hash missing}"
|
|
new="${2?new hash missing}"
|
|
awk -v OLD="$old" -v NEW="$new" '{
|
|
if (i=index($0, OLD)) {
|
|
$0 = substr($0, 1, i-1) NEW substr($0, i+length(OLD));
|
|
}
|
|
print $0;
|
|
}' "$FILE" | sponge "$FILE"
|
|
}
|
|
extractVendorHash() {
|
|
original="${1?original hash missing}"
|
|
result="$(nix-build -A grafana.goModules 2>&1 | tail -n3 | grep 'got:' | cut -d: -f2- | xargs echo || true)"
|
|
[ -z "$result" ] && { echo "$original"; } || { echo "$result"; }
|
|
}
|
|
|
|
oldVersion="$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion grafana" | tr -d '"')"
|
|
latest="$(curl https://api.github.com/repos/grafana/grafana/releases/latest | jq '.tag_name' -r | tr -d 'v')"
|
|
|
|
targetVersion="${1:-$latest}"
|
|
if [ ! "${oldVersion}" = "${targetVersion}" ]; then
|
|
update-source-version grafana "${targetVersion#v}"
|
|
oldStaticHash="$(nix-instantiate --eval -A grafana.srcStatic.outputHash | tr -d '"')"
|
|
newStaticHash="$(nix-prefetch-url "https://dl.grafana.com/oss/release/grafana-${targetVersion#v}.linux-amd64.tar.gz")"
|
|
replaceHash "$oldStaticHash" "$newStaticHash"
|
|
goHash="$(nix-instantiate --eval -A grafana.vendorSha256 | tr -d '"')"
|
|
emptyHash="$(nix-instantiate --eval -A lib.fakeSha256 | tr -d '"')"
|
|
replaceHash "$goHash" "$emptyHash"
|
|
replaceHash "$emptyHash" "$(extractVendorHash "$goHash")"
|
|
nix-build -A grafana
|
|
else
|
|
echo "grafana is already up-to-date"
|
|
fi
|