1{
2 lib,
3 stdenvNoCC,
4 fetchurl,
5 copyDesktopItems,
6 makeDesktopItem,
7 makeBinaryWrapper,
8 wine,
9}:
10
11let
12 # The icon is also from the winbox AUR package (see above).
13 icon = fetchurl {
14 name = "winbox.png";
15 url = "https://aur.archlinux.org/cgit/aur.git/plain/winbox.png?h=winbox";
16 hash = "sha256-YD6u2N+1thRnEsXO6AHm138fRda9XEtUX5+EGTg004A=";
17 };
18in
19stdenvNoCC.mkDerivation (finalAttrs: {
20 pname = "winbox";
21 version = "3.41";
22
23 src = fetchurl (
24 if (wine.meta.mainProgram == "wine64") then
25 {
26 url = "https://download.mikrotik.com/routeros/winbox/${finalAttrs.version}/winbox64.exe";
27 hash = "sha256-i8Ps8fNZUmAOyxo4DDjIjp1jwIGjIgT9CU1YgjAHC/Y=";
28 }
29 else
30 {
31 url = "https://download.mikrotik.com/routeros/winbox/${finalAttrs.version}/winbox.exe";
32 hash = "sha256-NypSEC5YKpqldlkSIRFtWVD4xJZcjGcfjnphSg70wmE=";
33 }
34 );
35
36 dontUnpack = true;
37
38 nativeBuildInputs = [
39 makeBinaryWrapper
40 copyDesktopItems
41 ];
42
43 installPhase = ''
44 runHook preInstall
45
46 mkdir -p $out/{bin,libexec,share/pixmaps}
47
48 ln -s "${icon}" "$out/share/pixmaps/winbox.png"
49
50 makeWrapper ${lib.getExe wine} $out/bin/winbox \
51 --add-flags $src
52
53 runHook postInstall
54 '';
55
56 desktopItems = [
57 (makeDesktopItem {
58 name = "winbox";
59 desktopName = "Winbox";
60 comment = "GUI administration for Mikrotik RouterOS";
61 exec = "winbox";
62 icon = "winbox";
63 categories = [ "Utility" ];
64 })
65 ];
66
67 meta = {
68 description = "Graphical configuration utility for RouterOS-based devices";
69 homepage = "https://mikrotik.com";
70 downloadPage = "https://mikrotik.com/download";
71 changelog = "https://wiki.mikrotik.com/wiki/Winbox_changelog";
72 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
73 license = lib.licenses.unfree;
74 mainProgram = "winbox";
75 maintainers = with lib.maintainers; [ yrd ];
76 };
77})