Subject: [PATCH 1/2] gnu: Add guix-hello.

From: zimoun <[email-masked]>
Date: Thu, 6 Oct 2022 18:39:34 +0200

From: Efraim Flashner <[email-masked]>

* gnu/packages/guix-extensions.scm (guix-hello): New variable.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add guix-extensions.

Co-authored-by: zimoun <[email-masked]>
---
 gnu/local.mk                     |  1 +
 gnu/packages/guix-extensions.scm | 60 ++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+)
 create mode 100644 gnu/packages/guix-extensions.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index 5976cbe90c..7bf1c34995 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -299,6 +299,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/packages/guile.scm			\
   %D%/packages/guile-wm.scm			\
   %D%/packages/guile-xyz.scm			\
+  %D%/packages/guix-extensions.scm		\
   %D%/packages/gv.scm				\
   %D%/packages/gxmessage.scm			\
   %D%/packages/hardware.scm			\
diff --git a/gnu/packages/guix-extensions.scm b/gnu/packages/guix-extensions.scm
new file mode 100644
index 0000000000..6294c15f3d
--- /dev/null
+++ b/gnu/packages/guix-extensions.scm
@@ -0,0 +1,60 @@
+;;; Copyright © 2022 Efraim Flashner <[email-masked]>
+;;; Copyright © 2022 Simon Tournier <[email-masked]>
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages guix-extensions)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix gexp)
+  #:use-module (guix packages)
+  #:use-module (guix build-system trivial)
+  #:use-module (gnu packages base))
+
+(define-public guix-hello
+  (package
+    (name "guix-hello")
+    (version "0")
+    (source #f)
+    (build-system trivial-build-system)
+    (arguments
+     (list
+      #:modules '((guix build utils))
+      #:builder
+      #~(begin
+          (use-modules (guix build utils))
+          (let ((dest (string-append #$output
+                                     "/share/guix/extensions/hello.scm"))
+                (hello            #$(this-package-input "hello")))
+            (mkdir-p (dirname dest))
+            (with-output-to-file dest
+              (lambda ()
+                (format #t
+                        "(define-module (guix extensions hello)~@
+                #:use-module (guix scripts)~@
+                #:export (guix-hello))~@
+~@
+(define-command (guix-hello . args)~@
+                (category extension)~@
+                (synopsis \"world\")~@
+                (apply system* \"~a/bin/hello\" args))~%"
+                        hello)))))))
+    (home-page "") ; Should be documentation location for GUIX_EXTENSIONS_PATH
+    (inputs
+     (list hello))
+    (synopsis "Example of Guix sub-command extension")
+    (description "This Guix extension provides a shell redirection from
+@code{guix hello} to @code{hello}.")
+    ;; The package definition is longer than the code;
+    ;; let this serve as the declaration of the license.
+    (license license:gpl3+)))
-- 
2.36.0