Skip to content

Commit

Permalink
add pkgs from NixOS/nixpkgs#255185
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Huber <[email protected]>
  • Loading branch information
maxhbr committed Jan 18, 2024
1 parent f639c26 commit 1b2fcf0
Show file tree
Hide file tree
Showing 4 changed files with 382 additions and 5 deletions.
38 changes: 33 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
outputs = { self, nixpkgs }@inputs:
let
# Nixpkgs instantiated for supported system types
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
nixpkgsFor = forAllSystems (system: import nixpkgs {
inherit system;
config.allowUnfree = true; # :(
config.segger-jlink.acceptLicense = true;
config.permittedInsecurePackages = [
"segger-jlink-qt4-794a"
];
});

lastModifiedDate =
self.lastModifiedDate or self.lastModified or "19700101";
Expand Down Expand Up @@ -103,11 +110,9 @@
gperf
ccache
gmp.dev
# openocd
openocd
dfu-util
bossa
# pkgs.nrfutil # UNFREE
# nRF-Command-Line-Tools
# jlink
srecord # for srec_cat

Expand Down Expand Up @@ -174,7 +179,13 @@
};
in my-west-fun {
pnameext = "-arm";
moreBuildInputs = [ gcc binutils stdenv.cc.cc.lib ];
moreBuildInputs = [
gcc
binutils
stdenv.cc.cc.lib

pkgs.nrfutil
];
wrapperArgs = ''
--set ZEPHYR_TOOLCHAIN_VARIANT "gnuarmemb" \
--set GNUARMEMB_TOOLCHAIN_PATH "${arm-toolchain}"
Expand Down Expand Up @@ -209,6 +220,16 @@
--set ESPRESSIF_TOOLCHAIN_PATH "${zephyr-sdk}/xtensa-espressif_esp32_zephyr-elf"
'';
};


# from https://github.com/NixOS/nixpkgs/pull/255185
nrf-command-line-tools = pkgs.callPackage ./pkgs_from_pr_255185/nrf-command-line-tools {
segger-jlink = self.packages."${system}".segger-jlink;
};
nrfconnect = pkgs.callPackage ./pkgs_from_pr_255185/nrfconnect {
segger-jlink = self.packages."${system}".segger-jlink;
};
segger-jlink = pkgs.callPackage ./pkgs_from_pr_255185/segger-jlink { };
});

homeManagerModules.zephyr = ({ config, lib, pkgs, ... }:
Expand Down Expand Up @@ -242,12 +263,17 @@
my-west
my-west-arm
my-west-esp32

nrf-command-line-tools
nrfconnect
segger-jlink
]);
};
});

nixosModules.zephyr = ({ config, lib, pkgs, ... }:
let
inherit (pkgs.stdenv.hostPlatform) system;
# platformio-udev-rules = pkgs.writeTextFile {
# name = "platformio-udev-rules";
# text = builtins.readFile
Expand All @@ -273,6 +299,8 @@
# pkgs.segger-jlink
pkgs.stlink
pkgs.teensy-udev-rules

self.packages."${system}".segger-jlink
];
});

Expand Down
76 changes: 76 additions & 0 deletions pkgs_from_pr_255185/nrf-command-line-tools/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{ lib
, stdenv
, fetchurl
, autoPatchelfHook
, udev
, libusb1
, segger-jlink
}:

let
supported = {
x86_64-linux = {
name = "linux-amd64";
hash = "sha256-zL9tXl2HsO8JZXEGsjg4+lDJJz30StOMH96rU7neDsg=";
};
aarch64-linux = {
name = "linux-arm64";
hash = "sha256-ACy3rXsvBZNVXdVkpP2AqrsoqKPliw6m9UUWrFOCBzs=";
};
armv7l-linux = {
name = "linux-armhf";
hash = "sha256-nD1pHL/SQqC7OlxuovWwvtnXKMmhfx5qFaF4ti8gh8g=";
};
};

platform = supported.${stdenv.system} or (throw "unsupported platform ${stdenv.system}");

version = "10.23.2";

url = let
versionWithDashes = builtins.replaceStrings ["."] ["-"] version;
in "https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/desktop-software/nrf-command-line-tools/sw/versions-${lib.versions.major version}-x-x/${versionWithDashes}/nrf-command-line-tools-${version}_${platform.name}.tar.gz";

in stdenv.mkDerivation {
pname = "nrf-command-line-tools";
inherit version;

src = fetchurl {
inherit url;
inherit (platform) hash;
};

runtimeDependencies = [
segger-jlink
];

nativeBuildInputs = [
autoPatchelfHook
];

buildInputs = [
udev
libusb1
];

dontConfigure = true;
dontBuild = true;

installPhase = ''
runHook preInstall
rm -rf ./python
mkdir -p $out
cp -r * $out
runHook postInstall
'';

meta = with lib; {
description = "Nordic Semiconductor nRF Command Line Tools";
homepage = "https://www.nordicsemi.com/Products/Development-tools/nRF-Command-Line-Tools";
license = licenses.unfree;
platforms = attrNames supported;
maintainers = with maintainers; [ stargate01 ];
};
}
45 changes: 45 additions & 0 deletions pkgs_from_pr_255185/nrfconnect/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{ lib
, fetchurl
, appimageTools
, segger-jlink
}:

let
pname = "nrfconnect";
version = "4.3.0";

src = fetchurl {
url = "https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/desktop-software/nrf-connect-for-desktop/${lib.versions.major version}-${lib.versions.minor version}-${lib.versions.patch version}/nrfconnect-${version}-x86_64.appimage";
hash = "sha256-G8//dZqPxn6mR8Bjzf/bAn9Gv7t2AFWIF9twCGbqMd8=";
name = "${pname}-${version}.AppImage";
};

appimageContents = appimageTools.extractType2 {
inherit pname version src;
};

in appimageTools.wrapType2 {
inherit pname version src;

extraPkgs = pkgs: with pkgs; [
segger-jlink
];

extraInstallCommands = ''
mv $out/bin/nrfconnect-* $out/bin/nrfconnect
install -Dm444 ${appimageContents}/nrfconnect.desktop -t $out/share/applications
install -Dm444 ${appimageContents}/usr/share/icons/hicolor/512x512/apps/nrfconnect.png \
-t $out/share/icons/hicolor/512x512/apps
substituteInPlace $out/share/applications/nrfconnect.desktop \
--replace 'Exec=AppRun' 'Exec=nrfconnect'
'';

meta = with lib; {
description = "Nordic Semiconductor nRF Connect for Desktop";
homepage = "https://www.nordicsemi.com/Products/Development-tools/nRF-Connect-for-desktop";
license = licenses.unfree;
platforms = platforms.linux;
maintainers = with maintainers; [ stargate01 ];
mainProgram = "nrfconnect";
};
}
Loading

0 comments on commit 1b2fcf0

Please sign in to comment.