From 4a4440ce9ec4af51cf697a31c6a09a1654d514e8 Mon Sep 17 00:00:00 2001
From: willifan <willifan@pm.me>
Date: Wed, 15 Jan 2025 12:06:52 +0100
Subject: [PATCH] fix missing postInstall for ewwbar

---
 .../home-manager/desktop/compositors/niri.nix |  3 +-
 pkgs/ewwbar/default.nix                       | 39 +++++++++++++++++--
 2 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/modules/default/home-manager/desktop/compositors/niri.nix b/modules/default/home-manager/desktop/compositors/niri.nix
index 01df39a..ee92db5 100644
--- a/modules/default/home-manager/desktop/compositors/niri.nix
+++ b/modules/default/home-manager/desktop/compositors/niri.nix
@@ -12,6 +12,7 @@ lib.mkIf config.desktop.wm.niri.enable {
 
     home.packages = [
       pkgs.xwayland-satellite
+      pkgs.ewwbar
     ];
 
     programs.niri.settings = {
@@ -22,7 +23,7 @@ lib.mkIf config.desktop.wm.niri.enable {
           command = [ "xwayland-satellite" ":0" ];
         }
         {
-          command = [ "${lib.getExe pkgs.ewwbar}" ];
+          command = [ "ewwbar" ];
         }
       ];
 
diff --git a/pkgs/ewwbar/default.nix b/pkgs/ewwbar/default.nix
index cf36bfd..2cbdf67 100644
--- a/pkgs/ewwbar/default.nix
+++ b/pkgs/ewwbar/default.nix
@@ -1,17 +1,28 @@
 { lib
 , rustPlatform
-, fetchurl
+, fetchzip
 , pkg-config
+, makeWrapper
 , libxkbcommon
+, eww
+, bash
+, gawk
+, bluez
+, coreutils
+, inotify-tools
+, playerctl
+, networkmanager
+, wireplumber
+, pulseaudio
 }:
 rustPlatform.buildRustPackage rec {
 
   pname = "ewwbar";
   version = "v0.1.1";
 
-  src = fetchurl {
+  src = fetchzip {
     url = "https://git.huwe.mooo.com/willifan/desktop-utils/archive/${version}.tar.gz";
-    sha256 = "sha256-yUwZdW8NusSS0cPmdl87z1C8rqq2/eBNdkqprbSkmUE=";
+    sha256 = "sha256-HbNbGEfkohFGmy22RGslrwR2REFbhbRL+I656V9e/7Q=";
   };
 
   cargoHash = "sha256-89Vljhbv2yLJtnr/6GLAuXkhVovJn1Iy+8jNgdPCCu8=";
@@ -19,12 +30,34 @@ rustPlatform.buildRustPackage rec {
 
   nativeBuildInputs = [
     pkg-config
+    makeWrapper
   ];
 
   buildInputs = [
     libxkbcommon
   ];
 
+  postInstall = ''
+    mkdir -p $out/bin
+    cp -r $src/eww $out/bin/eww
+  '';
+
+  postFixup = ''
+    wrapProgram $out/bin/ewwbar \
+      --set PATH ${lib.makeBinPath  [
+        eww
+        bash
+        gawk
+        bluez
+        coreutils
+        inotify-tools
+        playerctl
+        networkmanager
+        wireplumber
+        pulseaudio
+      ]}
+  '';
+
   meta = with lib; {
     description = "utils for my desktop";
     homepage = " git.huwe.mooo.com/willifan/desktop-utils";