From 018704ce15f4779880ca223804c09f1eb7a9ec79 Mon Sep 17 00:00:00 2001 From: Anthony Rodriguez Date: Wed, 30 Oct 2024 16:13:04 +0100 Subject: [PATCH] pkgs/mcuxpresso: attempt to fix make --- pkgs/mcuxpresso/config-tools.nix | 49 ++++++++++++++++++++++++++++++++ pkgs/mcuxpresso/ide.nix | 37 +++++++++++++++++++++++- system/services/default.nix | 3 ++ 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 pkgs/mcuxpresso/config-tools.nix diff --git a/pkgs/mcuxpresso/config-tools.nix b/pkgs/mcuxpresso/config-tools.nix new file mode 100644 index 0000000..7ea094f --- /dev/null +++ b/pkgs/mcuxpresso/config-tools.nix @@ -0,0 +1,49 @@ +{ + eclipses, + stdenv, + requireFile, + ... +}: let + name = "mcuxpressotools"; + version = "v16-1"; + description = "MCUXpresso Config Tools"; + filename = "mcuxpresso-config-tools-${version}_amd64.deb"; + + src = stdenv.mkDerivation { + inherit version description; + name = "${name}-src"; + src = requireFile { + url = "https://www.nxp.com/design/software/development-software/mcuxpresso-config-tools-pins-clocks-and-peripherals:MCUXpresso-Config-Tools"; + name = "${filename}.bin"; + sha256 = "sha256-BbEwxm1urV2IrgUiTiMBEAPvonQGwdL4fpqFftGgRxI="; + }; + + buildCommand = '' + # Unpack tarball. + mkdir -p deb + sh $src --target deb || true + ar -xv deb/${filename} + tar xfvz data.tar.gz -C . + + mkdir -p ./final/eclipse + mv ./opt/nxp/MCUX_CFG_v13/bin/.* final/eclipse + mv ./usr final/ + mv final/eclipse/tools final/eclipse/eclipse + mv final/eclipse/tools.ini final/eclipse/eclipse.ini + + # Create custom .eclipseproduct file + echo "name=${name} + id=com.nxp.${name} + version=${version} + " > final/eclipse/.eclipseproduct + + # Additional files + mkdir -p final/usr/share/mime + mv ./opt/nxp/MCUX_CFG_v13/mcu_data final/mcu_data + + cd ./final + tar -czf $out ./ + ''; + }; +in + eclipses.buildEclipse {inherit description name src;} diff --git a/pkgs/mcuxpresso/ide.nix b/pkgs/mcuxpresso/ide.nix index 0b671d7..f78bea7 100644 --- a/pkgs/mcuxpresso/ide.nix +++ b/pkgs/mcuxpresso/ide.nix @@ -19,6 +19,7 @@ ar -xv deb/${filename} tar xfvz data.tar.gz -C . mkdir -p ./final/eclipse + find . -type f -iname "*mcuxpresso*" -o -iname "*.png" -o -iname "*.svg" mv ./usr/local/${name}-${version}/ide/* ./usr/local/${name}-${version}/ide/.* final/eclipse mv final/eclipse/mcuxpressoide final/eclipse/eclipse mv final/eclipse/mcuxpressoide.ini final/eclipse/eclipse.ini @@ -41,6 +42,40 @@ name = "${name}-eclipse"; inherit description src; }; + + patchedMcuxpressoide = pkgs.stdenv.mkDerivation { + name = "${name}-patched"; + src = mcuxpressoide; + nativeBuildInputs = [ + pkgs.stdenv.cc.cc.lib + pkgs.gcc + pkgs.libgcc + pkgs.libstdcxx5 + pkgs.xorg.libXext + pkgs.xorg.libX11 + pkgs.xorg.libXrender + pkgs.xorg.libXtst + pkgs.xorg.libXi + pkgs.freetype + pkgs.alsa-lib + pkgs.ncurses + pkgs.ncurses5 + pkgs.libusb1 + pkgs.readline + pkgs.libffi + pkgs.zlib + pkgs.tcl + pkgs.libxcrypt + pkgs.libxcrypt-legacy + pkgs.libusb-compat-0_1 + pkgs.autoPatchelfHook + ]; + + installPhase = '' + mkdir -p $out + cp -r $src/* $out + ''; + }; in pkgs.stdenv.mkDerivation { inherit name version description; @@ -59,7 +94,7 @@ in installPhase = '' runHook preInstall mkdir -p $out/bin - ln -s ${mcuxpressoide}/bin/eclipse $out/bin/mcuxpresso + ln -s ${patchedMcuxpressoide}/bin/eclipse $out/bin/mcuxpresso runHook postInstall ''; } diff --git a/system/services/default.nix b/system/services/default.nix index ab2f69d..0185c1e 100644 --- a/system/services/default.nix +++ b/system/services/default.nix @@ -5,4 +5,7 @@ }: { imports = [./docker.nix ./gnupg.nix ./pipewire.nix ./kmscon.nix]; services.udev.packages = [pkgs.segger-jlink inputs.self.packages.${pkgs.system}.mcuxpresso.ide]; + services.udev.extraRules = '' + SUBSYSTEM=="usb", ATTR{idVendor}=="1fc9", ATTR{idProduct}=="0132", MODE="0666" + ''; }