nixpkgs/pkgs/tools/admin/winbox/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

74 lines
2.2 KiB
Nix
Raw Normal View History

{ lib
, fetchurl
, makeDesktopItem
, symlinkJoin
, writeShellScriptBin
, wine
}:
let
inherit (lib) last splitString;
pname = "winbox";
2023-05-07 10:32:13 +00:00
version = "3.38";
name = "${pname}-${version}";
2022-11-23 13:22:53 +00:00
executable = fetchurl (if (wine.meta.mainProgram == "wine64") then {
2022-07-23 07:08:38 +00:00
url = "https://download.mikrotik.com/winbox/${version}/winbox64.exe";
2023-05-07 10:32:13 +00:00
sha256 = "RV+j8FQigpwPprR2xuMYpDRMDwugSZD+O2ZmyPZDz54=";
} else {
2022-07-23 07:08:38 +00:00
url = "https://download.mikrotik.com/winbox/${version}/winbox.exe";
2023-05-07 10:32:13 +00:00
sha256 = "dh3P+otukhnEpVTqTu16MgIHVnJbzp4Voj+wZ3r5Fxg=";
});
2022-11-23 13:22:53 +00:00
# This is from the winbox AUR package:
# https://aur.archlinux.org/cgit/aur.git/tree/winbox64?h=winbox64&id=8edd93792af84e87592e8645ca09e9795931e60e
wrapper = writeShellScriptBin pname ''
export WINEPREFIX="''${WINBOX_HOME:-"''${XDG_DATA_HOME:-"''${HOME}/.local/share"}/winbox"}/wine"
export WINEDLLOVERRIDES="mscoree=" # disable mono
export WINEDEBUG=-all
if [ ! -d "$WINEPREFIX" ] ; then
mkdir -p "$WINEPREFIX"
${wine}/bin/wineboot -u
fi
2022-11-23 13:22:53 +00:00
${wine}/bin/${wine.meta.mainProgram} ${executable} "$@"
'';
desktopItem = makeDesktopItem {
name = pname;
desktopName = "Winbox";
comment = "GUI administration for Mikrotik RouterOS";
exec = pname;
icon = pname;
categories = [ "Utility" ];
startupWMClass = last (splitString "/" executable);
};
# The icon is also from the winbox AUR package (see above).
icon = fetchurl {
name = "winbox.png";
url = "https://aur.archlinux.org/cgit/aur.git/plain/winbox.png?h=winbox";
sha256 = "sha256-YD6u2N+1thRnEsXO6AHm138fRda9XEtUX5+EGTg004A=";
};
in
symlinkJoin {
inherit name pname version;
paths = [ wrapper desktopItem ];
postBuild = ''
mkdir -p "$out/share/pixmaps"
ln -s "${icon}" "$out/share/pixmaps/${pname}.png"
'';
meta = with lib; {
description = "Graphical configuration utility for RouterOS-based devices";
homepage = "https://mikrotik.com";
downloadPage = "https://mikrotik.com/download";
changelog = "https://wiki.mikrotik.com/wiki/Winbox_changelog";
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
license = licenses.unfree;
maintainers = with maintainers; [ yrd ];
};
}