diff --git a/doc/packages/index.md b/doc/packages/index.md index 623fbe357d54..dbfe60ca3227 100644 --- a/doc/packages/index.md +++ b/doc/packages/index.md @@ -22,6 +22,7 @@ lhapdf.section.md locales.section.md etc-files.section.md nginx.section.md +nrfutil.section.md opengl.section.md shell-helpers.section.md python-tree-sitter.section.md diff --git a/doc/packages/nrfutil.section.md b/doc/packages/nrfutil.section.md new file mode 100644 index 000000000000..5767b0e0b946 --- /dev/null +++ b/doc/packages/nrfutil.section.md @@ -0,0 +1,13 @@ +# nrfutil {#sec-nrfutil} + +nrfutil can be built with its installables as following: + +```nix +(nrfutil.withExtensions [ + "nrfutil-completion" + "nrfutil-device" + "nrfutil-trace" +]) +``` + +Keep in mind that all installables might not be available for every supported platform. diff --git a/doc/redirects.json b/doc/redirects.json index bb9f1188f88a..46ccacdb3c17 100644 --- a/doc/redirects.json +++ b/doc/redirects.json @@ -322,6 +322,9 @@ "sec-nixpkgs-release-25.05-notable-changes": [ "release-notes.html#sec-nixpkgs-release-25.05-notable-changes" ], + "sec-nrfutil": [ + "index.html#sec-nrfutil" + ], "sec-overlays-install": [ "index.html#sec-overlays-install" ], diff --git a/pkgs/by-name/nr/nrfutil/package.nix b/pkgs/by-name/nr/nrfutil/package.nix index 926dcd030251..66b597809972 100644 --- a/pkgs/by-name/nr/nrfutil/package.nix +++ b/pkgs/by-name/nr/nrfutil/package.nix @@ -2,69 +2,109 @@ lib, stdenvNoCC, fetchurl, + + xz, zlib, libusb1, segger-jlink-headless, gcc, + autoPatchelfHook, versionCheckHook, + makeWrapper, + + symlinkJoin, + extensions ? [ ], + nrfutil, }: let - source = import ./source.nix; - supported = removeAttrs source [ "version" ]; + sources = import ./source.nix; + platformSources = + sources.${stdenvNoCC.system} or (throw "unsupported platform ${stdenvNoCC.system}"); - platform = supported.${stdenvNoCC.system} or (throw "unsupported platform ${stdenvNoCC.system}"); - -in -stdenvNoCC.mkDerivation (finalAttrs: { - pname = "nrfutil"; - inherit (source) version; - - src = fetchurl { - url = "https://files.nordicsemi.com/artifactory/swtools/external/nrfutil/packages/nrfutil/nrfutil-${platform.name}-${finalAttrs.version}.tar.gz"; - inherit (platform) hash; - }; - - nativeBuildInputs = [ - autoPatchelfHook - ]; - - buildInputs = [ - zlib - libusb1 - gcc.cc.lib - segger-jlink-headless - ]; - - dontConfigure = true; - dontBuild = true; - - installPhase = '' - runHook preInstall - - mkdir -p $out - mv data/* $out/ - - runHook postInstall - ''; - - doInstallCheck = true; - nativeInstallCheckInputs = [ - versionCheckHook - ]; - passthru.updateScript = ./update.sh; - - meta = with lib; { + sharedMeta = with lib; { description = "CLI tool for managing Nordic Semiconductor devices"; homepage = "https://www.nordicsemi.com/Products/Development-tools/nRF-Util"; changelog = "https://docs.nordicsemi.com/bundle/nrfutil/page/guides/revision_history.html"; license = licenses.unfree; - platforms = lib.attrNames supported; + platforms = lib.attrNames sources; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; maintainers = with maintainers; [ h7x4 ezrizhu ]; + }; + + packages = map ( + name: + let + package = platformSources.packages.${name}; + in + stdenvNoCC.mkDerivation (finalAttrs: { + pname = name; + inherit (package) version; + + src = fetchurl { + url = "https://files.nordicsemi.com/artifactory/swtools/external/nrfutil/packages/${name}/${name}-${platformSources.triplet}-${package.version}.tar.gz"; + inherit (package) hash; + }; + + nativeBuildInputs = [ + autoPatchelfHook + ]; + + buildInputs = [ + xz + zlib + libusb1 + gcc.cc.lib + segger-jlink-headless + ]; + + dontConfigure = true; + dontBuild = true; + + installPhase = '' + runHook preInstall + + mkdir -p $out + mv data/* $out/ + + runHook postInstall + ''; + + doInstallCheck = true; + nativeInstallCheckInputs = [ + versionCheckHook + ]; + versionCheckProgramArg = "--version"; + + meta = sharedMeta // { + mainProgram = name; + }; + }) + ) ([ "nrfutil" ] ++ extensions); + +in +symlinkJoin { + pname = "nrfutil"; + inherit (platformSources.packages.nrfutil) version; + + paths = packages; + + nativeBuildInputs = [ makeWrapper ]; + + postBuild = '' + wrapProgram $out/bin/nrfutil --prefix PATH ":" "$out/bin" + ''; + + passthru = { + updateScript = ./update.sh; + withExtensions = extensions: nrfutil.override { inherit extensions; }; + }; + + meta = sharedMeta // { mainProgram = "nrfutil"; }; -}) +} diff --git a/pkgs/by-name/nr/nrfutil/source.nix b/pkgs/by-name/nr/nrfutil/source.nix index ba5df8b720a5..e5663ff78268 100644 --- a/pkgs/by-name/nr/nrfutil/source.nix +++ b/pkgs/by-name/nr/nrfutil/source.nix @@ -1,7 +1,84 @@ { - version = "7.13.0"; + aarch64-linux = { + triplet = "aarch64-unknown-linux-gnu"; + packages = { + nrfutil = { + version = "8.1.1"; + hash = "sha256-y7ywCr9Ze3Uz1JQh0hNg2BOPKW2yEftYDaD8WzHWSxY="; + }; + nrfutil-ble-sniffer = { + version = "0.16.2"; + hash = "sha256-vCpSs9oUcqKPDKVoEtrqqY9Jy0AtbMwK8s398xvQ7Us="; + }; + nrfutil-device = { + version = "2.15.1"; + hash = "sha256-u8JlM7bxkR5x0fhTQRIkElpxot6jpKyL2SljFfoKj54="; + }; + nrfutil-mcu-manager = { + version = "0.8.0"; + hash = "sha256-jLsLN/Ny5zL4MSaKS3cb2L4WBCKZHVLiR2RkPAL8JnY="; + }; + nrfutil-sdk-manager = { + version = "1.8.0"; + hash = "sha256-DsGuOQ6rzwit5oeG4ZLObCOaxMt8WB+YYnuXRYtqq4U="; + }; + nrfutil-trace = { + version = "4.0.1"; + hash = "sha256-IR4P1tK/0P3d96Wnwciq7b3TJurENF2pYKaHu2yZIPk="; + }; + }; + }; x86_64-linux = { - name = "x86_64-unknown-linux-gnu"; - hash = "sha256-R3OF/340xEab+0zamfwvejY16fjy/3TrzMvQaBlVxHw="; + triplet = "x86_64-unknown-linux-gnu"; + packages = { + nrfutil = { + version = "8.1.1"; + hash = "sha256-asX1UbAE6X03lLC3l9e/9G2WgVRezfmRD6dyXJKb18Y="; + }; + nrfutil-91 = { + version = "0.5.0"; + hash = "sha256-ACQ+csYVIoANKV+CyAAD+drXQSb7CVUdvDYe76LELqs="; + }; + nrfutil-ble-sniffer = { + version = "0.16.2"; + hash = "sha256-4TGbn0HdlER5k76Hc5rCSVvyx89VdLQ56fMiGgWUvrU="; + }; + nrfutil-completion = { + version = "1.5.0"; + hash = "sha256-KA5h9/hJA66nkAAW1Tui+m60E/Iv9wzVPdeQqIQWpxc="; + }; + nrfutil-device = { + version = "2.15.1"; + hash = "sha256-zH/QtM1vM6BIiZHPLM23TRt2LCRUdJvmYN9oveotsH0="; + }; + nrfutil-mcu-manager = { + version = "0.8.0"; + hash = "sha256-ItU3kys1HMd06srLTzPtRoAW1YxwOt39LqjIQPMvmaI="; + }; + nrfutil-npm = { + version = "0.3.1"; + hash = "sha256-kQ63fVWR8RdGTQLA27Sg7jegYhtlkvXvLJsucifH4I0="; + }; + nrfutil-nrf5sdk-tools = { + version = "1.1.0"; + hash = "sha256-hLQhTEa5F2lrFxppKmVrD5PnIA3JPcP/M/r9bYizHk8="; + }; + nrfutil-sdk-manager = { + version = "1.8.0"; + hash = "sha256-+Z1xfEdTAcvYj+hjsW0z/dHRoIzVGWXjD6lSqoQvOPg="; + }; + nrfutil-suit = { + version = "0.9.0"; + hash = "sha256-uwbUgjpJNC27bSINyhfzTrOXIUi7GjFnPebg38apRKc="; + }; + nrfutil-toolchain-manager = { + version = "0.15.0"; + hash = "sha256-/bQx4yu1ybCO2TBd7MctxCANiYO5c1qCDYSjXm7hLcE="; + }; + nrfutil-trace = { + version = "4.0.1"; + hash = "sha256-YmsMQOD1vylaRwMWOhOA9xXePJR779P8im4Lcs7EcWk="; + }; + }; }; } diff --git a/pkgs/by-name/nr/nrfutil/update.sh b/pkgs/by-name/nr/nrfutil/update.sh index 199983e4aabb..72bb4763a361 100755 --- a/pkgs/by-name/nr/nrfutil/update.sh +++ b/pkgs/by-name/nr/nrfutil/update.sh @@ -12,23 +12,60 @@ set -euo pipefail declare -A architectures declare -A versions declare -A hashes +declare -a packages architectures["x86_64-linux"]="x86_64-unknown-linux-gnu" +architectures["aarch64-linux"]="aarch64-unknown-linux-gnu" +# NOTE: segger-jlink is not yet packaged for darwin +# architectures["x86_64-darwin"]="x86_64-apple-darwin" +# architectures["aarch64-darwin"]="aarch64-apple-darwin" + +packages=( + "nrfutil" + "nrfutil-91" + "nrfutil-ble-sniffer" + "nrfutil-completion" + "nrfutil-device" + "nrfutil-mcu-manager" + "nrfutil-npm" + "nrfutil-nrf5sdk-tools" + "nrfutil-sdk-manager" + "nrfutil-suit" + "nrfutil-toolchain-manager" + "nrfutil-trace" +) + BASE_URL="https://files.nordicsemi.com/artifactory/swtools/external/nrfutil" -for a in ${!architectures[@]}; do - versions["$a"]=$(curl "$BASE_URL/index/${architectures[${a}]}/index.json" | jq -r '.packages.nrfutil.latest_version') - hashes["$a"]=$(narhash "$BASE_URL/packages/nrfutil/nrfutil-${architectures[${a}]}-${versions[${a}]}.tar.gz") +for a in "${!architectures[@]}"; do + ARCH="${architectures["${a}"]}" + INDEX=$(curl "$BASE_URL/index/${ARCH}/index.json") + for p in "${!packages[@]}"; do + PKG="${packages["${p}"]}" + + jq -e -r ".packages.\"${PKG}\"" <<< "$INDEX" 1>/dev/null && { + versions["$a-$p"]=$(jq -r ".packages.\"${PKG}\".latest_version" <<< "$INDEX") + hashes["$a-$p"]=$(narhash "$BASE_URL/packages/${PKG}/${PKG}-${ARCH}-${versions["$a-$p"]}.tar.gz") + } + done done { printf "{\n" - printf " version = \"${versions["x86_64-linux"]}\";\n" - for a in ${!architectures[@]}; do - printf " ${a} = {\n" - printf " name = \"${architectures[${a}]}\";\n" - printf " hash = \"${hashes[${a}]}\";\n" + for a in "${!architectures[@]}"; do + printf " %s = {\n" "$a" + printf " triplet = \"%s\";\n" "${architectures["${a}"]}" + printf " packages = {\n" + for p in "${!packages[@]}"; do + test ${versions["$a-$p"]+_} && { + printf " %s = {\n" "${packages["${p}"]}" + printf " version = \"%s\";\n" "${versions["$a-$p"]}" + printf " hash = \"%s\";\n" "${hashes["$a-$p"]}" + printf " };\n" + } + done + printf " };\n" printf " };\n" done printf "}\n"