winbox4: add MacOS aarch64 support (#384296)

authored by Pol Dellaiera and committed by GitHub f3e80c71 aaf817bb

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