about summary refs log tree commit diff
path: root/pkgs/by-name/go
diff options
context:
space:
mode:
authorSandro Jäckel <sandro.jaeckel@gmail.com>2024-03-04 00:59:59 +0100
committerSandro Jäckel <sandro.jaeckel@gmail.com>2024-03-10 00:17:43 +0100
commit32adfce17cbc39a570660bc6f7196ea2ae194b9f (patch)
treef63be6963e69019ffcf264b2415c1809e85d7812 /pkgs/by-name/go
parent3b2d1bebd61a7d4815fb1734fcef00272b1b9a2a (diff)
goldwarden: package GUI, drop pinentry
The correct way is to use goldwarden through the programs.goldwarden module
and the correct pinentry flavor based on programs.gnupg.agent.pinentryFlavor is now used.
Diffstat (limited to 'pkgs/by-name/go')
-rw-r--r--pkgs/by-name/go/goldwarden/package.nix64
1 files changed, 53 insertions, 11 deletions
diff --git a/pkgs/by-name/go/goldwarden/package.nix b/pkgs/by-name/go/goldwarden/package.nix
index 35b18ab1e51c4..9ef200fbf7baf 100644
--- a/pkgs/by-name/go/goldwarden/package.nix
+++ b/pkgs/by-name/go/goldwarden/package.nix
@@ -1,11 +1,14 @@
 { lib
+, bash
 , buildGoModule
 , fetchFromGitHub
-, makeBinaryWrapper
+, gobject-introspection
+, gtk4
+, libadwaita
 , libfido2
-, dbus
-, pinentry-gnome3
-, nix-update-script
+, libnotify
+, python3
+, wrapGAppsHook
 }:
 
 buildGoModule rec {
@@ -19,25 +22,64 @@ buildGoModule rec {
     hash = "sha256-4KxPtsIEW46p+cFx6yeSdNlsffy9U31k+ZSkE6V0AFc=";
   };
 
+  postPatch = ''
+    substituteInPlace browserbiometrics/manifests.go \
+      --replace-fail "/bin/bash" "${lib.getExe bash}"
+    substituteInPlace gui/com.quexten.Goldwarden.desktop \
+      --replace-fail "Exec=goldwarden_ui_main.py" "Exec=$out/bin/goldwarden-gui"
+    substituteInPlace gui/src/gui/browserbiometrics.py \
+      --replace-fail "flatpak run --filesystem=home --command=goldwarden com.quexten.Goldwarden" "goldwarden"
+    substituteInPlace gui/src/gui/ssh.py \
+      --replace-fail "flatpak run --command=goldwarden com.quexten.Goldwarden" "goldwarden" \
+      --replace-fail 'SSH_AUTH_SOCK=/home/$USER/.var/app/com.quexten.Goldwarden/data/ssh-auth-sock' 'SSH_AUTH_SOCK=/home/$USER/.goldwarden-ssh-agent.sock'
+    substituteInPlace gui/src/{linux/main.py,linux/monitors/dbus_monitor.py,gui/settings.py} \
+      --replace-fail "python3" "${(python3.buildEnv.override { extraLibs = pythonPath; }).interpreter}"
+  '';
+
   vendorHash = "sha256-IH0p7t1qInA9rNYv6ekxDN/BT5Kguhh4cZfmL+iqwVU=";
 
   ldflags = [ "-s" "-w" ];
 
-  nativeBuildInputs = [makeBinaryWrapper];
+  nativeBuildInputs = [
+    gobject-introspection
+    python3.pkgs.wrapPython
+    wrapGAppsHook
+  ];
 
-  buildInputs = [libfido2];
+  buildInputs = [
+    gtk4
+    libadwaita
+    libfido2
+    libnotify
+  ];
+
+  pythonPath = with python3.pkgs; [
+    dbus-python
+    pygobject3
+    tendo
+  ];
 
   postInstall = ''
-    wrapProgram $out/bin/goldwarden \
-      --suffix PATH : ${lib.makeBinPath [dbus pinentry-gnome3]}
+    chmod +x gui/goldwarden_ui_main.py
+    ln -s $out/share/goldwarden/goldwarden_ui_main.py $out/bin/goldwarden-gui
+    mkdir -p $out/share/goldwarden
+    cp -r gui/* $out/share/goldwarden/
+    rm $out/share/goldwarden/{com.quexten.Goldwarden.desktop,com.quexten.Goldwarden.metainfo.xml,goldwarden.svg,python3-requirements.json,requirements.txt}
 
-    install -Dm644 $src/resources/com.quexten.goldwarden.policy -t $out/share/polkit-1/actions
+    install -D gui/com.quexten.Goldwarden.desktop -t $out/share/applications
+    install -D gui/goldwarden.svg -t $out/share/icons/hicolor/scalable/apps
+    install -Dm644 gui/com.quexten.Goldwarden.metainfo.xml -t $out/share/metainfo
+    install -Dm644 resources/com.quexten.goldwarden.policy -t $out/share/polkit-1/actions
   '';
 
-  passthru.updateScript = nix-update-script {};
+  dontWrapGApps = true;
+  postFixup = ''
+    makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
+    wrapPythonProgramsIn $out/share/goldwarden "$out/share/goldwarden $pythonPath"
+  '';
 
   meta = with lib; {
-    description = "A feature-packed Bitwarden compatible desktop integration";
+    description = "Feature-packed Bitwarden compatible desktop integration";
     homepage = "https://github.com/quexten/goldwarden";
     license = licenses.mit;
     maintainers = with maintainers; [ arthsmn ];