[PATCH] gnu: Add yubikey-oath-dmenu.

  • Done
  • quality assurance status badge
Details
3 participants
  • John Kehayias
  • Ludovic Courtès
  • Maxime Devos
Owner
unassigned
Submitted by
John Kehayias
Severity
normal

Debbugs page

John Kehayias wrote 3 years ago
(name . Guix-patches)(address . guix-patches@gnu.org)
jAGwwpRAblbWHGMfLOpO5IW8Q2mR5voGZUyFEPe930wTQe-gJGdjYWU3VpPfV-sJ1PQA5TGljCwXQIEbUP2sgMd98G2FiouWaK9e1naiJ-0=@protonmail.com
Hello!

Here is a patch to add yubikey-oath-dmenu, a handy way to get OATH codes from a Yubikey with a dmenu interface. I use it all the time (though through rofi). It seemed the best place was in the security-token module with similar yubikey packages. This is written in python but meant to run as a program rather than used as a library, so I called it without a python- prefix (and it runs with just non-propagated inputs).

Thanks!
John
From dae602f6db781ec71ab79a560b522270f35750cd Mon Sep 17 00:00:00 2001
From: John Kehayias <john.kehayias@protonmail.com>
Date: Fri, 14 Jan 2022 16:11:47 -0500
Subject: [PATCH] gnu: Add yubikey-oath-dmenu.

* gnu/packages/security-token.scm (yubikey-oath-dmenu): New variable.
---
gnu/packages/security-token.scm | 63 +++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)

Toggle diff (98 lines)
diff --git a/gnu/packages/security-token.scm b/gnu/packages/security-token.scm
index 79afdcee47..3a2d88cf8d 100644
--- a/gnu/packages/security-token.scm
+++ b/gnu/packages/security-token.scm
@@ -14,6 +14,7 @@
;;; Copyright © 2021 Sergey Trofimov <sarg@sarg.org.ru>
;;; Copyright © 2021 Dhruvin Gandhi <contact@dhruvin.dev>
;;; Copyright © 2021 Ahmad Jarara <git@ajarara.io>
+;;; Copyright © 2022 John Kehayias <john.kehayias@protonmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -53,6 +54,7 @@ (define-module (gnu packages security-token)
#:use-module (gnu packages dns)
#:use-module (gnu packages gettext)
#:use-module (gnu packages graphviz)
+ #:use-module (gnu packages gnome)
#:use-module (gnu packages gnupg)
#:use-module (gnu packages gtk)
#:use-module (gnu packages libbsd)
@@ -72,7 +74,9 @@ (define-module (gnu packages security-token)
#:use-module (gnu packages python-crypto)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages swig)
+ #:use-module (gnu packages suckless)
#:use-module (gnu packages web)
+ #:use-module (gnu packages xdisorg)
#:use-module (gnu packages xml))
(define-public ccid
@@ -443,6 +447,65 @@ (define-public python-pyscard
(define-public python2-pyscard
(package-with-python2 python-pyscard))
+(define-public yubikey-oath-dmenu
+ (package
+ (name "yubikey-oath-dmenu")
+ (version "0.13.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/emlun/yubikey-oath-dmenu")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1h6dr4l0gzgdg8zn2c39kx9cx1bgvwqxkz3z95qz9r70xfsghgwk"))))
+ (build-system python-build-system)
+ (arguments
+ (list
+ #:tests? #f ; there are no tests
+ #:phases
+ #~(modify-phases %standard-phases
+ (delete 'configure) ; no configure script
+ (delete 'build) ; or build
+ (add-after 'unpack 'fix-paths
+ (lambda _
+ (for-each (lambda (tool)
+ (substitute* "yubikey-oath-dmenu.py"
+ (((string-append "'" tool))
+ (string-append "'" (which tool)))))
+ (list "dmenu" "notify-send" "wl-copy" "xclip" "xdotool"))))
+ (replace 'install
+ (lambda _
+ (invoke "make" "install"
+ (string-append "DESTDIR=" #$output)
+ "PREFIX="))))))
+ (inputs
+ (list dmenu
+ libnotify
+ python-click
+ python-yubikey-manager
+ ;; TODO add wtype, once packaged, for type support for Wayland
+ wl-clipboard ; optional clipboard support for Wayland
+ xclip ; optional clipboard support for X11
+ xdotool)) ; optional type support for X11
+ (home-page
+ "https://github.com/emlun/yubikey-oath-dmenu/")
+ (synopsis "Interface for getting OATH codes from a YubiKey using dmenu")
+ (description
+ "Yubikey-oath-demenu lets you pick an OATH credential from your YubiKey using
+dmenu, and copies the corresponding OTP to the clipboard. Alternatively, it
+can \"type\" the OTP using @code{xdotool} on X11.
+
+Notable features:
+
+@itemize
+@item Pick between all credentials on all connected YubiKeys
+@item No mouse interaction required
+@end itemize\n")
+ (license license:gpl3+)))
+
(define-public libu2f-host
(package
(name "libu2f-host")
--
2.34.0
John Kehayias wrote 3 years ago
[PATCH v2] gnu: Add yubikey-oath-dmenu.
(name . 53270@debbugs.gnu.org)(address . 53270@debbugs.gnu.org)
hk0AcUix2YAtnZoXukuYtIQajXq-d906hpiSNkOG_INkE5zF3FIZ4_GvXMI6zRjYD7lLfe2F3_wF5x-SGAElZl6jRAmkxDEYG4FE0pMg73Y=@protonmail.com
Updated patch to use 'search-input-file' rather than 'which'. Since these are not meant to be host-side build paths, but for the target machine, if I understand correctly why 'which' shouldn't be used here.
From ea11bc0d6b6517636de3750356489aec93129e7c Mon Sep 17 00:00:00 2001
From: John Kehayias <john.kehayias@protonmail.com>
Date: Fri, 14 Jan 2022 16:11:47 -0500
Subject: [PATCH] gnu: Add yubikey-oath-dmenu.

* gnu/packages/security-token.scm (yubikey-oath-dmenu): New variable.
---
gnu/packages/security-token.scm | 65 +++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)

Toggle diff (100 lines)
diff --git a/gnu/packages/security-token.scm b/gnu/packages/security-token.scm
index 79afdcee47..e01245b4cf 100644
--- a/gnu/packages/security-token.scm
+++ b/gnu/packages/security-token.scm
@@ -14,6 +14,7 @@
;;; Copyright © 2021 Sergey Trofimov <sarg@sarg.org.ru>
;;; Copyright © 2021 Dhruvin Gandhi <contact@dhruvin.dev>
;;; Copyright © 2021 Ahmad Jarara <git@ajarara.io>
+;;; Copyright © 2022 John Kehayias <john.kehayias@protonmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -53,6 +54,7 @@ (define-module (gnu packages security-token)
#:use-module (gnu packages dns)
#:use-module (gnu packages gettext)
#:use-module (gnu packages graphviz)
+ #:use-module (gnu packages gnome)
#:use-module (gnu packages gnupg)
#:use-module (gnu packages gtk)
#:use-module (gnu packages libbsd)
@@ -72,7 +74,9 @@ (define-module (gnu packages security-token)
#:use-module (gnu packages python-crypto)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages swig)
+ #:use-module (gnu packages suckless)
#:use-module (gnu packages web)
+ #:use-module (gnu packages xdisorg)
#:use-module (gnu packages xml))
(define-public ccid
@@ -443,6 +447,67 @@ (define-public python-pyscard
(define-public python2-pyscard
(package-with-python2 python-pyscard))
+(define-public yubikey-oath-dmenu
+ (package
+ (name "yubikey-oath-dmenu")
+ (version "0.13.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/emlun/yubikey-oath-dmenu")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1h6dr4l0gzgdg8zn2c39kx9cx1bgvwqxkz3z95qz9r70xfsghgwk"))))
+ (build-system python-build-system)
+ (arguments
+ (list
+ #:tests? #f ; there are no tests
+ #:phases
+ #~(modify-phases %standard-phases
+ (delete 'configure) ; no configure script
+ (delete 'build) ; or build
+ (add-after 'unpack 'fix-paths
+ (lambda* (#:key inputs #:allow-other-keys)
+ (for-each (lambda (tool)
+ (substitute* "yubikey-oath-dmenu.py"
+ (((string-append "'" tool))
+ (string-append "'"
+ (search-input-file inputs
+ (string-append "/bin/" tool))))))
+ (list "dmenu" "notify-send" "wl-copy" "xclip" "xdotool"))))
+ (replace 'install
+ (lambda _
+ (invoke "make" "install"
+ (string-append "DESTDIR=" #$output)
+ "PREFIX="))))))
+ (inputs
+ (list dmenu
+ libnotify
+ python-click
+ python-yubikey-manager
+ ;; TODO add wtype, once packaged, for type support for Wayland
+ wl-clipboard ; optional clipboard support for Wayland
+ xclip ; optional clipboard support for X11
+ xdotool)) ; optional type support for X11
+ (home-page
+ "https://github.com/emlun/yubikey-oath-dmenu/")
+ (synopsis "Interface for getting OATH codes from a YubiKey using dmenu")
+ (description
+ "Yubikey-oath-demenu lets you pick an OATH credential from your YubiKey using
+dmenu, and copies the corresponding OTP to the clipboard. Alternatively, it
+can \"type\" the OTP using @code{xdotool} on X11.
+
+Notable features:
+
+@itemize
+@item Pick between all credentials on all connected YubiKeys
+@item No mouse interaction required
+@end itemize\n")
+ (license license:gpl3+)))
+
(define-public libu2f-host
(package
(name "libu2f-host")
--
2.34.0
Maxime Devos wrote 3 years ago
(name . John Kehayias)(address . john.kehayias@protonmail.com)(name . 53270@debbugs.gnu.org)(address . 53270@debbugs.gnu.org)
3d5ccfc962993cc5d5af18e49feb23e3c14765ca.camel@telenet.be
John Kehayias via Guix-patches via schreef op vr 14-01-2022 om 23:01
[+0000]:
Toggle quote (6 lines)
> +          (replace 'install
> +            (lambda _
> +              (invoke "make" "install"
> +                      (string-append "DESTDIR=" #$output)
> +                      "PREFIX="))))))

Guix doesn't do staged installation
so I would avoid (ab)using DESTDIR here. Instead of this phase,
maybe do

(replace 'install
(lambda _
(invoke "make" "install"
(string-append "PREFIX=" #$output)))))))

instead (untested)?

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYeKvnBccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7jHdAQDH9b6O3ZCu5GoEmcemOzy83cb6
uz3Dpl3ggmXsgFSQ3AD/eXfOK1bFMXS4G6Y5faXCYdPNbosa1wYznqnIa+fIfgg=
=1s4h
-----END PGP SIGNATURE-----


John Kehayias wrote 3 years ago
(name . Maxime Devos)(address . maximedevos@telenet.be)(name . 53270@debbugs.gnu.org)(address . 53270@debbugs.gnu.org)
yRBE6e16uCuEAOldGd4aeAX3gbO0Mov_uPv6kc1FWvaGkXEWtwG_orESE6otwe_tm66HusJC9fOe99DGAvbwFIPOJMGvJejPwWt-7Iiq4C4=@protonmail.com
Hi Maxime,

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Saturday, January 15th, 2022 at 6:27 AM, Maxime Devos wrote:

Toggle quote (9 lines)
> Guix doesn't do staged installation
> (https://www.gnu.org/software/automake/manual/html_node/DESTDIR.html),
> so I would avoid (ab)using DESTDIR here. Instead of this phase,
> maybe do
> [...]
> (string-append "PREFIX=" #$output)))))))
> instead (untested)?
>

No idea why I had DESTDIR there (there are some old packages I made, live and learn!) but your suggestion has the same result.

Attached is v3 of the patch with just this adjustment.

Thanks!
John
From a5958b588cebd23012d7d9cbeb8f1e22a3802ea2 Mon Sep 17 00:00:00 2001
From: John Kehayias <john.kehayias@protonmail.com>
Date: Fri, 14 Jan 2022 16:11:47 -0500
Subject: [PATCH] gnu: Add yubikey-oath-dmenu.

* gnu/packages/security-token.scm (yubikey-oath-dmenu): New variable.
---
gnu/packages/security-token.scm | 64 +++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)

Toggle diff (99 lines)
diff --git a/gnu/packages/security-token.scm b/gnu/packages/security-token.scm
index 79afdcee47..56b1552349 100644
--- a/gnu/packages/security-token.scm
+++ b/gnu/packages/security-token.scm
@@ -14,6 +14,7 @@
;;; Copyright © 2021 Sergey Trofimov <sarg@sarg.org.ru>
;;; Copyright © 2021 Dhruvin Gandhi <contact@dhruvin.dev>
;;; Copyright © 2021 Ahmad Jarara <git@ajarara.io>
+;;; Copyright © 2022 John Kehayias <john.kehayias@protonmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -53,6 +54,7 @@ (define-module (gnu packages security-token)
#:use-module (gnu packages dns)
#:use-module (gnu packages gettext)
#:use-module (gnu packages graphviz)
+ #:use-module (gnu packages gnome)
#:use-module (gnu packages gnupg)
#:use-module (gnu packages gtk)
#:use-module (gnu packages libbsd)
@@ -72,7 +74,9 @@ (define-module (gnu packages security-token)
#:use-module (gnu packages python-crypto)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages swig)
+ #:use-module (gnu packages suckless)
#:use-module (gnu packages web)
+ #:use-module (gnu packages xdisorg)
#:use-module (gnu packages xml))
(define-public ccid
@@ -443,6 +447,66 @@ (define-public python-pyscard
(define-public python2-pyscard
(package-with-python2 python-pyscard))
+(define-public yubikey-oath-dmenu
+ (package
+ (name "yubikey-oath-dmenu")
+ (version "0.13.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/emlun/yubikey-oath-dmenu")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1h6dr4l0gzgdg8zn2c39kx9cx1bgvwqxkz3z95qz9r70xfsghgwk"))))
+ (build-system python-build-system)
+ (arguments
+ (list
+ #:tests? #f ; there are no tests
+ #:phases
+ #~(modify-phases %standard-phases
+ (delete 'configure) ; no configure script
+ (delete 'build) ; or build
+ (add-after 'unpack 'fix-paths
+ (lambda* (#:key inputs #:allow-other-keys)
+ (for-each (lambda (tool)
+ (substitute* "yubikey-oath-dmenu.py"
+ (((string-append "'" tool))
+ (string-append "'"
+ (search-input-file inputs
+ (string-append "/bin/" tool))))))
+ (list "dmenu" "notify-send" "wl-copy" "xclip" "xdotool"))))
+ (replace 'install
+ (lambda _
+ (invoke "make" "install"
+ (string-append "PREFIX=" #$output)))))))
+ (inputs
+ (list dmenu
+ libnotify
+ python-click
+ python-yubikey-manager
+ ;; TODO add wtype, once packaged, for type support for Wayland
+ wl-clipboard ; optional clipboard support for Wayland
+ xclip ; optional clipboard support for X11
+ xdotool)) ; optional type support for X11
+ (home-page
+ "https://github.com/emlun/yubikey-oath-dmenu/")
+ (synopsis "Interface for getting OATH codes from a YubiKey using dmenu")
+ (description
+ "Yubikey-oath-demenu lets you pick an OATH credential from your YubiKey using
+dmenu, and copies the corresponding OTP to the clipboard. Alternatively, it
+can \"type\" the OTP using @code{xdotool} on X11.
+
+Notable features:
+
+@itemize
+@item Pick between all credentials on all connected YubiKeys
+@item No mouse interaction required
+@end itemize\n")
+ (license license:gpl3+)))
+
(define-public libu2f-host
(package
(name "libu2f-host")
--
2.34.0
John Kehayias wrote 3 years ago
Re: [bug#53270] [PATCH v3] gnu: Add yubikey-oath-dmenu.
(name . Maxime Devos)(address . maximedevos@telenet.be)(name . 53270@debbugs.gnu.org)(address . 53270@debbugs.gnu.org)
iKoZdHIwivh1dL3OWl4Fitqlj7tILEy7oLlM9CO-LzbZ9TTWwtMe1n6QNFQouGpkkX6gr_BlhUxWwS8hDYMR3sU4XY2DmTsHZDApThbfnMk=@protonmail.com
Hi Maxime,

I sent a v3 of the patch in response to your previous comment, were there other changes or comments you had in mind for this package?

Thanks!
John
Ludovic Courtès wrote 3 years ago
Re: bug#53270: [PATCH] gnu: Add yubikey-oath-dmenu.
(name . John Kehayias)(address . john.kehayias@protonmail.com)(name . 53270@debbugs.gnu.org)(address . 53270-done@debbugs.gnu.org)(name . Maxime Devos)(address . maximedevos@telenet.be)
8735ldxzx3.fsf_-_@gnu.org
Hi,

John Kehayias <john.kehayias@protonmail.com> skribis:

Toggle quote (7 lines)
> From a5958b588cebd23012d7d9cbeb8f1e22a3802ea2 Mon Sep 17 00:00:00 2001
> From: John Kehayias <john.kehayias@protonmail.com>
> Date: Fri, 14 Jan 2022 16:11:47 -0500
> Subject: [PATCH] gnu: Add yubikey-oath-dmenu.
>
> * gnu/packages/security-token.scm (yubikey-oath-dmenu): New variable.

Applied. I took the liberty to make the change below, to avoid using a
non-literal string as the ‘substitute*’ pattern (it’s possible to use a
non-literal string but more error prone).

Thanks John and Maxime!

Ludo’.
Toggle diff (25 lines)
diff --git a/gnu/packages/security-token.scm b/gnu/packages/security-token.scm
index b2f9f83ba2..8190e1e1e2 100644
--- a/gnu/packages/security-token.scm
+++ b/gnu/packages/security-token.scm
@@ -471,14 +471,12 @@ (define-public yubikey-oath-dmenu
(delete 'build) ; or build
(add-after 'unpack 'fix-paths
(lambda* (#:key inputs #:allow-other-keys)
- (for-each (lambda (tool)
- (substitute* "yubikey-oath-dmenu.py"
- (((string-append "'" tool))
- (string-append
- "'"
- (search-input-file inputs
- (string-append "/bin/" tool))))))
- (list "dmenu" "notify-send" "wl-copy" "xclip" "xdotool"))))
+ (substitute* "yubikey-oath-dmenu.py"
+ (("'(dmenu|notify-send|wl-copy|xclip|xdotool)" _ tool)
+ (string-append
+ "'"
+ (search-input-file inputs
+ (string-append "/bin/" tool)))))))
(replace 'install
(lambda _
(invoke "make" "install"
Closed
John Kehayias wrote 3 years ago
(name . Ludovic Courtès)(address . ludo@gnu.org)(name . 53270@debbugs.gnu.org)(address . 53270-done@debbugs.gnu.org)(name . Maxime Devos)(address . maximedevos@telenet.be)
QHjsUKi_MZiaYMzzP_pWJ-8YTah1SK6698fNWqmW149ohtv9mfWioQWBeSc2IM2M-l2DcZbiTXMcFP5aIaDIr15qA6HJ2dZxppM0LFEwVWg=@protonmail.com
Hi,

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Monday, January 24th, 2022 at 4:10 AM, Ludovic Courtès wrote:

Toggle quote (10 lines)
> > Subject: [PATCH] gnu: Add yubikey-oath-dmenu.
> > - gnu/packages/security-token.scm (yubikey-oath-dmenu): New variable.
>
> Applied. I took the liberty to make the change below, to avoid using a
> non-literal string as the ‘substitute*’ pattern (it’s possible to use a
> non-literal string but more error prone).
>
> Thanks John and Maxime!
>

Ah, that's how you do that, I'll add that to my virtual packaging toolbox.

Thanks for pushing and thanks for the review Maxime!

John
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 53270@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 53270
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help