nrfutil: 7.13.0 -> 8.1.1, package all installables (#440671)

This commit is contained in:
h7x4
2025-10-18 07:50:50 +00:00
committed by GitHub
6 changed files with 267 additions and 57 deletions

View File

@@ -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

View File

@@ -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.

View File

@@ -325,6 +325,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"
],

View File

@@ -2,69 +2,148 @@
lib,
stdenvNoCC,
fetchurl,
xz,
zlib,
libusb1,
segger-jlink-headless,
gcc,
autoPatchelfHook,
versionCheckHook,
makeWrapper,
installShellFiles,
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"
"nrfutil-completion"
]
++ extensions
);
in
symlinkJoin {
pname = "nrfutil";
inherit (platformSources.packages.nrfutil) version;
paths = packages;
nativeBuildInputs = [
makeWrapper
installShellFiles
];
postBuild =
let
wrapProgramArgs = lib.concatStringsSep " " (
[
''--prefix PATH : "$out/bin"''
''--prefix PATH : "$out"/lib/nrfutil-npm''
''--prefix PATH : "$out"/lib/nrfutil-nrf5sdk-tools''
''--set NRF_JLINK_DLL_PATH '${segger-jlink-headless}'/lib/libjlinkarm.so''
''--set NRFUTIL_BLE_SNIFFER_SHIM_BIN_ENV "$out"/lib/nrfutil-ble-sniffer/wireshark-shim''
''--set NRFUTIL_BLE_SNIFFER_HCI_SHIM_BIN_ENV "$out"/lib/nrfutil-ble-sniffer/wireshark-hci-shim''
]
++ (
let
# These are the extensions with the probe-plugin-worker executable vendored.
relevantExtensions = lib.intersectLists [ "nrfutil-device" "nrfutil-trace" ] extensions;
in
lib.optionals (relevantExtensions != [ ]) [
''--set NRF_PROBE_PATH "$out"/lib/${lib.head relevantExtensions}''
]
)
);
in
''
wrapProgram "$out"/bin/nrfutil ${wrapProgramArgs}
installShellCompletion --cmd nrfutil \
--bash $(realpath "$out"/share/nrfutil-completion/scripts/bash/setup.bash) \
--zsh $(realpath "$out"/share/nrfutil-completion/scripts/zsh/_nrfutil)
'';
passthru = {
updateScript = ./update.sh;
withExtensions = extensions: nrfutil.override { inherit extensions; };
};
meta = sharedMeta // {
mainProgram = "nrfutil";
};
})
}

View File

@@ -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=";
};
};
};
}

View File

@@ -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"