nix-stuff/nixpkgs-patches/handheld-daemon-ui-init.patch
2024-07-11 12:29:18 +02:00

127 lines
4.1 KiB
Diff

From 18cd88064d152491d5ba19602db5c5d65bc2d685 Mon Sep 17 00:00:00 2001
From: Toast <39011842+toast003@users.noreply.github.com>
Date: Thu, 18 Apr 2024 11:22:24 +0200
Subject: [PATCH 1/3] handheld-daemon-ui: init at 3.1.1
---
.../by-name/ha/handheld-daemon-ui/package.nix | 39 +++++++++++++++++++
1 file changed, 39 insertions(+)
create mode 100644 pkgs/by-name/ha/handheld-daemon-ui/package.nix
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 00000000000000..81d318d88b5abd
--- /dev/null
+++ b/pkgs/by-name/ha/handheld-daemon-ui/package.nix
@@ -0,0 +1,39 @@
+{
+ lib,
+ appimageTools,
+ fetchurl,
+}:
+let
+ pname = "handheld-daemon-ui";
+ version = "3.1.1";
+
+ src = fetchurl {
+ url = "https://github.com/hhd-dev/hhd-ui/releases/download/v${version}/hhd-ui.Appimage";
+ hash = "sha256-KH01MvcCbvCqjp1UZHnwfh9G3Yh50CO9Ecjl1Y8VY9E=";
+ };
+ 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"
+ cp ${extractedFiles}/usr/share/icons $out/share -r
+ '';
+
+ 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 ];
+ };
+}
From 8ebb1f0976c79c74eb0cea3975c348e36d86a7d1 Mon Sep 17 00:00:00 2001
From: Toast <39011842+toast003@users.noreply.github.com>
Date: Wed, 10 Jul 2024 12:59:01 +0200
Subject: [PATCH 2/3] handheld-daemon: add options for handheld-daemon-ui
---
.../modules/services/hardware/handheld-daemon.nix | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/nixos/modules/services/hardware/handheld-daemon.nix b/nixos/modules/services/hardware/handheld-daemon.nix
index 6c9d5aa3e22c86..e8e283bca89413 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 ];
+ environment.systemPackages = [
+ cfg.package
+ (mkIf 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";
From 1b034ab22605b29195dabce893282b05077d0fe7 Mon Sep 17 00:00:00 2001
From: Toast <39011842+toast003@users.noreply.github.com>
Date: Thu, 11 Jul 2024 12:11:00 +0200
Subject: [PATCH 3/3] handheld-daemon: enable ui when enabling handheld-daemon
---
nixos/modules/services/hardware/handheld-daemon.nix | 1 +
1 file changed, 1 insertion(+)
diff --git a/nixos/modules/services/hardware/handheld-daemon.nix b/nixos/modules/services/hardware/handheld-daemon.nix
index e8e283bca89413..d78bae5e9bc483 100644
--- a/nixos/modules/services/hardware/handheld-daemon.nix
+++ b/nixos/modules/services/hardware/handheld-daemon.nix
@@ -25,6 +25,7 @@ in
};
config = mkIf cfg.enable {
+ services.handheld-daemon.ui.enable = mkDefault true;
environment.systemPackages = [
cfg.package
(mkIf cfg.ui.enable cfg.ui.package)