1{ appimageTools, lib, fetchurl }:
2let
3 pname = "uhk-agent";
4 version = "2.1.2";
5 src = fetchurl {
6 url = "https://github.com/UltimateHackingKeyboard/agent/releases/download/v${version}/UHK.Agent-${version}-linux-x86_64.AppImage";
7 name = "${pname}-${version}.AppImage";
8 sha256 = "sha256-G/UT1ec7rWl8xONZnT+dpHAFOQh6/s0Vq7MTqAcmJSA=";
9 };
10
11 appimageContents = appimageTools.extract {
12 name = "${pname}-${version}";
13 inherit src;
14 };
15in appimageTools.wrapType2 {
16 inherit pname version src;
17
18 extraPkgs = pkgs: with pkgs; [ polkit udev ];
19
20 extraInstallCommands = ''
21 mv $out/bin/${pname}-${version} $out/bin/${pname}
22
23 install -m 444 -D ${appimageContents}/${pname}.desktop -t $out/share/applications
24 install -m 644 -D ${appimageContents}/resources/rules/50-uhk60.rules $out/rules/50-uhk60.rules
25 substituteInPlace $out/share/applications/${pname}.desktop \
26 --replace 'Exec=AppRun' 'Exec=${pname}'
27 cp -r ${appimageContents}/usr/share/icons $out/share
28 '';
29 # wrapType2 does not passthru pname+version
30 passthru.version = version;
31
32 meta = with lib; {
33 description = "Agent is the configuration application of the Ultimate Hacking Keyboard";
34 homepage = "https://github.com/UltimateHackingKeyboard/agent";
35 license = licenses.unfreeRedistributable;
36 maintainers = with maintainers; [ ngiger ];
37 platforms = [ "x86_64-linux" ];
38 };
39}