uhk-agent: custom package

This commit is contained in:
Zynh Ludwig 2025-02-03 20:10:02 -08:00
parent 00834d5c31
commit 510d2360df
3 changed files with 93 additions and 0 deletions

View file

@ -39,6 +39,19 @@ let
};
});
})
(final: prev: {
uhk-agent = prev.uhk-agent.overrideAttrs (old: rec {
pname = "uhk-agent";
version = "5.0.2";
src = prev.fetchurl {
url = "https://github.com/UltimateHackingKeyboard/agent/releases/download/v${version}/UHK.Agent-${version}-linux-x86_64.AppImage";
name = "${pname}-${version}.AppImage";
sha256 = "sha256-A0ALw5noXeeCGvWEFJMyYeNb9mMHyr3DC3T0yK1MQoM=";
};
});
})
];
});

View file

@ -11,4 +11,5 @@ in
zenBrowser = callDefaultPackage ./zenBrowser;
rose-pine-grub = callDefaultPackage ./rosePineGrub;
dwm-msg = callDefaultPackage ./dwm-msg;
uhk-agent = callDefaultPackage ./uhk-agent;
}

View file

@ -0,0 +1,79 @@
{ lib
, stdenv
, stdenvNoCC
, fetchurl
, appimageTools
, electron
, makeWrapper
, asar
, autoPatchelfHook
, libusb1
}:
let
pname = "uhk-agent";
version = "5.0.2";
src = fetchurl {
url = "https://github.com/UltimateHackingKeyboard/agent/releases/download/v${version}/UHK.Agent-${version}-linux-x86_64.AppImage";
name = "${pname}-${version}.AppImage";
sha256 = "sha256-A0ALw5noXeeCGvWEFJMyYeNb9mMHyr3DC3T0yK1MQoM=";
};
appimageContents = appimageTools.extract {
inherit pname version src;
};
in
stdenvNoCC.mkDerivation {
inherit pname version src;
dontUnpack = true;
nativeBuildInputs = [
asar
makeWrapper
autoPatchelfHook
];
buildInputs = [
(lib.getLib stdenv.cc.cc)
libusb1
];
autoPatchelfIgnoreMissingDeps = [
"libc.musl-x86_64.so.1"
];
installPhase = ''
runHook preInstall
mkdir -p "$out"/{opt,share/applications}
cp -r --no-preserve=mode "${appimageContents}/resources" "$out/opt/${pname}"
cp -r --no-preserve=mode "${appimageContents}/usr/share/icons" "$out/share/icons"
cp -r --no-preserve=mode "${appimageContents}/${pname}.desktop" "$out/share/applications/${pname}.desktop"
substituteInPlace "$out/share/applications/${pname}.desktop" \
--replace "Exec=AppRun" "Exec=${pname}"
asar extract "$out/opt/${pname}/app.asar" "$out/opt/${pname}/app.asar.unpacked"
rm "$out/opt/${pname}/app.asar"
makeWrapper "${electron}/bin/electron" "$out/bin/${pname}" \
--add-flags "$out/opt/${pname}/app.asar.unpacked" \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \
--set-default ELECTRON_IS_DEV 0 \
--inherit-argv0
runHook postInstall
'';
meta = with lib; {
description = "Agent is the configuration application of the Ultimate Hacking Keyboard";
homepage = "https://github.com/UltimateHackingKeyboard/agent";
license = licenses.unfreeRedistributable;
maintainers = with maintainers; [ ngiger nickcao ];
platforms = [ "x86_64-linux" ];
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
};
}