btrbk: add mainProgram
[NixPkgs.git] / pkgs / by-name / st / stm32cubemx / package.nix
blob6d58322767d30b8713386e33b34317cd4e7610a2
1 { fdupes
2 , buildFHSEnv
3 , fetchzip
4 , icoutils
5 , imagemagick
6 , jdk17
7 , lib
8 , makeDesktopItem
9 , stdenvNoCC
12 let
13   iconame = "STM32CubeMX";
14   package = stdenvNoCC.mkDerivation rec {
15     pname = "stm32cubemx";
16     version = "6.11.1";
18     src = fetchzip {
19       url = "https://sw-center.st.com/packs/resource/library/stm32cube_mx_v${builtins.replaceStrings ["."] [""] version}-lin.zip";
20       hash = "sha256-By9T43GLM1J63TkRi3kl05h1RflBorU1QHgYOrXQ9N0=";
21       stripRoot = false;
22     };
24     nativeBuildInputs = [ fdupes icoutils imagemagick ];
25     desktopItem = makeDesktopItem {
26       name = "STM32CubeMX";
27       exec = "stm32cubemx";
28       desktopName = "STM32CubeMX";
29       categories = [ "Development" ];
30       icon = "stm32cubemx";
31       comment = meta.description;
32       terminal = false;
33       startupNotify = false;
34       mimeTypes = [
35         "x-scheme-handler/sgnl"
36         "x-scheme-handler/signalcaptcha"
37       ];
38     };
40     buildCommand = ''
41       mkdir -p $out/{bin,opt/STM32CubeMX,share/applications}
43       cp -r $src/MX/. $out/opt/STM32CubeMX/
44       chmod +rx $out/opt/STM32CubeMX/STM32CubeMX
46       cat << EOF > $out/bin/${pname}
47       #!${stdenvNoCC.shell}
48       ${jdk17}/bin/java -jar $out/opt/STM32CubeMX/STM32CubeMX
49       EOF
50       chmod +x $out/bin/${pname}
52       icotool --extract $out/opt/STM32CubeMX/help/${iconame}.ico
53       fdupes -dN . > /dev/null
54       ls
55       for size in 16 24 32 48 64 128 256; do
56         mkdir -pv $out/share/icons/hicolor/"$size"x"$size"/apps
57         if [ $size -eq 256 ]; then
58           mv ${iconame}_*_"$size"x"$size"x32.png \
59             $out/share/icons/hicolor/"$size"x"$size"/apps/${pname}.png
60         else
61           convert -resize "$size"x"$size" ${iconame}_*_256x256x32.png \
62             $out/share/icons/hicolor/"$size"x"$size"/apps/${pname}.png
63         fi
64       done;
66       cp ${desktopItem}/share/applications/*.desktop $out/share/applications
67     '';
69     meta = with lib; {
70       description = "A graphical tool for configuring STM32 microcontrollers and microprocessors";
71       longDescription = ''
72         A graphical tool that allows a very easy configuration of STM32
73         microcontrollers and microprocessors, as well as the generation of the
74         corresponding initialization C code for the Arm® Cortex®-M core or a
75         partial Linux® Device Tree for Arm® Cortex®-A core), through a
76         step-by-step process.
77       '';
78       homepage = "https://www.st.com/en/development-tools/stm32cubemx.html";
79       sourceProvenance = with sourceTypes; [ binaryBytecode ];
80       license = licenses.unfree;
81       maintainers = with maintainers; [ angaz wucke13 ];
82       platforms = [ "x86_64-linux" ];
83     };
84   };
85   in
86   buildFHSEnv {
87     inherit (package) pname version meta;
88     runScript = "${package.outPath}/bin/stm32cubemx";
89     targetPkgs = pkgs:
90       with pkgs; [
91         alsa-lib
92         at-spi2-atk
93         cairo
94         cups
95         dbus
96         expat
97         glib
98         gtk3
99         libdrm
100         libGL
101         libudev0-shim
102         libxkbcommon
103         mesa
104         nspr
105         nss
106         pango
107         xorg.libX11
108         xorg.libxcb
109         xorg.libXcomposite
110         xorg.libXdamage
111         xorg.libXext
112         xorg.libXfixes
113         xorg.libXrandr
114       ];