diff --git a/nixos/modules/services/hardware/handheld-daemon.nix b/nixos/modules/services/hardware/handheld-daemon.nix index 6c9d5aa3e22c86b..02684426b578de3 100644 --- a/nixos/modules/services/hardware/handheld-daemon.nix +++ b/nixos/modules/services/hardware/handheld-daemon.nix @@ -11,6 +11,11 @@ in enable = mkEnableOption "Enable Handheld Daemon"; package = mkPackageOption pkgs "handheld-daemon" { }; + ui = { + enable = mkEnableOption "Handheld Daemon UI"; + package = mkPackageOption pkgs "handheld-daemon-ui" { }; + }; + user = mkOption { type = types.str; description = '' @@ -20,7 +25,10 @@ in }; config = mkIf cfg.enable { - environment.systemPackages = [ cfg.package ]; + services.handheld-daemon.ui.enable = mkDefault true; + environment.systemPackages = [ + cfg.package + ] ++ lib.optional cfg.ui.enable cfg.ui.package; services.udev.packages = [ cfg.package ]; systemd.packages = [ cfg.package ]; @@ -31,6 +39,11 @@ in restartIfChanged = true; + path = mkIf cfg.ui.enable [ + pkgs.handheld-daemon-ui + pkgs.lsof + ]; + serviceConfig = { ExecStart = "${ lib.getExe cfg.package } --user ${ cfg.user }"; Nice = "-12"; diff --git a/pkgs/by-name/ha/handheld-daemon-ui/package.nix b/pkgs/by-name/ha/handheld-daemon-ui/package.nix new file mode 100644 index 000000000000000..a1131ea5c23d64a --- /dev/null +++ b/pkgs/by-name/ha/handheld-daemon-ui/package.nix @@ -0,0 +1,42 @@ +{ + lib, + appimageTools, + fetchurl, +}: +let + pname = "handheld-daemon-ui"; + version = "3.2.1"; + + src = fetchurl { + url = "https://github.com/hhd-dev/hhd-ui/releases/download/v${version}/hhd-ui.Appimage"; + hash = "sha256-RRXVoeWOO/pR+CAEY0J6Buf/RhA+G0PdxGQVMdAHfwA="; + }; + extractedFiles = appimageTools.extractType2 { inherit pname version src; }; +in +appimageTools.wrapType2 { + inherit pname version src; + + extraInstallCommands = '' + # Handheld-daemon expects the UI binary to be called hhd-ui + mv $out/bin/${pname}* $out/bin/hhd-ui + + mkdir -p $out/share/applications + substitute ${extractedFiles}/hhd-ui.desktop \ + $out/share/applications/hhd-ui.desktop \ + --replace-fail "Exec=AppRun" "Exec=hhd-ui" \ + --replace-fail "Categories=game;" "Categories=Game;" + iconDir=$out/share/icons/hicolor/512x512/apps + mkdir -p $iconDir + cp ${extractedFiles}/hhd-ui.png $iconDir + ''; + + meta = with lib; { + description = "The main UI for the Handheld Daemon"; + homepage = "https://github.com/hhd-dev/hhd-ui"; + license = licenses.gpl3Only; + maintainers = with maintainers; [ toast ]; + mainProgram = "hhd-ui"; + platforms = [ "x86_64-linux" ]; + sourceProvenance = with sourceTypes; [ binaryNativeCode ]; + }; +}