Subject: [bug#39021] [PATCH] Add Keybase

From: Jakub Kądziołka <[email-masked]>
Date: Tue, 7 Jan 2020 21:00:39 +0100

Hi Guix,

please find attached a set of patches that adds the non-GUI parts of
Keybase (the GUI is an Electron application - as far as I am aware,
there are no similar packages in Guix, so packaging the GUI requires a
significant amount of further work).

Unresolved question: in other distributions, the package provides user
units for systemd. Should the Guix package provide Shepherd services to
be ran as the user? If so, are there any other examples I could look at
and draw inspiration from? Also, I haven't been able to find any
documentation on how to set up user shepherd, apart from a passing
mention of that being possible in the documentation. I would appreciate
any pointers on the topic.

Regards,
Jakub Kądziołka
>From 0d744787c48c7184a70dda9fc1bb2c0d334fc080 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20K=C4=85dzio=C5=82ka?= <[email-masked]>
Date: Sun, 5 Jan 2020 17:13:20 +0100
Subject: [PATCH 1/2] build-system/go: Allow providing additional build flags

* guix/build-system/go.scm (build-flags): New argument.
* guix/build/go-build-system.scm (build): Use apply to pass the
  additional arguments to invoke.
---
 guix/build-system/go.scm       | 3 +++
 guix/build/go-build-system.scm | 7 ++++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/guix/build-system/go.scm b/guix/build-system/go.scm
index 1b916af8f9..86f57079b1 100644
--- a/guix/build-system/go.scm
+++ b/guix/build-system/go.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2016 Petter <[email-masked]>
 ;;; Copyright © 2017 Leo Famulari <[email-masked]>
+;;; Copyright © 2020 Jakub Kądziołka <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -82,6 +83,7 @@
                    (install-source? #t)
                    (import-path "")
                    (unpack-path "")
+                   (build-flags '())
                    (tests? #t)
                    (allow-go-reference? #f)
                    (system (%current-system))
@@ -109,6 +111,7 @@
                 #:install-source? ,install-source?
                 #:import-path ,import-path
                 #:unpack-path ,unpack-path
+                #:build-flags ,build-flags
                 #:tests? ,tests?
                 #:allow-go-reference? ,allow-go-reference?
                 #:inputs %build-inputs)))
diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.scm
index 4bc0156a88..49887848f6 100644
--- a/guix/build/go-build-system.scm
+++ b/guix/build/go-build-system.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2016 Petter <[email-masked]>
 ;;; Copyright © 2017, 2019 Leo Famulari <[email-masked]>
 ;;; Copyright © 2019 Maxim Cournoyer <[email-masked]>
+;;; Copyright © 2020 Jakub Kądziołka <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -209,18 +210,18 @@ unpacking."
                 (_ #f))
               inputs))))
 
-(define* (build #:key import-path #:allow-other-keys)
+(define* (build #:key import-path build-flags #:allow-other-keys)
   "Build the package named by IMPORT-PATH."
   (with-throw-handler
     #t
     (lambda _
-      (invoke "go" "install"
+      (apply invoke "go" "install"
               "-v" ; print the name of packages as they are compiled
               "-x" ; print each command as it is invoked
               ;; Respectively, strip the symbol table and debug
               ;; information, and the DWARF symbol table.
               "-ldflags=-s -w"
-              import-path))
+              `(,@build-flags ,import-path)))
     (lambda (key . args)
       (display (string-append "Building '" import-path "' failed.\n"
                               "Here are the results of `go env`:\n"))
-- 
2.24.1

>From 3de233a2d8e6bdb4723844337b69b6612616c9c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20K=C4=85dzio=C5=82ka?= <[email-masked]>
Date: Tue, 7 Jan 2020 20:29:21 +0100
Subject: [PATCH 2/2] gnu: Add keybase.

* gnu/packages/crypto.scm
  (keybase-component): New function.
  (keybase, git-remote-keybase, kbfs): New variables.
---
 gnu/packages/crypto.scm | 49 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/gnu/packages/crypto.scm b/gnu/packages/crypto.scm
index dd49c12e5b..c78515ae68 100644
--- a/gnu/packages/crypto.scm
+++ b/gnu/packages/crypto.scm
@@ -14,6 +14,7 @@
 ;;; Copyright © 2018 Tim Gesthuizen <[email-masked]>
 ;;; Copyright © 2019 Pierre Neidhardt <[email-masked]>
 ;;; Copyright © 2019 Tanguy Le Carrour <[email-masked]>
+;;; Copyright © 2020 Jakub Kądziołka <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -69,6 +70,7 @@
   #:use-module (guix git-download)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system go)
   #:use-module (guix build-system perl)
   #:use-module (guix build utils)
   #:use-module (srfi srfi-1)
@@ -1040,3 +1042,50 @@ minisign uses a slightly different format to store secret keys.  Minisign
 signatures include trusted comments in addition to untrusted comments.
 Trusted comments are signed, thus verified, before being displayed.")
     (license license:isc)))
+
+(define* (keybase-component #:key name repo-path synopsis description)
+  (package
+    (name name)
+    (version "5.1.1")
+    (source (origin
+              (method url-fetch)
+              (uri
+                (string-append "https://github.com/keybase/client/releases/download/v"
+                               version "/keybase-v" version ".tar.xz"))
+              (sha256
+                (base32
+                  "1i6waaprdr89k3lrg36hn11f5z8j0n2iv6gpyrynbh2h128cfpwy"))))
+    (build-system go-build-system)
+    (arguments
+     `(#:import-path ,(string-append "github.com/keybase/client/go/" repo-path)
+       #:unpack-path "github.com/keybase/client"
+       #:build-flags '("-tags" "production")
+       #:install-source? #f))
+    (home-page "https://keybase.io")
+    (synopsis synopsis)
+    (description description)
+    (license license:bsd-3)))
+
+(define-public keybase
+  (keybase-component
+    #:name "keybase"
+    #:repo-path "keybase"
+    #:synopsis "Command-line client for Keybase"
+    #:description "Keybase is a key directory that maps social media identities
+to encryption keys in a publically auditable manner.  End-to-end encrypted chat,
+cloud storage and git hosting is also provided."))
+
+(define-public git-remote-keybase
+  (keybase-component
+    #:name "git-remote-keybase"
+    #:repo-path "kbfs/kbfsgit/git-remote-keybase"
+    #:synopsis "Git remote helper for Keybase encrypted repositories"
+    #:description "keybase-kbfsgit provides the git remote helper that handles
+@code{keybase://} URIs."))
+
+(define-public kbfs
+  (keybase-component
+    #:name "kbfs"
+    #:repo-path "kbfs/kbfsfuse"
+    #:synopsis "FUSE handler for the Keybase filesystem"
+    #:description "Handles mounting /keybase"))
-- 
2.24.1