From 8be02edd28bfd5baa4c12256d8c160a16105cb65 Mon Sep 17 00:00:00 2001 From: Toast <39011842+toast003@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:17:59 +0100 Subject: [PATCH] handheld-daemon-ui: init at 3.2.3 (#305027) Co-authored-by: Sandro Co-authored-by: Arne Keller <2012gdwu+github@posteo.de> (cherry picked from commit d5808aee19c06e9e6b2603d0b600de34ed890de8) --- .../services/hardware/handheld-daemon.nix | 15 ++++++- .../by-name/ha/handheld-daemon-ui/package.nix | 42 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 pkgs/by-name/ha/handheld-daemon-ui/package.nix diff --git a/nixos/modules/services/hardware/handheld-daemon.nix b/nixos/modules/services/hardware/handheld-daemon.nix index a5ba1856d015..c1a628e1697d 100644 --- a/nixos/modules/services/hardware/handheld-daemon.nix +++ b/nixos/modules/services/hardware/handheld-daemon.nix @@ -11,6 +11,11 @@ in enable = mkEnableOption "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 [ + cfg.ui.package + 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 000000000000..00c830bd3fc6 --- /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.3"; + + src = fetchurl { + url = "https://github.com/hhd-dev/hhd-ui/releases/download/v${version}/hhd-ui.Appimage"; + hash = "sha256-VhJrOvE+BebJIAeQlwOOsPfqSrvBnJQavGT7glTrG2o="; + }; + 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 = { + description = "UI for the Handheld Daemon"; + homepage = "https://github.com/hhd-dev/hhd-ui"; + license = lib.licenses.gpl3Only; + maintainers = with lib.maintainers; [ toast ]; + mainProgram = "hhd-ui"; + platforms = [ "x86_64-linux" ]; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + }; +}