···49495050stdenv.mkDerivation (finalAttrs: {
5151 pname = "uhd";
5252- # UHD seems to use three different version number styles: x.y.z, xxx_yyy_zzz
5353- # and xxx.yyy.zzz. Hrmpf... style keeps changing
5454- version = "4.4.0.0";
5252+ # NOTE: Use the following command to update the package, and the uhdImageSrc attribute:
5353+ #
5454+ # nix-shell maintainers/scripts/update.nix --argstr package uhd --argstr commit true
5555+ #
5656+ version = "4.5.0.0";
55575658 outputs = [ "out" "dev" ];
5759···5961 owner = "EttusResearch";
6062 repo = "uhd";
6163 rev = "v${finalAttrs.version}";
6262- sha256 = "sha256-khVOHlvacZc4EMg4m55rxEqPvLY1xURpAfOW905/3jg=";
6464+ # The updateScript relies on the `src` using `hash`, and not `sha256. To
6565+ # update the correct hash for the `src` vs the `uhdImagesSrc`
6666+ hash = "sha256-0EqMBaQiNr8PE542YNkPvX3o1HhnhrO0Kz1euphY6Ps=";
6367 };
6468 # Firmware images are downloaded (pre-built) from the respective release on Github
6569 uhdImagesSrc = fetchurl {
6670 url = "https://github.com/EttusResearch/uhd/releases/download/v${finalAttrs.version}/uhd-images_${finalAttrs.version}.tar.xz";
6767- sha256 = "V8ldW8bvYWbrDAvpWpHcMeLf9YvF8PIruDAyNK/bru4=";
7171+ # Please don't convert this to a hash, in base64, see comment near src's
7272+ # hash.
7373+ sha256 = "13cn41wv7vldk4vx7vy3jbb3wb3a5vpfg3ay893klpi6vzxc1dly";
6874 };
6969- # TODO: Add passthru.updateScript that will update both of the above hashes...
7575+ passthru = {
7676+ updateScript = [
7777+ ./update.sh
7878+ # Pass it this file name as argument
7979+ (builtins.unsafeGetAttrPos "pname" finalAttrs.finalPackage).file
8080+ ];
8181+ };
70827183 cmakeFlags = [
7284 "-DENABLE_LIBUHD=ON"
+27
pkgs/applications/radio/uhd/update.sh
···11+#!/usr/bin/env nix-shell
22+#!nix-shell -i bash -p jq nix nix-prefetch-github
33+44+set -euo pipefail
55+echoerr() { echo "$@" 1>&2; }
66+77+fname="$1"
88+echoerr got fname $fname
99+shift
1010+latest_release=$(curl --silent https://api.github.com/repos/EttusResearch/uhd/releases/latest)
1111+version=$(jq -r '.tag_name' <<<"$latest_release" | cut -c2-)
1212+# Update version, if needed
1313+if grep -q 'version = "'$version $fname; then
1414+ echoerr Current version $version is the latest available
1515+ exit 0;
1616+fi
1717+echoerr got version $version
1818+sed -i -E 's/(version = ").*(";)/\1'$version'\2/g' $fname
1919+# Verify the sed command above did not fail
2020+grep -q $version $fname
2121+# Update srcHash
2222+srcHash="$(nix-prefetch-github EttusResearch uhd --rev v${version} | jq --raw-output .hash)"
2323+sed -i -E 's#(hash = ").*(";)#\1'$srcHash'\2#g' $fname
2424+grep -q $srcHash $fname
2525+imageHash="$(nix-prefetch-url https://github.com/EttusResearch/uhd/releases/download/v${version}/uhd-images_${version}.tar.xz)"
2626+sed -i -E 's#(sha256 = ").*(";)#\1'$imageHash'\2#g' $fname
2727+grep -q $imageHash $fname