diff --git a/hosts/desktopnix/default.nix b/hosts/desktopnix/default.nix index 1a0b854..06613f0 100644 --- a/hosts/desktopnix/default.nix +++ b/hosts/desktopnix/default.nix @@ -1,6 +1,7 @@ { inputs, lib, + pkgs, ... }: { imports = [ @@ -55,6 +56,10 @@ boot.binfmt.emulatedSystems = ["aarch64-linux" "riscv64-linux"]; nix.settings.system-features = ["kvm" "nixos-test"]; + # for embedded + services.udev.packages = [pkgs.j-link]; + environment.systemPackages = [pkgs.j-link]; + services.netbird.enable = true; # Do not cleanup nix store to prevent having to rebuild packages onca a month nix.gc.automatic = lib.mkForce false; diff --git a/pkgs/default.nix b/pkgs/default.nix index 91c1443..359da9e 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -7,6 +7,7 @@ actual = super.callPackage ./actual.nix {}; deploy = super.callPackage ./deploy.nix {}; minify = super.callPackage ./minify {}; + j-link = super.callPackage ./jlink.nix {}; mongodb-bin = super.callPackage ./mongodb-bin.nix {}; awakened-poe-trade = super.callPackage ./awakened-poe-trade.nix {}; neovim-clean = super.neovim-unwrapped.overrideAttrs (_neovimFinal: neovimPrev: { diff --git a/pkgs/jlink.nix b/pkgs/jlink.nix new file mode 100644 index 0000000..dc48ed0 --- /dev/null +++ b/pkgs/jlink.nix @@ -0,0 +1,99 @@ +{ + stdenv, + lib, + requireFile, + autoPatchelfHook, + makeWrapper, + copyDesktopItems, + fontconfig, + freetype, + libICE, + libSM, + udev, + libX11, + libXext, + libXcursor, + libXfixes, + libXrender, + libXrandr, +}: let + version = "796f"; + url = "https://www.segger.com/downloads/jlink/JLink_Linux_V${version}_x86_64.tgz"; + hash = "02ahzj6dwxh15bnk2468zidi78vyiyp9v3bkq7rfijmasl73ybhr"; + archiveFilename = "JLink_Linux_V${version}_x86_64.tgz"; +in + stdenv.mkDerivation { + pname = "j-link"; + inherit version; + + src = requireFile { + name = archiveFilename; + url = "https://www.segger.com/downloads/jlink#J-LinkSoftwareAndDocumentationPack"; + sha256 = hash; + }; + + dontConfigure = true; + dontBuild = true; + dontStrip = true; + preferLocalBuild = true; + + nativeBuildInputs = [copyDesktopItems autoPatchelfHook makeWrapper]; + + buildInputs = [ + udev + stdenv.cc.cc.lib + fontconfig + freetype + libICE + libSM + libX11 + libXext + libXcursor + libXfixes + libXrender + libXrandr + ]; + + runtimeDependencies = [udev]; + + installPhase = '' + runHook preInstall + + mkdir -p "$out/lib/JLink" "$out/share/doc" "$out/bin" + + cp -R * "$out/lib/JLink" + rm "$out/lib/JLink/99-jlink.rules" + + for f in "$out/lib/JLink"/J*; do + if [[ -L $f ]]; then + mv "$f" "$out/bin/" + elif [[ -x $f ]]; then + makeWrapper "$f" "$out/bin/$(basename "$f")" + fi + done + + mv "$out/lib/JLink/Doc" "$out/share/doc/JLink" + mv \ + "$out/lib/JLink"/README* \ + "$out/lib/JLink/Samples" \ + "$out/lib/JLink/GDBServer"/Readme* \ + "$out/share/doc/JLink/" + + install -D -t "$out/lib/udev/rules.d" 99-jlink.rules + + runHook postInstall + ''; + + preFixup = '' + patchelf --add-needed libudev.so.1 $out/lib/JLink/libjlinkarm.so + ''; + + meta = with lib; { + homepage = "https://www.segger.com/downloads/jlink"; + description = "SEGGER J-Link"; + license = licenses.unfree; + platforms = platforms.linux; + maintainers = with maintainers; [liff]; + mainProgram = "JLinkExe"; + }; + }