forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.nix
157 lines (142 loc) · 3.42 KB
/
package.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
{ acceptLicense ? false
, lib
, stdenvNoCC
, requireFile
, fetchurl
, autoPatchelfHook
, patchelf
, dpkg
, xorg
, fontconfig
, libudev0-shim
}:
let
meta = {
homepage = "https://www.segger.com/downloads/jlink/";
description = "Segger JLink Software and Documentation pack";
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
license = [
{
shortName = "segger-sfl";
fullName = "SEGGER's Friendly License";
url = "https://www.segger.com/purchase/licensing/license-sfl/";
free = false;
redistributable = false;
deprecated = false;
}
{
shortName = "segger-cul";
fullName = "SEGGER's Commercial-use License";
url = "https://www.segger.com/purchase/licensing/license-cul/";
free = false;
redistributable = false;
deprecated = false;
}
];
platforms = [ "x86_64-linux" ];
maintainers = with lib.maintainers; [ liarokapisv ];
};
version = "V7.92k";
versionNoDots = lib.strings.replaceStrings [ "." ] [ "" ] version;
platformSpecific = {
x86_64-linux = {
fileName = "JLink_Linux_${versionNoDots}_x86_64.deb";
sha256 = "sha256-MTPG0HeAcwOTHEHtqR/uOjuEu13UrTxQyX6zvwrDAoA=";
};
};
src =
let
system = stdenvNoCC.hostPlatform.system;
fileName = platformSpecific.${system}.fileName;
sha256 = platformSpecific.${system}.sha256;
url = " https://www.segger.com/downloads/jlink/${fileName}";
in
if acceptLicense then
(fetchurl {
inherit sha256;
inherit url;
curlOpts = "-d accept_license_agreement=accepted";
}) else
(requireFile {
name = fileName;
inherit sha256;
inherit url;
});
in
stdenvNoCC.mkDerivation
{
pname = "jlink-software-tools";
inherit version;
inherit src;
inherit meta;
nativeBuildInputs = [
dpkg
autoPatchelfHook
patchelf
];
buildInputs = [
xorg.libXrandr
xorg.libXfixes
xorg.libXcursor
xorg.libX11
xorg.libSM
xorg.libICE
fontconfig.lib
];
desktopApps = [
"JFlash"
"JFlashLite"
"JFlashSPI"
"JLinkConfig"
"JLink"
"JLinkGDBServer"
"JLinkGUIServer"
"JLinkLicenseManager"
"JLinkRegistration"
"JLinkRemoteServer"
"JLinkRTTClient"
"JLinkRTTLogger"
"JLinkRTTViewer"
"JLinkSTM32"
"JLinkSWOViewer"
"JMem"
"JRun"
"JTAGLoad"
];
installPhase = ''
dpkg-deb -x $src $out
# Soothe nix-build suspicions
chmod -R g-w $out
# Remove and recreate symlinks
rm -R $out/usr
mkdir -p $out/bin
for path in $out/opt/SEGGER/JLink_${versionNoDots}/J*
do
name=$(basename "$path")
ln -s "$out/opt/SEGGER/JLink_${versionNoDots}/$name" "$out/bin/$name"
done
# Add desktop entries icon
mkdir -p $out/share/pixmaps
ln -s ${./JLink.svg} $out/share/pixmaps/JLink.svg
# Create desktop entries
mkdir -p $out/share/applications
for name in $desktopApps
do
cat << EOF > "$out/share/applications/$name.desktop"
[Desktop Entry]
Type=Application
Name=$name
Exec=''${name}Exe
Icon=JLink
Terminal=false
StartupNotify=false
Categories=Development
EOF
chmod +x "$out/share/applications/$name.desktop"
done
'';
postFixup = ''
# needed due to dlopen
patchelf --add-rpath "${libudev0-shim}/lib" $out/opt/SEGGER/JLink_${versionNoDots}/libjlinkarm.so
'';
}