me
/
guix
Archived
1
0
Fork 0

import: Wrap package expressions with define-public.

* guix/scripts/import.scm (guix-import): Wrap package expressions.

Change-Id: Ic4d986a4706a692b2fecd6fded8ac72ab6311687
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
master
Herman Rimm 2024-02-20 21:45:10 +01:00 committed by Ludovic Courtès
parent bf746ae258
commit a1d0610f83
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 11 additions and 3 deletions

View File

@ -6,6 +6,7 @@
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com> ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2022 Philip McGrath <philip@philipmcgrath.com> ;;; Copyright © 2022 Philip McGrath <philip@philipmcgrath.com>
;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -23,6 +24,7 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (guix scripts import) (define-module (guix scripts import)
#:use-module (guix import utils)
#:use-module (guix ui) #:use-module (guix ui)
#:use-module (guix scripts) #:use-module (guix scripts)
#:use-module (guix read-print) #:use-module (guix read-print)
@ -89,12 +91,18 @@ Run IMPORTER with ARGS.\n"))
(pretty-print-with-comments (current-output-port) expr))))) (pretty-print-with-comments (current-output-port) expr)))))
(match (apply (resolve-importer importer) args) (match (apply (resolve-importer importer) args)
((and expr (or ('package _ ...) ((and expr (or ('package _ ...)
('let _ ...) ('let _ ...)))
('define-public _ ...))) (print (package->definition expr)))
((and expr ('define-public _ ...))
(print expr)) (print expr))
((? list? expressions) ((? list? expressions)
(for-each (lambda (expr) (for-each (lambda (expr)
(print expr) (match expr
((and expr (or ('package _ ...)
('let _ ...)))
(print (package->definition expr)))
((and expr ('define-public _ ...))
(print expr)))
;; Two newlines: one after the closing paren, and ;; Two newlines: one after the closing paren, and
;; one to leave a blank line. ;; one to leave a blank line.
(newline) (newline)) (newline) (newline))