From 4f353c485dea4b549a0aabd1c87b0dd03fef4f1e Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Tue, 14 Apr 2020 18:02:26 +0200 Subject: scripts/package: Handle JSON files. * guix/scripts/package.scm (%options): Support loading from JSON files when "install-from-file" is used. --- guix/scripts/package.scm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index badb1dcd38..40445832aa 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -7,6 +7,7 @@ ;;; Copyright © 2016 Benz Schenk ;;; Copyright © 2016 Chris Marusich ;;; Copyright © 2019 Tobias Geerinckx-Rice +;;; Copyright © 2020 Ricardo Wurmus ;;; ;;; This file is part of GNU Guix. ;;; @@ -33,6 +34,7 @@ #:use-module (guix packages) #:use-module (guix profiles) #:use-module (guix search-paths) + #:use-module (guix import json) #:use-module (guix monads) #:use-module (guix utils) #:use-module (guix config) @@ -418,7 +420,10 @@ Install, remove, or upgrade packages in a single transaction.\n")) (option '(#\f "install-from-file") #t #f (lambda (opt name arg result arg-handler) (values (alist-cons 'install - (load* arg (make-user-module '())) + (let ((file (or (and (string-suffix? ".json" arg) + (json->scheme-file arg)) + arg))) + (load* file (make-user-module '()))) result) #f))) (option '(#\r "remove") #f #t -- cgit v1.2.3