From 4bc21d213b56d7f24661611d561ae47495f43e2a Mon Sep 17 00:00:00 2001 From: Andrew Kvalheim Date: Fri, 19 May 2023 12:51:18 -0700 Subject: [PATCH] yubikey-touch-detector: add icon As explained in maximbaz/yubikey-touch-detector#25, YTD doesn't include an icon but is intended to be paired with one by the user or packager. Following the example of alpinelinux/aports@1f596c2, this derives an icon from the assets of Yubico Authenticator. --- .../yubikey-touch-detector/default.nix | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pkgs/tools/security/yubikey-touch-detector/default.nix b/pkgs/tools/security/yubikey-touch-detector/default.nix index 6d21bbe6f56..9e66a5ffd5a 100644 --- a/pkgs/tools/security/yubikey-touch-detector/default.nix +++ b/pkgs/tools/security/yubikey-touch-detector/default.nix @@ -1,4 +1,4 @@ -{ lib, libnotify, buildGoModule, fetchFromGitHub, pkg-config }: +{ lib, libnotify, buildGoModule, fetchFromGitHub, fetchurl, pkg-config, iconColor ? "#84bd00" }: buildGoModule rec { pname = "yubikey-touch-detector"; @@ -12,13 +12,31 @@ buildGoModule rec { }; vendorHash = "sha256-OitI9Yp4/mRMrNH4yrWSL785+3mykPkvzarrc6ipOeg="; + iconSrc = fetchurl { + url = "https://github.com/Yubico/yubioath-flutter/raw/yubioath-desktop-5.0.0/images/touch.svg"; + hash = "sha256-+jC9RKjl1uMBaNqLX5WXN+E4CuOcIEx5IGXWxgxzA/k="; + }; + nativeBuildInputs = [ pkg-config ]; buildInputs = [ libnotify ]; + postPatch = '' + cp $iconSrc yubikey-touch-detector.svg + substituteInPlace yubikey-touch-detector.svg \ + --replace '#284c61' ${lib.escapeShellArg iconColor} + + substituteInPlace notifier/libnotify.go \ + --replace \ + 'AppIcon: "yubikey-touch-detector"' \ + "AppIcon: \"$out/share/icons/yubikey-touch-detector.svg\"" + ''; + postInstall = '' install -Dm444 -t $out/share/doc/${pname} *.md + install -Dm444 -t $out/share/icons yubikey-touch-detector.svg + install -Dm444 -t $out/lib/systemd/user *.{service,socket} substituteInPlace $out/lib/systemd/user/*.service \ @@ -29,7 +47,7 @@ buildGoModule rec { description = "A tool to detect when your YubiKey is waiting for a touch (to send notification or display a visual indicator on the screen)."; homepage = "https://github.com/maximbaz/yubikey-touch-detector"; maintainers = with maintainers; [ sumnerevans ]; - license = licenses.isc; + license = with licenses; [ bsd2 isc ]; platforms = platforms.linux; }; }