From c4dc44a810df0cedfb9f5e538fdb41b3d204854c Mon Sep 17 00:00:00 2001
From: liv <shadows@with.al>
Date: Mon, 21 Oct 2024 14:26:59 +0200
Subject: [PATCH] pkgs: add easyroam-connect-desktop

---
 home/enoko.nix                    |  4 ++-
 pkgs/default.nix                  |  5 +--
 pkgs/easyroam-connect-desktop.nix | 59 +++++++++++++++++++++++++++++++
 3 files changed, 65 insertions(+), 3 deletions(-)
 create mode 100644 pkgs/easyroam-connect-desktop.nix

diff --git a/home/enoko.nix b/home/enoko.nix
index 76bbd64..0ce4ad9 100644
--- a/home/enoko.nix
+++ b/home/enoko.nix
@@ -1,5 +1,5 @@
 # enoko is my framework 13-inch AMD laptop, running nixos
-{ ... }: {
+{ pkgs, ... }: {
   imports = [ ./global.nix ./global.linux.nix ./features/desktop ];
 
   config.monitors = [{
@@ -12,6 +12,8 @@
     scale = "1.175000";
   }];
 
+  config.home.packages = with pkgs; [ easyroam-connect-desktop ];
+
   # Fix HiDPI scaling
   # config.wayland.windowManager.hyprland = {
   #   settings.xwayland.force_zero_scaling = true;
diff --git a/pkgs/default.nix b/pkgs/default.nix
index 414ce95..57825fd 100644
--- a/pkgs/default.nix
+++ b/pkgs/default.nix
@@ -1,6 +1,7 @@
 # Custom packages, that can be defined similarly to ones from nixpkgs
 # You can build them using 'nix build .#example'
-pkgs:
-{
+pkgs: {
   # example = pkgs.callPackage ./example { };
+  easyroam-connect-desktop =
+    pkgs.callPackage ./easyroam-connect-desktop.nix { };
 }
diff --git a/pkgs/easyroam-connect-desktop.nix b/pkgs/easyroam-connect-desktop.nix
new file mode 100644
index 0000000..4f0b382
--- /dev/null
+++ b/pkgs/easyroam-connect-desktop.nix
@@ -0,0 +1,59 @@
+{ stdenv, lib, fetchurl, autoPatchelfHook, glib, gtk3, pango, cairo, harfbuzz
+, networkmanager, libsecret, libsoup_3, webkitgtk_4_1, glib-networking
+, wrapGAppsHook }:
+stdenv.mkDerivation rec {
+  pname = "easyroam-connect-desktop";
+  version = "1.3.5";
+
+  src = fetchurl {
+    url =
+      "http://packages.easyroam.de/repos/easyroam-desktop/pool/main/e/easyroam-desktop/easyroam_connect_desktop-${version}+${version}-linux.deb";
+    hash = "sha256-TRzEPPjsD1+eSuElvbTV4HJFfwfS+EH+r/OhdMP8KG0=";
+  };
+
+  dontConfigure = true;
+  dontBuild = true;
+
+  nativeBuildInputs = [ autoPatchelfHook wrapGAppsHook ];
+
+  buildInputs = [
+    glib
+    gtk3
+    pango
+    cairo
+    harfbuzz
+    libsecret
+    networkmanager
+    webkitgtk_4_1
+    libsoup_3
+    glib-networking
+  ];
+
+  unpackPhase = ''
+    ar p $src data.tar.xz | tar xJ
+  '';
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out
+    cp -r usr/share $out/share
+
+    mkdir -p $out/bin
+    ln -s $out/share/easyroam_connect_desktop/easyroam_connect_desktop $out/bin/easyroam_connect_desktop
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "Manage and install your easyroam WiFi profiles";
+    mainProgram = "easyroam_connect_desktop";
+    longDescription = ''
+      Using this software you can easily connect your device to eduroamĀ® by simply logging in with your DFN-AAI account.
+    '';
+    homepage = "https://easyroam.de";
+    license = licenses.unfree;
+    # maintainers = with maintainers; [ shadows_withal ];
+    platforms = [ "x86_64-linux" ];
+  };
+}