-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
115 lines (103 loc) · 3.13 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
{
description = "STM32CubeMX configurator";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
};
outputs = { self, nixpkgs, ... }:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
iconame = "STM32CubeMX";
stm32cubemx = pkgs.stdenv.mkDerivation rec {
pname = "stm32cubemx";
version = "6.11.1";
src = pkgs.fetchzip {
url = "http://kafpi.local/stm32cube_mx_v${
builtins.replaceStrings [ "." ] [ "" ] version
}-lin.zip";
hash = "sha256-By9T43GLM1J63TkRi3kl05h1RflBorU1QHgYOrXQ9N0=";
stripRoot = false;
};
nativeBuildInputs = with pkgs; [
fdupes
icoutils
imagemagick
];
desktopItem = pkgs.makeDesktopItem {
name = "STM32CubeMX";
exec = "stm32cubemx";
desktopName = "STM32CubeMX";
categories = [ "Development" ];
icon = "stm32cubemx";
comment = "A graphical tool for configuring STM32 microcontrollers and microprocessors";
terminal = false;
startupNotify = false;
mimeTypes = [
"x-scheme-handler/sgnl"
"x-scheme-handler/signalcaptcha"
];
};
buildCommand = ''
mkdir -p $out/{bin,opt/STM32CubeMX,share/applications}
cp -r $src/MX/. $out/opt/STM32CubeMX/
chmod +rx $out/opt/STM32CubeMX/STM32CubeMX
cat << EOF > $out/bin/${pname}
#!${pkgs.stdenvNoCC.shell}
${pkgs.jdk17}/bin/java -jar $out/opt/STM32CubeMX/STM32CubeMX
EOF
chmod +x $out/bin/${pname}
icotool --extract $out/opt/STM32CubeMX/help/${iconame}.ico
fdupes -dN . > /dev/null
ls
for size in 16 24 32 48 64 128 256; do
mkdir -pv $out/share/icons/hicolor/"$size"x"$size"/apps
if [ $size -eq 256 ]; then
mv ${iconame}_*_"$size"x"$size"x32.png \
$out/share/icons/hicolor/"$size"x"$size"/apps/${pname}.png
else
convert -resize "$size"x"$size" ${iconame}_*_256x256x32.png \
$out/share/icons/hicolor/"$size"x"$size"/apps/${pname}.png
fi
done;
cp ${desktopItem}/share/applications/*.desktop $out/share/applications
'';
fhsEnv = pkgs.buildFHSEnv {
name = "${pname}-fhs-env";
targetPkgs = p: with p; [
alsa-lib
at-spi2-atk
cairo
cups
dbus
expat
glib
gtk3
libdrm
libGL
libudev0-shim
libxkbcommon
mesa
nspr
nss
pango
xorg.libX11
xorg.libxcb
xorg.libXcomposite
xorg.libXdamage
xorg.libXext
xorg.libXfixes
xorg.libXrandr
];
runScript = "${src}/bin/mmain";
};
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp ${fhsEnv}/bin/${pname}-fhs-env $out/bin/stm32cubemx
runHook postInstall
'';
};
in {
packages.x86_64-linux.stm32cubemx = stm32cubemx;
defaultPackage.x86_64-linux = stm32cubemx;
};
}