winbox4: add MacOS aarch64 support (#384296)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
{
|
||||
pname,
|
||||
version,
|
||||
hash,
|
||||
fetchurl,
|
||||
stdenvNoCC,
|
||||
undmg,
|
||||
metaCommon ? { },
|
||||
}:
|
||||
|
||||
stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
inherit pname version;
|
||||
|
||||
src = fetchurl {
|
||||
name = "WinBox-${finalAttrs.version}.dmg";
|
||||
url = "https://download.mikrotik.com/routeros/winbox/${finalAttrs.version}/WinBox.dmg";
|
||||
inherit hash;
|
||||
};
|
||||
|
||||
sourceRoot = ".";
|
||||
|
||||
nativeBuildInputs = [ undmg ];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/{bin,Applications}
|
||||
cp -R "WinBox.app" "$out/Applications/WinBox.app"
|
||||
ln -s "$out/Applications/WinBox.app/Contents/MacOS/WinBox" "$out/bin/WinBox"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = metaCommon // {
|
||||
platforms = [ "aarch64-darwin" ];
|
||||
};
|
||||
})
|
||||
@@ -0,0 +1,119 @@
|
||||
{
|
||||
pname,
|
||||
version,
|
||||
hash,
|
||||
autoPatchelfHook,
|
||||
copyDesktopItems,
|
||||
fetchurl,
|
||||
fontconfig,
|
||||
freetype,
|
||||
lib,
|
||||
libGL,
|
||||
libxkbcommon,
|
||||
makeDesktopItem,
|
||||
makeWrapper,
|
||||
stdenvNoCC,
|
||||
unzip,
|
||||
writeShellApplication,
|
||||
xorg,
|
||||
zlib,
|
||||
metaCommon ? { },
|
||||
}:
|
||||
|
||||
stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
inherit pname version;
|
||||
|
||||
src = fetchurl {
|
||||
name = "WinBox_Linux-${finalAttrs.version}.zip";
|
||||
url = "https://download.mikrotik.com/routeros/winbox/${finalAttrs.version}/WinBox_Linux.zip";
|
||||
inherit hash;
|
||||
};
|
||||
|
||||
sourceRoot = ".";
|
||||
|
||||
nativeBuildInputs = [
|
||||
autoPatchelfHook
|
||||
copyDesktopItems
|
||||
# makeBinaryWrapper does not support --run
|
||||
makeWrapper
|
||||
unzip
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
fontconfig
|
||||
freetype
|
||||
libGL
|
||||
libxkbcommon
|
||||
xorg.libxcb
|
||||
xorg.xcbutilimage
|
||||
xorg.xcbutilkeysyms
|
||||
xorg.xcbutilrenderutil
|
||||
xorg.xcbutilwm
|
||||
zlib
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
install -Dm644 "assets/img/winbox.png" "$out/share/pixmaps/winbox.png"
|
||||
install -Dm755 "WinBox" "$out/bin/WinBox"
|
||||
|
||||
wrapProgram "$out/bin/WinBox" --run "${lib.getExe finalAttrs.migrationScript}"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
desktopItems = [
|
||||
(makeDesktopItem {
|
||||
name = "winbox";
|
||||
desktopName = "WinBox";
|
||||
comment = "GUI administration for Mikrotik RouterOS";
|
||||
exec = "WinBox";
|
||||
icon = "winbox";
|
||||
categories = [ "Utility" ];
|
||||
})
|
||||
];
|
||||
|
||||
migrationScript = writeShellApplication {
|
||||
name = "winbox-migrate";
|
||||
text = ''
|
||||
XDG_DATA_HOME=''${XDG_DATA_HOME:-$HOME/.local/share}
|
||||
targetFile="$XDG_DATA_HOME/MikroTik/WinBox/Addresses.cdb"
|
||||
|
||||
if [ -f "$targetFile" ]; then
|
||||
echo "NixOS: WinBox 4 data already present at $(dirname "$targetFile"). Skipping automatic migration."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# cover both wine prefix variants
|
||||
# latter was used until https://github.com/NixOS/nixpkgs/pull/329626 was merged on 2024/07/24
|
||||
winePrefixes=(
|
||||
"''${WINEPREFIX:-$HOME/.wine}"
|
||||
"''${WINBOX_HOME:-$XDG_DATA_HOME/winbox}/wine"
|
||||
)
|
||||
sourceFilePathSuffix="drive_c/users/$USER/AppData/Roaming/Mikrotik/Winbox/Addresses.cdb"
|
||||
selectedSourceFile=""
|
||||
|
||||
for prefix in "''${winePrefixes[@]}"
|
||||
do
|
||||
echo "NixOS: Probing WinBox 3 data path at $prefix..."
|
||||
if [ -f "$prefix/$sourceFilePathSuffix" ]; then
|
||||
selectedSourceFile="$prefix/$sourceFilePathSuffix"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$selectedSourceFile" ]; then
|
||||
echo "NixOS: WinBox 3 data not found. Skipping automatic migration."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "NixOS: Automatically migrating WinBox 3 data..."
|
||||
install -Dvm644 "$selectedSourceFile" "$targetFile"
|
||||
'';
|
||||
};
|
||||
|
||||
meta = metaCommon // {
|
||||
platforms = [ "x86_64-linux" ];
|
||||
};
|
||||
})
|
||||
@@ -1,123 +1,18 @@
|
||||
{
|
||||
autoPatchelfHook,
|
||||
copyDesktopItems,
|
||||
fetchurl,
|
||||
fontconfig,
|
||||
freetype,
|
||||
lib,
|
||||
libGL,
|
||||
libxkbcommon,
|
||||
makeDesktopItem,
|
||||
makeWrapper,
|
||||
callPackage,
|
||||
stdenvNoCC,
|
||||
unzip,
|
||||
writeShellApplication,
|
||||
xorg,
|
||||
zlib,
|
||||
}:
|
||||
|
||||
stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
let
|
||||
pname = "winbox";
|
||||
version = "4.0beta20";
|
||||
|
||||
src = fetchurl {
|
||||
name = "WinBox_Linux-${finalAttrs.version}.zip";
|
||||
url = "https://download.mikrotik.com/routeros/winbox/${finalAttrs.version}/WinBox_Linux.zip";
|
||||
hash = "sha256-mU+z7yRYKXnGAXHB5LS5SVUgIzRlR9nV2FzXispntF0=";
|
||||
};
|
||||
|
||||
sourceRoot = ".";
|
||||
|
||||
nativeBuildInputs = [
|
||||
autoPatchelfHook
|
||||
copyDesktopItems
|
||||
# makeBinaryWrapper does not support --run
|
||||
makeWrapper
|
||||
unzip
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
fontconfig
|
||||
freetype
|
||||
libGL
|
||||
libxkbcommon
|
||||
xorg.libxcb
|
||||
xorg.xcbutilimage
|
||||
xorg.xcbutilkeysyms
|
||||
xorg.xcbutilrenderutil
|
||||
xorg.xcbutilwm
|
||||
zlib
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
install -Dm644 "assets/img/winbox.png" "$out/share/pixmaps/winbox.png"
|
||||
install -Dm755 "WinBox" "$out/bin/WinBox"
|
||||
|
||||
wrapProgram "$out/bin/WinBox" --run "${lib.getExe finalAttrs.migrationScript}"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
desktopItems = [
|
||||
(makeDesktopItem {
|
||||
name = "winbox";
|
||||
desktopName = "Winbox";
|
||||
comment = "GUI administration for Mikrotik RouterOS";
|
||||
exec = "WinBox";
|
||||
icon = "winbox";
|
||||
categories = [ "Utility" ];
|
||||
})
|
||||
];
|
||||
|
||||
migrationScript = writeShellApplication {
|
||||
name = "winbox-migrate";
|
||||
text = ''
|
||||
XDG_DATA_HOME=''${XDG_DATA_HOME:-$HOME/.local/share}
|
||||
targetFile="$XDG_DATA_HOME/MikroTik/WinBox/Addresses.cdb"
|
||||
|
||||
if [ -f "$targetFile" ]; then
|
||||
echo "NixOS: WinBox 4 data already present at $(dirname "$targetFile"). Skipping automatic migration."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# cover both wine prefix variants
|
||||
# latter was used until https://github.com/NixOS/nixpkgs/pull/329626 was merged on 2024/07/24
|
||||
winePrefixes=(
|
||||
"''${WINEPREFIX:-$HOME/.wine}"
|
||||
"''${WINBOX_HOME:-$XDG_DATA_HOME/winbox}/wine"
|
||||
)
|
||||
sourceFilePathSuffix="drive_c/users/$USER/AppData/Roaming/Mikrotik/Winbox/Addresses.cdb"
|
||||
selectedSourceFile=""
|
||||
|
||||
for prefix in "''${winePrefixes[@]}"
|
||||
do
|
||||
echo "NixOS: Probing WinBox 3 data path at $prefix..."
|
||||
if [ -f "$prefix/$sourceFilePathSuffix" ]; then
|
||||
selectedSourceFile="$prefix/$sourceFilePathSuffix"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$selectedSourceFile" ]; then
|
||||
echo "NixOS: WinBox 3 data not found. Skipping automatic migration."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "NixOS: Automatically migrating WinBox 3 data..."
|
||||
install -Dvm644 "$selectedSourceFile" "$targetFile"
|
||||
'';
|
||||
};
|
||||
|
||||
meta = {
|
||||
metaCommon = {
|
||||
description = "Graphical configuration utility for RouterOS-based devices";
|
||||
homepage = "https://mikrotik.com";
|
||||
downloadPage = "https://mikrotik.com/download";
|
||||
changelog = "https://download.mikrotik.com/routeros/winbox/${finalAttrs.version}/CHANGELOG";
|
||||
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
||||
license = lib.licenses.unfree;
|
||||
platforms = [ "x86_64-linux" ];
|
||||
mainProgram = "WinBox";
|
||||
maintainers = with lib.maintainers; [
|
||||
Scrumplex
|
||||
@@ -125,4 +20,22 @@ stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
savalet
|
||||
];
|
||||
};
|
||||
x86_64-zip = callPackage ./build-from-zip.nix {
|
||||
inherit pname version metaCommon;
|
||||
|
||||
hash = "sha256-mU+z7yRYKXnGAXHB5LS5SVUgIzRlR9nV2FzXispntF0=";
|
||||
};
|
||||
|
||||
x86_64-dmg = callPackage ./build-from-dmg.nix {
|
||||
inherit pname version metaCommon;
|
||||
|
||||
hash = "sha256-tLsreK6YsqsbMaY4dil34eiHxAG7GrZYyll6BX9dsx8=";
|
||||
};
|
||||
in
|
||||
(if stdenvNoCC.hostPlatform.isDarwin then x86_64-dmg else x86_64-zip).overrideAttrs (oldAttrs: {
|
||||
meta = oldAttrs.meta // {
|
||||
platforms = x86_64-zip.meta.platforms ++ x86_64-dmg.meta.platforms;
|
||||
mainProgram = "WinBox";
|
||||
changelog = "https://download.mikrotik.com/routeros/winbox/${oldAttrs.version}/CHANGELOG";
|
||||
};
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user