aboutsummaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorJan Nieuwenhuizen <janneke@gnu.org>2018-07-10 19:06:32 +0200
committerJan Nieuwenhuizen <janneke@gnu.org>2018-07-12 06:22:04 +0200
commite8e1f295f15fa56660a2c460d422795b1a31bed8 (patch)
tree19101ec2bfff62539d6c67f8f2fe2db3f2c6d46e /guix
parentf3a422511f793fb6c6cfeec2bb8735965a03294a (diff)
downloadgnu-guix-e8e1f295f15fa56660a2c460d422795b1a31bed8.tar
gnu-guix-e8e1f295f15fa56660a2c460d422795b1a31bed8.tar.gz
gexp: Allow bytevector as content of `plain-file'.
This allows for using a package source directly from git, doing something like (define (command->bytevector command) (let ((port (apply open-pipe* OPEN_READ command))) (let ((output (get-bytevector-all port))) (close-port port) output))) (define-public hello-git (package (name "hello") (version "git") (source (let* ((commit "stable-2.0") (content (command->bytevector `("git" "archive" "--format" "tar" "--prefix" ,(string-append commit "/") ,commit))) (file-name (string-append "hello-" commit))) (plain-file file-name content))) ... )) * guix/gexp.scm (<plain-file>): Also allow bytevector content. (plain-file-compiler): Handle bytevector content. * doc/guix.texi (G-Expressions): Describe plain-file now also taking bytevectors.
Diffstat (limited to 'guix')
-rw-r--r--guix/gexp.scm10
1 files changed, 7 insertions, 3 deletions
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 153b29bd42..cc3613f6f6 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
+;;; Copyright © 2018 Jan Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -23,6 +24,7 @@
#:use-module (guix derivations)
#:use-module (guix grafts)
#:use-module (guix utils)
+ #:use-module (rnrs bytevectors)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-9 gnu)
@@ -334,7 +336,7 @@ appears."
(%plain-file name content references)
plain-file?
(name plain-file-name) ;string
- (content plain-file-content) ;string
+ (content plain-file-content) ;string or bytevector
(references plain-file-references)) ;list (currently unused)
(define (plain-file name content)
@@ -349,8 +351,10 @@ This is the declarative counterpart of 'text-file'."
(define-gexp-compiler (plain-file-compiler (file <plain-file>) system target)
;; "Compile" FILE by adding it to the store.
(match file
- (($ <plain-file> name content references)
- (text-file name content references))))
+ (($ <plain-file> name (and (? string?) content) references)
+ (text-file name content references))
+ (($ <plain-file> name (and (? bytevector?) content) references)
+ (binary-file name content references))))
(define-record-type <computed-file>
(%computed-file name gexp guile options)