[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/02: guix system: Type-check the file or expression.
From: |
guix-commits |
Subject: |
01/02: guix system: Type-check the file or expression. |
Date: |
Thu, 16 May 2019 07:35:50 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit ce10e6053bb02e936b3a0862f3a3f86010b948d0
Author: Ludovic Courtès <address@hidden>
Date: Wed May 15 22:36:46 2019 +0200
guix system: Type-check the file or expression.
Previously, users would get a wrong-type-arg exception down the road
with an intimidating backtrace.
* guix/scripts/system.scm (process-action)[ensure-operating-system]: New
procedure.
Use it.
---
guix/scripts/system.scm | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 8434d1e..60c1ca5 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -1143,22 +1143,30 @@ Some ACTIONS support additional ARGS.\n"))
ACTION must be one of the sub-commands that takes an operating system
declaration as an argument (a file name.) OPTS is the raw alist of options
resulting from command-line parsing."
+ (define (ensure-operating-system file-or-exp obj)
+ (unless (operating-system? obj)
+ (leave (G_ "'~a' does not return an operating system~%")
+ file-or-exp))
+ obj)
+
(let* ((file (match args
(() #f)
((x . _) x)))
(expr (assoc-ref opts 'expression))
(system (assoc-ref opts 'system))
- (os (cond
- ((and expr file)
- (leave
- (G_ "both file and expression cannot be
specified~%")))
- (expr
- (read/eval expr))
- (file
- (load* file %user-module
- #:on-error (assoc-ref opts 'on-error)))
- (else
- (leave (G_ "no configuration specified~%")))))
+ (os (ensure-operating-system
+ (or file expr)
+ (cond
+ ((and expr file)
+ (leave
+ (G_ "both file and expression cannot be
specified~%")))
+ (expr
+ (read/eval expr))
+ (file
+ (load* file %user-module
+ #:on-error (assoc-ref opts 'on-error)))
+ (else
+ (leave (G_ "no configuration specified~%"))))))
(dry? (assoc-ref opts 'dry-run?))
(bootloader? (assoc-ref opts 'install-bootloader?))