[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
07/11: packages: Add 'base64' macro.
From: |
guix-commits |
Subject: |
07/11: packages: Add 'base64' macro. |
Date: |
Thu, 21 May 2020 19:39:20 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 56f7ca6e7c8b5eadeee48b00bcbd78f9fa9e5f43
Author: Ludovic Courtès <address@hidden>
AuthorDate: Mon May 18 23:21:36 2020 +0200
packages: Add 'base64' macro.
* guix/packages.scm (define-compile-time-decoder): New macro.
(base32): Redefine in terms of it.
(base64): New macro.
---
guix/packages.scm | 31 +++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
diff --git a/guix/packages.scm b/guix/packages.scm
index 3fff50a..c1c4805 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -28,6 +28,7 @@
#:use-module (guix monads)
#:use-module (guix gexp)
#:use-module (guix base32)
+ #:autoload (guix base64) (base64-decode)
#:use-module (guix grafts)
#:use-module (guix derivations)
#:use-module (guix memoization)
@@ -62,6 +63,7 @@
origin-snippet
origin-modules
base32
+ base64
package
package?
@@ -197,19 +199,24 @@
(set-record-type-printer! <origin> print-origin)
-(define-syntax base32
- (lambda (s)
- "Return the bytevector corresponding to the given Nix-base32
+(define-syntax-rule (define-compile-time-decoder name string->bytevector)
+ "Define NAME as a macro that runs STRING->BYTEVECTOR at macro expansion time
+if possible."
+ (define-syntax name
+ (lambda (s)
+ "Return the bytevector corresponding to the given textual
representation."
- (syntax-case s ()
- ((_ str)
- (string? (syntax->datum #'str))
- ;; A literal string: do the conversion at expansion time.
- (with-syntax ((bv (nix-base32-string->bytevector
- (syntax->datum #'str))))
- #''bv))
- ((_ str)
- #'(nix-base32-string->bytevector str)))))
+ (syntax-case s ()
+ ((_ str)
+ (string? (syntax->datum #'str))
+ ;; A literal string: do the conversion at expansion time.
+ (with-syntax ((bv (string->bytevector (syntax->datum #'str))))
+ #''bv))
+ ((_ str)
+ #'(string->bytevector str))))))
+
+(define-compile-time-decoder base32 nix-base32-string->bytevector)
+(define-compile-time-decoder base64 base64-decode)
(define (origin-actual-file-name origin)
"Return the file name of ORIGIN, either its 'file-name' field or the file
- branch master updated (1ce1583 -> ef1d475), guix-commits, 2020/05/21
- 01/11: doc: Use "Alternatively" instead of "Alternately"., guix-commits, 2020/05/21
- 05/11: guix hash, guix download: Add '--hash'., guix-commits, 2020/05/21
- 06/11: guix hash, guix download: Support base64 format., guix-commits, 2020/05/21
- 07/11: packages: Add 'base64' macro.,
guix-commits <=
- 08/11: packages: Introduce <content-hash> and use it in <origin>., guix-commits, 2020/05/21
- 09/11: lint: archival: Use 'origin-hash'., guix-commits, 2020/05/21
- 02/11: maint: Add "make check-channel-news"., guix-commits, 2020/05/21
- 03/11: tests: Test 'add-to-store' with several hash algorithms., guix-commits, 2020/05/21
- 10/11: upstream: Use 'origin-hash'., guix-commits, 2020/05/21
- 04/11: tests: Test fixed-output derivations with several hash algorithms., guix-commits, 2020/05/21
- 11/11: gnu: llvm: Remove unused 'package-elisp-from-package' procedure., guix-commits, 2020/05/21