|
1 | 1 | { |
2 | | - autoPatchelfHook, |
3 | | - copyDesktopItems, |
4 | | - fetchurl, |
5 | | - fontconfig, |
6 | | - freetype, |
7 | 2 | lib, |
8 | | - libGL, |
9 | | - libxkbcommon, |
10 | | - makeDesktopItem, |
11 | | - makeWrapper, |
| 3 | + callPackage, |
12 | 4 | stdenvNoCC, |
13 | | - unzip, |
14 | | - writeShellApplication, |
15 | | - xorg, |
16 | | - zlib, |
17 | 5 | }: |
18 | | - |
19 | | -stdenvNoCC.mkDerivation (finalAttrs: { |
| 6 | +let |
20 | 7 | pname = "winbox"; |
21 | 8 | version = "4.0beta20"; |
22 | 9 |
|
23 | | - src = fetchurl { |
24 | | - name = "WinBox_Linux-${finalAttrs.version}.zip"; |
25 | | - url = "https://download.mikrotik.com/routeros/winbox/${finalAttrs.version}/WinBox_Linux.zip"; |
26 | | - hash = "sha256-mU+z7yRYKXnGAXHB5LS5SVUgIzRlR9nV2FzXispntF0="; |
27 | | - }; |
28 | | - |
29 | | - sourceRoot = "."; |
30 | | - |
31 | | - nativeBuildInputs = [ |
32 | | - autoPatchelfHook |
33 | | - copyDesktopItems |
34 | | - # makeBinaryWrapper does not support --run |
35 | | - makeWrapper |
36 | | - unzip |
37 | | - ]; |
38 | | - |
39 | | - buildInputs = [ |
40 | | - fontconfig |
41 | | - freetype |
42 | | - libGL |
43 | | - libxkbcommon |
44 | | - xorg.libxcb |
45 | | - xorg.xcbutilimage |
46 | | - xorg.xcbutilkeysyms |
47 | | - xorg.xcbutilrenderutil |
48 | | - xorg.xcbutilwm |
49 | | - zlib |
50 | | - ]; |
51 | | - |
52 | | - installPhase = '' |
53 | | - runHook preInstall |
54 | | -
|
55 | | - install -Dm644 "assets/img/winbox.png" "$out/share/pixmaps/winbox.png" |
56 | | - install -Dm755 "WinBox" "$out/bin/WinBox" |
57 | | -
|
58 | | - wrapProgram "$out/bin/WinBox" --run "${lib.getExe finalAttrs.migrationScript}" |
59 | | -
|
60 | | - runHook postInstall |
61 | | - ''; |
62 | | - |
63 | | - desktopItems = [ |
64 | | - (makeDesktopItem { |
65 | | - name = "winbox"; |
66 | | - desktopName = "Winbox"; |
67 | | - comment = "GUI administration for Mikrotik RouterOS"; |
68 | | - exec = "WinBox"; |
69 | | - icon = "winbox"; |
70 | | - categories = [ "Utility" ]; |
71 | | - }) |
72 | | - ]; |
73 | | - |
74 | | - migrationScript = writeShellApplication { |
75 | | - name = "winbox-migrate"; |
76 | | - text = '' |
77 | | - XDG_DATA_HOME=''${XDG_DATA_HOME:-$HOME/.local/share} |
78 | | - targetFile="$XDG_DATA_HOME/MikroTik/WinBox/Addresses.cdb" |
79 | | -
|
80 | | - if [ -f "$targetFile" ]; then |
81 | | - echo "NixOS: WinBox 4 data already present at $(dirname "$targetFile"). Skipping automatic migration." |
82 | | - exit 0 |
83 | | - fi |
84 | | -
|
85 | | - # cover both wine prefix variants |
86 | | - # latter was used until https://github.com/NixOS/nixpkgs/pull/329626 was merged on 2024/07/24 |
87 | | - winePrefixes=( |
88 | | - "''${WINEPREFIX:-$HOME/.wine}" |
89 | | - "''${WINBOX_HOME:-$XDG_DATA_HOME/winbox}/wine" |
90 | | - ) |
91 | | - sourceFilePathSuffix="drive_c/users/$USER/AppData/Roaming/Mikrotik/Winbox/Addresses.cdb" |
92 | | - selectedSourceFile="" |
93 | | -
|
94 | | - for prefix in "''${winePrefixes[@]}" |
95 | | - do |
96 | | - echo "NixOS: Probing WinBox 3 data path at $prefix..." |
97 | | - if [ -f "$prefix/$sourceFilePathSuffix" ]; then |
98 | | - selectedSourceFile="$prefix/$sourceFilePathSuffix" |
99 | | - break |
100 | | - fi |
101 | | - done |
102 | | -
|
103 | | - if [ -z "$selectedSourceFile" ]; then |
104 | | - echo "NixOS: WinBox 3 data not found. Skipping automatic migration." |
105 | | - exit 0 |
106 | | - fi |
107 | | -
|
108 | | - echo "NixOS: Automatically migrating WinBox 3 data..." |
109 | | - install -Dvm644 "$selectedSourceFile" "$targetFile" |
110 | | - ''; |
111 | | - }; |
112 | | - |
113 | | - meta = { |
| 10 | + metaCommon = { |
114 | 11 | description = "Graphical configuration utility for RouterOS-based devices"; |
115 | 12 | homepage = "https://mikrotik.com"; |
116 | 13 | downloadPage = "https://mikrotik.com/download"; |
117 | | - changelog = "https://download.mikrotik.com/routeros/winbox/${finalAttrs.version}/CHANGELOG"; |
118 | 14 | sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; |
119 | 15 | license = lib.licenses.unfree; |
120 | | - platforms = [ "x86_64-linux" ]; |
121 | 16 | mainProgram = "WinBox"; |
122 | 17 | maintainers = with lib.maintainers; [ |
123 | 18 | Scrumplex |
124 | 19 | yrd |
125 | 20 | savalet |
126 | 21 | ]; |
127 | 22 | }; |
| 23 | + x86_64-zip = callPackage ./build-from-zip.nix { |
| 24 | + inherit pname version metaCommon; |
| 25 | + |
| 26 | + hash = "sha256-mU+z7yRYKXnGAXHB5LS5SVUgIzRlR9nV2FzXispntF0="; |
| 27 | + }; |
| 28 | + |
| 29 | + x86_64-dmg = callPackage ./build-from-dmg.nix { |
| 30 | + inherit pname version metaCommon; |
| 31 | + |
| 32 | + hash = "sha256-tLsreK6YsqsbMaY4dil34eiHxAG7GrZYyll6BX9dsx8="; |
| 33 | + }; |
| 34 | +in |
| 35 | +(if stdenvNoCC.hostPlatform.isDarwin then x86_64-dmg else x86_64-zip).overrideAttrs (oldAttrs: { |
| 36 | + meta = oldAttrs.meta // { |
| 37 | + platforms = x86_64-zip.meta.platforms ++ x86_64-dmg.meta.platforms; |
| 38 | + mainProgram = "WinBox"; |
| 39 | + changelog = "https://download.mikrotik.com/routeros/winbox/${oldAttrs.version}/CHANGELOG"; |
| 40 | + }; |
128 | 41 | }) |
0 commit comments