From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 14 12:44:16 2020 Received: (at submit) by debbugs.gnu.org; 14 Apr 2020 16:44:16 +0000 Received: from localhost ([127.0.0.1]:34621 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOOfY-0001Wy-77 for submit@debbugs.gnu.org; Tue, 14 Apr 2020 12:44:16 -0400 Received: from lists.gnu.org ([209.51.188.17]:55254) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOOfV-0001Wq-CW for submit@debbugs.gnu.org; Tue, 14 Apr 2020 12:44:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58853) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jOOfT-0004C4-Ks for guix-patches@gnu.org; Tue, 14 Apr 2020 12:44:12 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_20,RCVD_IN_DNSWL_NONE, URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jOOfS-0007Oj-BY for guix-patches@gnu.org; Tue, 14 Apr 2020 12:44:11 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21321) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jONjr-0004Hu-V1 for guix-patches@gnu.org; Tue, 14 Apr 2020 11:44:40 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1586879076; cv=none; d=zohomail.com; s=zohoarc; b=AbR9LrR4FHbkP8oms/xSuz8t6VejH5m9AAHe0veeHmjQAumqswAs/tyQ/aFZ31D6PoO1lfdWj2p2C3lfL2poqFVJewZIK2vGTj3UJB+fxjjBtiVQ/s5qgPaMrhRsyovVm5L3la0Im4EbW88bMX9LMVyVoZpvf/QWAGIt4vwZlBc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586879076; h=Content-Type:Content-Transfer-Encoding:Date:From:MIME-Version:Message-ID:Subject:To; bh=85SoSo5a1LVtWbjuh/BlUA9lAA2SSVfHfR5ETi9KJV0=; b=JeigG635l2zcKQQ4mNB0b6UwPjqooDpVhh16BO1orS7FO2URPUWgbAgwQKW0CkLh9s/fTpjbEsfa5yu9mzZdsh3dieabXi68UR3oEvAVw3QANyJfBhIO/SzpEiiSbEtUy4tCWQbF3f0kvLOOnzv9oCp1zNL/LkRzgexu4+ilbSE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1586879076; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:To:Subject:Message-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=85SoSo5a1LVtWbjuh/BlUA9lAA2SSVfHfR5ETi9KJV0=; b=HDJtLEzPXplSfc0jUECMuc9CtY9arFxijJXxtkToxM5lsiTAYdxrb1CK2kj+Rhf6 imFymZOuYv9nGMjOldC75EJJeEM4iY/rrKOjDawxnnyaYbklE525X87BlPjEUuGqGt/ Aslcpgzj6RvJZjQ+oUlS8BsQsjFsh3o3pC7III0Q= Received: from localhost (p54AD4D5F.dip0.t-ipconnect.de [84.173.77.95]) by mx.zohomail.com with SMTPS id 1586879073941243.43620785442783; Tue, 14 Apr 2020 08:44:33 -0700 (PDT) User-agent: mu4e 1.2.0; emacs 26.3 From: Ricardo Wurmus To: guix-patches@gnu.org Subject: Build and install packages from JSON definitions Message-ID: <87y2qym5v8.fsf@elephly.net> X-URL: https://elephly.net X-PGP-Key: https://elephly.net/rekado.pubkey X-PGP-Fingerprint: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC Date: Tue, 14 Apr 2020 17:44:31 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 136.143.188.53 X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Hi Guix, did you know that we have JSON importer? Admittedly, it=E2=80=99s not very useful because people don=E2=80=99t generally use JSON syntax to define Guix packages. Not even Guix lets you build and install packages from JSON definitions, so what=E2=80=99s the point really? Well, fret not! This patch set adds support for JSON package definitions to =E2=80=9Cguix package -f=E2=80=9D and =E2=80=9Cguix build -f= =E2=80=9D. You can now dump this into a file =E2=80=9Chello.json=E2=80=9D: --8<---------------cut here---------------start------------->8--- { "name": "hello", "version": "2.10", "source": "mirror://gnu/hello/hello-2.10.tar.gz", "build-system": "gnu", "home-page": "https://www.gnu.org/software/hello/", "synopsis": "Hello, GNU world: An example GNU package", "description": "GNU Hello prints a greeting.", "license": "GPL-3.0+", "native-inputs": ["gettext"] } --8<---------------cut here---------------end--------------->8--- and then install the hello package with =E2=80=9Cguix package -f hello.json= =E2=80=9D without having to first run the JSON importer. Since the JSON importer doesn=E2=80=99t know how to work with more than one definition you can=E2=80=99t have more than one custom definition in your J= SON file, but if there=E2=80=99s interest we can easily add support for this. (My patch set does not come with documentation changes for =E2=80=9Cguix package=E2=80=9D or =E2=80=9Cguix build=E2=80=9D.) What do you think? -- Ricardo From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 14 13:20:12 2020 Received: (at 40629) by debbugs.gnu.org; 14 Apr 2020 17:20:12 +0000 Received: from localhost ([127.0.0.1]:34703 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOPEK-0006ZB-0U for submit@debbugs.gnu.org; Tue, 14 Apr 2020 13:20:12 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21361) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOPEI-0006Yu-3j for 40629@debbugs.gnu.org; Tue, 14 Apr 2020 13:20:10 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1586884806; cv=none; d=zohomail.com; s=zohoarc; b=gl0/NzvBSYIV9fJYJ6ChzA9EgoPZezpBN/xvLPMVdqdnTqZszJEr/0vCl0zBrWcUrWCs4aqzLu+s2KMYfK/1U/6PSa1pK+QCH7mkBQByZHzqZa0ppzon8gL4wCN0j4cMRCtRmjJcHCWuv8PJQJ60kLWP3JwO9awCnE90dq0/xT0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586884806; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=QTS4QwdOObT1ABRKlGYcrOBk/o0BS0s8bMPRQD1GY+I=; b=ZLkaF/tITuYQ4JYmBR4BVx73FepwQvAluvFWmlPWl/kxP3uEFOEM9Wi8uEZp6UmyErQRdbVOe+7Mo5sj4TNE6QzfMIQefkiFpMMIuyWThAxv+/CvIrUwVGs6vhn4e5Yvct6Wm7E83kuarQ5CPA7+j2kvyD9I1UyadoryPEOGBMk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1586884806; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:To:Cc:Message-ID:Subject:Date:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=QTS4QwdOObT1ABRKlGYcrOBk/o0BS0s8bMPRQD1GY+I=; b=A1ksKYg1fQVIi+qq0rhGTdexG0qa0c7X1tlTDGTllpIwiiVv8yFHgi+yicf5ARM3 Rlu/7Qi5ZGbSVuoIdGmdVS9P7H+u6mxCIyvCExR3fc/Lrf86DhBQy3m8M0qFdKx+TvU LtGWGj1F/O1moGW1miX4y4/s/bBj5pDUzNSuUwBo= Received: from localhost (p54AD4D5F.dip0.t-ipconnect.de [84.173.77.95]) by mx.zohomail.com with SMTPS id 1586884804887512.8893174671015; Tue, 14 Apr 2020 10:20:04 -0700 (PDT) From: Ricardo Wurmus To: 40629@debbugs.gnu.org Message-ID: <20200414171959.3428-1-rekado@elephly.net> Subject: [PATCH 1/5] import/print: Return license with prefix. Date: Tue, 14 Apr 2020 19:19:55 +0200 X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 40629 Cc: Ricardo Wurmus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/import/print.scm (license->code): Prepend license: prefix. --- guix/import/print.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/guix/import/print.scm b/guix/import/print.scm index 4c2a91fa4f..b819e7cf90 100644 --- a/guix/import/print.scm +++ b/guix/import/print.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright =C2=A9 2017 Ricardo Wurmus +;;; Copyright =C2=A9 2017, 2020 Ricardo Wurmus ;;; ;;; This file is part of GNU Guix. ;;; @@ -57,7 +57,7 @@ when evaluated." ;; Print either license variable name or the code for a license object (define (license->code lic) (let ((var (variable-name lic '(guix licenses)))) - (or var + (or (symbol-append 'license: var) `(license (name ,(license-name lic)) (uri ,(license-uri lic)) --=20 2.25.1 From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 14 13:20:15 2020 Received: (at 40629) by debbugs.gnu.org; 14 Apr 2020 17:20:15 +0000 Received: from localhost ([127.0.0.1]:34705 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOPEN-0006ZO-8m for submit@debbugs.gnu.org; Tue, 14 Apr 2020 13:20:15 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21363) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOPEJ-0006Z4-IB for 40629@debbugs.gnu.org; Tue, 14 Apr 2020 13:20:11 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1586884810; cv=none; d=zohomail.com; s=zohoarc; b=QbCWBK/B+oLVKrf0oGOQs2nBTl8yA4++uwrQgIhT1vCOQhuVCC9r5CUCvBnVjw2vHBMSF+V+FnCj1wOuohxy4qub5di6fDaTBkuMrTL2jQd6mbz9qRLpvM5pk4Eipcnn/5MEoNFXhvrZuXMBA3CXkfyLH07WrFdaCWm7nQh5pFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586884810; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=iwCnpxwYd7GNTssywICiEExtqDcFHv6XlNcD/wYqOxo=; b=Z3bzMF+9RRTn3HqLZoU0ogJ81eyuFowgpxbA5uyOgKQRCVVjt3rZG+Op5wg1nizPmiMAZXFNyfJDY2p8XzWe9SSZRUq/zW3t6qOOvFDQOkioyjG2mm47sdo4zAzYoalWHnrG5CbcX5d5EgcPINrW7x0qnQf57ClxmnlhDn45AYg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1586884810; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=iwCnpxwYd7GNTssywICiEExtqDcFHv6XlNcD/wYqOxo=; b=At7khqfvvLDWvA0lr7iWngp9R6cEwNN8Tn8pB+IhhhskUPnNPfMp5jcYAkqonSDt wSlA00FF80w3+r+nJESZao5SIfBS7I0m1Pedab+ym52rbFLqs5xkuuGX85D5F//ww6+ WQGpt9FKLNQ6C+izYeRjczDXjOd5FTLfzngdEogw= Received: from localhost (p54AD4D5F.dip0.t-ipconnect.de [84.173.77.95]) by mx.zohomail.com with SMTPS id 1586884808672645.5786732174112; Tue, 14 Apr 2020 10:20:08 -0700 (PDT) From: Ricardo Wurmus To: 40629@debbugs.gnu.org Message-ID: <20200414171959.3428-2-rekado@elephly.net> Subject: [PATCH 2/5] import/print: package->code: Wrap build system value in module reference. Date: Tue, 14 Apr 2020 19:19:56 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200414171959.3428-1-rekado@elephly.net> References: <20200414171959.3428-1-rekado@elephly.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset=utf8 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 40629 Cc: Ricardo Wurmus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/import/print.scm (package->code): Return build system value with corresponding module. --- guix/import/print.scm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/guix/import/print.scm b/guix/import/print.scm index b819e7cf90..4529a79b23 100644 --- a/guix/import/print.scm +++ b/guix/import/print.scm @@ -131,8 +131,9 @@ when evaluated." ,@(if replacement `((replacement ,replacement)) '()) - (build-system ,(symbol-append (build-system-name build-system) - '-build-system)) + (build-system (@ (guix build-system ,(build-system-name build-syste= m)) + ,(symbol-append (build-system-name build-system) + '-build-system))) ,@(match arguments (() '()) (args `((arguments ,(list 'quasiquote args))))) --=20 2.25.1 From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 14 13:20:18 2020 Received: (at 40629) by debbugs.gnu.org; 14 Apr 2020 17:20:18 +0000 Received: from localhost ([127.0.0.1]:34708 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOPEQ-0006Ze-GA for submit@debbugs.gnu.org; Tue, 14 Apr 2020 13:20:18 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21365) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOPEP-0006ZW-4y for 40629@debbugs.gnu.org; Tue, 14 Apr 2020 13:20:17 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1586884814; cv=none; d=zohomail.com; s=zohoarc; b=IUQ3ADMhrBlyTa82mxWvxsu2na54LNJfNm3wvO8Bir5QZm6XuVTDFZq5T0bYUutr4mO/6ZeDTHqVzE3T4a/GyUK0Mjyzz6pSv++0Joaa/bUpPgJCX+7hjhOJGr0u48Quh3NiePn4Z3nuP10h05/RGdcMVenq4j+Q105BoKlin/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586884814; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=UUgbWQ6Qsht1d859gQBjbzqXXWFm4hVSq2Ma6d3YpG0=; b=a+tXHBuryhF2iEjzPEW57EqLNoy99MGXuSB+Vy3u6kbA37dmlxeFAkTGtbw9Vxt0avPdlAbMWgdxzjOY4CpfrytnYKqfZnPt0qN7Z0esacdH3ceeld95Ap8QKHkfGqH9axv+8lMSWImGxCXQXDa1wdNQUcrU60b/AWBcT7HrUMg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1586884814; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=UUgbWQ6Qsht1d859gQBjbzqXXWFm4hVSq2Ma6d3YpG0=; b=Wq335o0RFSmvAgIa+kNIwKilxheocd5ddAgQXAchch1o7iSryU9cxQYIPcoZERnx 1FTVhYfZbcoI9zXqzPRaPRQZ86Ul25aWusnQ76LDutF5y6vQV5M2Amvg3It9vcXTFNA Dx4cAypMAx70XDhMIt4rDQD2svQKOVHIDKfpbvsA= Received: from localhost (p54AD4D5F.dip0.t-ipconnect.de [84.173.77.95]) by mx.zohomail.com with SMTPS id 1586884812244300.5417325862229; Tue, 14 Apr 2020 10:20:12 -0700 (PDT) From: Ricardo Wurmus To: 40629@debbugs.gnu.org Message-ID: <20200414171959.3428-3-rekado@elephly.net> Subject: [PATCH 3/5] import/json: Add json->scheme-file. Date: Tue, 14 Apr 2020 19:19:57 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200414171959.3428-1-rekado@elephly.net> References: <20200414171959.3428-1-rekado@elephly.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 40629 Cc: Ricardo Wurmus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/import/json.scm (json->code, json->scheme-file): New procedures. --- guix/import/json.scm | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/guix/import/json.scm b/guix/import/json.scm index 8900724dcd..16dc2ad5cb 100644 --- a/guix/import/json.scm +++ b/guix/import/json.scm @@ -2,6 +2,7 @@ ;;; Copyright =C2=A9 2014 David Thompson ;;; Copyright =C2=A9 2015, 2016 Eric Bavier ;;; Copyright =C2=A9 2018, 2019 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2020 Ricardo Wurmus ;;; ;;; This file is part of GNU Guix. ;;; @@ -22,8 +23,12 @@ #:use-module (json) #:use-module (guix http-client) #:use-module (guix import utils) + #:use-module (guix import print) + #:use-module (ice-9 rdelim) + #:use-module (srfi srfi-2) #:use-module (srfi srfi-34) - #:export (json-fetch)) + #:export (json-fetch + json->scheme-file)) =20 (define* (json-fetch url ;; Note: many websites returns 403 if we omit a @@ -42,3 +47,31 @@ the query." (result (json->scm port))) (close-port port) result))) + +(define (json->code file-name) + "Read FILE-NAME containing a JSON package definition and return an +S-expression, or return #F when the JSON is invalid." + (catch 'json-invalid + (lambda () + (let ((json (json-string->scm + (with-input-from-file file-name read-string)))) + (package->code (alist->package json)))) + (const #f))) + +(define (json->scheme-file file) + "Convert the FILE containing a JSON package definition to a Scheme +representation and return the new file name (or #F on error)." + (and-let* ((json (json->code file)) + (file* (let* ((tempdir (or (getenv "TMPDIR") "/tmp")) + (template (string-append tempdir "/guix-XXXXXX"= )) + (port (mkstemp! template))) + (close-port port) + template))) + (call-with-output-file file* + (lambda (port) + (write '(use-modules (gnu) + (guix) + ((guix licenses) #:prefix license:)) + port) + (write json port))) + file*)) --=20 2.25.1 From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 14 13:20:23 2020 Received: (at 40629) by debbugs.gnu.org; 14 Apr 2020 17:20:23 +0000 Received: from localhost ([127.0.0.1]:34712 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOPEU-0006Zw-PR for submit@debbugs.gnu.org; Tue, 14 Apr 2020 13:20:23 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21367) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOPET-0006Zn-5J for 40629@debbugs.gnu.org; Tue, 14 Apr 2020 13:20:21 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1586884818; cv=none; d=zohomail.com; s=zohoarc; b=UbOfGuj72AN4yENgWZYm6zxgKkSUGNmNzWupXKKum6DiIi6NTfeXJo/d21mglhRWDTEtUbsBJvuKTQjQnwi7l0sC/X4yWvPRN3rka/+5v+++Yb9wEqAQoSfQNo37yGpwLD+8sdiDuuPlxUaEEYmqBd1mwb4sAkWq94nGgx3HZwA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586884818; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=FoIpDRQjgyhJFei7QFOnUse0FGrtxi3w77KOsQTXkHA=; b=aEA/5HbFulzgO+rEs9uqrWZVlOQurOktNPXh9gVLj3mnW3nQI7tewXw46Xs4cj90KUZtyXM0duFnXw82RlydPv6VnKU669TutklDBTOpHuGdw+PyJO5huW+iND6g8HMfFUF5a+A4hWObBKGKaMrXujyEnRN28jT0izipkmga0Bg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1586884818; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=FoIpDRQjgyhJFei7QFOnUse0FGrtxi3w77KOsQTXkHA=; b=Nb9svazwdfPtR/niXYjwmeBT3WktJHrqsBsilqo0xUrEzFO5MlYzmkOjKnIfmcMs N7iJrDIswdoPsgocsoPpjoqyalblRZls+bij+BC+8pAzESlzvdGLahiWJjU3tliwmb7 fUw4s8nY9k7wW9TUfEynZ3F4vSzz7wSmSMujk3cg= Received: from localhost (p54AD4D5F.dip0.t-ipconnect.de [84.173.77.95]) by mx.zohomail.com with SMTPS id 1586884815879691.574894298318; Tue, 14 Apr 2020 10:20:15 -0700 (PDT) From: Ricardo Wurmus To: 40629@debbugs.gnu.org Message-ID: <20200414171959.3428-4-rekado@elephly.net> Subject: [PATCH 4/5] scripts/build: options->things-to-build: Handle .json files. Date: Tue, 14 Apr 2020 19:19:58 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200414171959.3428-1-rekado@elephly.net> References: <20200414171959.3428-1-rekado@elephly.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 40629 Cc: Ricardo Wurmus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/scripts/build.scm (options->things-to-build): Handle files that end = on .json. --- guix/scripts/build.scm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index 79bd84a1a0..8ff2fd1910 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -2,6 +2,7 @@ ;;; Copyright =C2=A9 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 = Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2013 Mark H Weaver ;;; Copyright =C2=A9 2020 Marius Bakke +;;; Copyright =C2=A9 2020 Ricardo Wurmus ;;; ;;; This file is part of GNU Guix. ;;; @@ -21,6 +22,7 @@ (define-module (guix scripts build) #:use-module (guix ui) #:use-module (guix scripts) + #:use-module (guix import json) #:use-module (guix store) #:use-module (guix derivations) #:use-module (guix packages) @@ -834,7 +836,10 @@ build---packages, gexps, derivations, and so on." (else (list (specification->package spec))))) (('file . file) - (ensure-list (load* file (make-user-module '())))) + (let ((file (or (and (string-suffix? ".json" file) + (json->scheme-file file)) + file))) + (ensure-list (load* file (make-user-module '()))))) (('manifest . manifest) (map manifest-entry-item (manifest-entries --=20 2.25.1 From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 14 13:20:24 2020 Received: (at 40629) by debbugs.gnu.org; 14 Apr 2020 17:20:24 +0000 Received: from localhost ([127.0.0.1]:34714 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOPEW-0006a9-9I for submit@debbugs.gnu.org; Tue, 14 Apr 2020 13:20:24 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21369) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOPEU-0006Zu-93 for 40629@debbugs.gnu.org; Tue, 14 Apr 2020 13:20:22 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1586884820; cv=none; d=zohomail.com; s=zohoarc; b=UCDzHqPF9y9e+mljEmkkQRM/BVGsb9zbL5pKFsN/6jDSFtW+ybAelpbT+4LiKaExajJ4r0UVs7QAx1g+Xn3gpEkmwOaOG560BGNXi9Qxmj9fUttVn9k0GuaEzHDQPHmKTooVI3moPTz4ngmKDL8XBB/ufbW31Xcz1GdRDPgCK3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586884820; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=yYjahCN0fdCv3EAxJIwAUr102ZQtAZO/Z9faAECH/X8=; b=AzZ76GiROeiVPH1UIje72qnm9SfcKK0mZlorpgH65a0gEVfBVhWEy5kNF4wIXKJugzM3PJcMQP2se24UxwBqm+oWGGxc9xO7DsXJ7/oKkoP5Me3adxdM7PuRyECXxIo8dso+l7dzdV1P1/Nl636mnRY89+HMTK0qWz5F2cmC7IM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1586884820; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=yYjahCN0fdCv3EAxJIwAUr102ZQtAZO/Z9faAECH/X8=; b=BVRf3usffMt7bySBO/+OnQc6GPyrcdEUK9IYUGl5TQo1XlkxMTwNo1PzGaAVAzvO TACPNHwbUqZMcVq4fBSfJJi/ESNIuts2dFrvlr4tqerPmuf8CNHhw5ups0oP7gaa1Jt Cq2nBSbnJiTeJ6LpypOk+bF2Pdr0iRm/+AbNKM7s= Received: from localhost (p54AD4D5F.dip0.t-ipconnect.de [84.173.77.95]) by mx.zohomail.com with SMTPS id 1586884819336344.9745503257118; Tue, 14 Apr 2020 10:20:19 -0700 (PDT) From: Ricardo Wurmus To: 40629@debbugs.gnu.org Message-ID: <20200414171959.3428-5-rekado@elephly.net> Subject: [PATCH 5/5] scripts/package: Handle JSON files. Date: Tue, 14 Apr 2020 19:19:59 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200414171959.3428-1-rekado@elephly.net> References: <20200414171959.3428-1-rekado@elephly.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 40629 Cc: Ricardo Wurmus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * 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 =C2=A9 2016 Benz Schenk ;;; Copyright =C2=A9 2016 Chris Marusich ;;; Copyright =C2=A9 2019 Tobias Geerinckx-Rice +;;; Copyright =C2=A9 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 trans= action.\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 --=20 2.25.1 From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 14 18:48:29 2020 Received: (at 40629) by debbugs.gnu.org; 14 Apr 2020 22:48:29 +0000 Received: from localhost ([127.0.0.1]:34944 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOUM1-0001ly-B5 for submit@debbugs.gnu.org; Tue, 14 Apr 2020 18:48:29 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21392) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOULz-0001lq-6R for 40629@debbugs.gnu.org; Tue, 14 Apr 2020 18:48:27 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1586904505; cv=none; d=zohomail.com; s=zohoarc; b=gnWd1ZJBrMcEqJ933n3B7y4LsXruI6H/emgLdDI97gYjiKE+QkXcjjOKadHTCHSnc+hA+RjjLZcc+aPeAx4AFMdKm2nwFA89Y0h4iDeQeobiNUxvduwMQ23CIW9Hl2dvqyV3FA+oLRpMbDxH1SZLv2/yMhoU2LCvsvYP8d7IsD8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586904505; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=dI1Fr0Zyxo6J8F7oQNR/fZdLnd03kVq/icYAObSyZ/g=; b=BARCOiNu1bQaRqzdqXHVNAqfc8sM8ZQJLR1mQH1f/EEnlcKmXeX8Z4hPSvhX0T5ys8l1I8rvbOdbukiQoYRAJM1il11ZeJWB29gLNSD5/GFfilmEj+bLLpTw1arsXrF45SwNA1EFhHKjkk6lYSJvIv1drESbOfzqqpI8HKUqmqw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1586904505; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:To:Cc:Message-ID:Subject:Date:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=dI1Fr0Zyxo6J8F7oQNR/fZdLnd03kVq/icYAObSyZ/g=; b=aBfpSHOec16o2Wtbudz2DXsda2detnjlK08ZZwmweOMxx9TkAUMm/jUOkaAzAKJk T4qUQJu9RyQc2USCcnFGIBJGao/93s0+cx/TO1hQnA+gutpv/XM1YQldQACJ35LqOUm 5/KmCPfkhUxnJAdkFZlIua0B7E90Eo6+SsW7/23E= Received: from localhost (p54AD4D5F.dip0.t-ipconnect.de [84.173.77.95]) by mx.zohomail.com with SMTPS id 1586904502368542.4275580410043; Tue, 14 Apr 2020 15:48:22 -0700 (PDT) From: Ricardo Wurmus To: 40629@debbugs.gnu.org Message-ID: <20200414224817.3850-1-rekado@elephly.net> Subject: [PATCH 6/9] import/json: Use json->code. Date: Wed, 15 Apr 2020 00:48:14 +0200 X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset=utf8 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 40629 Cc: Ricardo Wurmus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/import/json.scm (json->code): Export procedure. * guix/scripts/import/json.scm (guix-import-json): Use json->code. --- guix/import/json.scm | 1 + guix/scripts/import/json.scm | 12 +++--------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/guix/import/json.scm b/guix/import/json.scm index 16dc2ad5cb..8f8dbbd05d 100644 --- a/guix/import/json.scm +++ b/guix/import/json.scm @@ -28,6 +28,7 @@ #:use-module (srfi srfi-2) #:use-module (srfi srfi-34) #:export (json-fetch + json->code json->scheme-file)) =20 (define* (json-fetch url diff --git a/guix/scripts/import/json.scm b/guix/scripts/import/json.scm index c9daf65479..778e5f4bc5 100644 --- a/guix/scripts/import/json.scm +++ b/guix/scripts/import/json.scm @@ -23,7 +23,7 @@ #:use-module (guix utils) #:use-module (guix scripts) #:use-module (guix import utils) - #:use-module (guix import print) + #:use-module (guix import json) #:use-module (guix scripts import) #:use-module (guix packages) #:use-module (srfi srfi-1) @@ -88,14 +88,8 @@ Import and convert the JSON package definition in PACKAG= E-FILE.\n")) (reverse opts)))) (match args ((file-name) - (catch 'json-invalid - (lambda () - (let ((json (json-string->scm - (with-input-from-file file-name read-string)))) - ;; TODO: also print define-module boilerplate - (package->code (alist->package json)))) - (lambda _ - (leave (G_ "invalid JSON in file '~a'~%") file-name)))) + (or (json->code file-name) + (leave (G_ "invalid JSON in file '~a'~%") file-name))) (() (leave (G_ "too few arguments~%"))) ((many ...) --=20 2.25.1 From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 14 18:48:33 2020 Received: (at 40629) by debbugs.gnu.org; 14 Apr 2020 22:48:33 +0000 Received: from localhost ([127.0.0.1]:34947 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOUM4-0001mF-J7 for submit@debbugs.gnu.org; Tue, 14 Apr 2020 18:48:33 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21393) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOUM2-0001m6-IR for 40629@debbugs.gnu.org; Tue, 14 Apr 2020 18:48:30 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1586904508; cv=none; d=zohomail.com; s=zohoarc; b=AxrcUYkiIo2dhjgZA76LQ3CwBz4oQFwoqj1cxoptUCnQB5IU5PiobPx4EZkzg0jPTW6+lR/ZiNevm3Rujsad8bJZUR8xjpnjVQv4gMIaRU0i57uM+dNo0taAGraFYk2mZIVqHzF4he9DEzOXq7Vp/ToJGkOl5SSk/XLXjvAczEg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586904508; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=lNuYbA+owNzNcGZQMMF3bsFU0SVssoihNZbq8hTT+qM=; b=TD9NxV6sO9orK6952U2aeil+3HjL0CdQ2f+onEsHYm3rD0c6gEJpF205IDA/V3ymuWmq//Wdgj8KxriwdzzL19HV7nc0S1UX7AIzMq5Y99gfRCfwq125AspLeiyxwQzQnHBGPhC1QHMK3YXZy0l9WXaXWm5XgXHJfaQoIPtI6m8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1586904508; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=lNuYbA+owNzNcGZQMMF3bsFU0SVssoihNZbq8hTT+qM=; b=iSSO6aRnSx7A8SzOvi4gPq/HP0SiXPuoOusSeH0zCZPtug/y5qjTChzjJY5EU93V t7iKAhQID2w2lWQQYThu+3lWIZb6W7Q3fgPGJprIOXjnhEl6GXIfkzcNWAzbbdhIF8p fLGohRi3gib86h6ZZ2y2xb9XsFQUkuKqswsYQSXY= Received: from localhost (p54AD4D5F.dip0.t-ipconnect.de [84.173.77.95]) by mx.zohomail.com with SMTPS id 1586904506102700.3554931827858; Tue, 14 Apr 2020 15:48:26 -0700 (PDT) From: Ricardo Wurmus To: 40629@debbugs.gnu.org Message-ID: <20200414224817.3850-2-rekado@elephly.net> Subject: [PATCH 7/9] import/print: package->code: Wrap S-expression in definition. Date: Wed, 15 Apr 2020 00:48:15 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200414224817.3850-1-rekado@elephly.net> References: <20200414224817.3850-1-rekado@elephly.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset=utf8 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 40629 Cc: Ricardo Wurmus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/import/print.scm (package->code): Return a definition, not just a package expression. --- guix/import/print.scm | 87 ++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/guix/import/print.scm b/guix/import/print.scm index 4529a79b23..08f3ec9c34 100644 --- a/guix/import/print.scm +++ b/guix/import/print.scm @@ -121,46 +121,47 @@ when evaluated." (home-page (package-home-page package)) (supported-systems (package-supported-systems package)) (properties (package-properties package))) - `(package - (name ,name) - (version ,version) - (source ,(source->code source version)) - ,@(match properties - (() '()) - (_ `((properties ,properties)))) - ,@(if replacement - `((replacement ,replacement)) - '()) - (build-system (@ (guix build-system ,(build-system-name build-syste= m)) - ,(symbol-append (build-system-name build-system) - '-build-system))) - ,@(match arguments - (() '()) - (args `((arguments ,(list 'quasiquote args))))) - ,@(match outputs - (("out") '()) - (outs `((outputs (list ,@outs))))) - ,@(match native-inputs - (() '()) - (pkgs `((native-inputs ,(package-lists->code pkgs))))) - ,@(match inputs - (() '()) - (pkgs `((inputs ,(package-lists->code pkgs))))) - ,@(match propagated-inputs - (() '()) - (pkgs `((propagated-inputs ,(package-lists->code pkgs))))) - ,@(if (lset=3D string=3D? supported-systems %supported-systems) - '() - `((supported-systems (list ,@supported-systems)))) - ,@(match (map search-path-specification->code native-search-paths) - (() '()) - (paths `((native-search-paths (list ,@paths))))) - ,@(match (map search-path-specification->code search-paths) - (() '()) - (paths `((search-paths (list ,@paths))))) - (home-page ,home-page) - (synopsis ,synopsis) - (description ,description) - (license ,(if (list? license) - `(list ,@(map license->code license)) - (license->code license)))))) + `(define-public ,(string->symbol name) + (package + (name ,name) + (version ,version) + (source ,(source->code source version)) + ,@(match properties + (() '()) + (_ `((properties ,properties)))) + ,@(if replacement + `((replacement ,replacement)) + '()) + (build-system (@ (guix build-system ,(build-system-name build-sys= tem)) + ,(symbol-append (build-system-name build-system) + '-build-system))) + ,@(match arguments + (() '()) + (args `((arguments ,(list 'quasiquote args))))) + ,@(match outputs + (("out") '()) + (outs `((outputs (list ,@outs))))) + ,@(match native-inputs + (() '()) + (pkgs `((native-inputs ,(package-lists->code pkgs))))) + ,@(match inputs + (() '()) + (pkgs `((inputs ,(package-lists->code pkgs))))) + ,@(match propagated-inputs + (() '()) + (pkgs `((propagated-inputs ,(package-lists->code pkgs))))) + ,@(if (lset=3D string=3D? supported-systems %supported-systems) + '() + `((supported-systems (list ,@supported-systems)))) + ,@(match (map search-path-specification->code native-search-paths= ) + (() '()) + (paths `((native-search-paths (list ,@paths))))) + ,@(match (map search-path-specification->code search-paths) + (() '()) + (paths `((search-paths (list ,@paths))))) + (home-page ,home-page) + (synopsis ,synopsis) + (description ,description) + (license ,(if (list? license) + `(list ,@(map license->code license)) + (license->code license))))))) --=20 2.25.1 From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 14 18:48:34 2020 Received: (at 40629) by debbugs.gnu.org; 14 Apr 2020 22:48:34 +0000 Received: from localhost ([127.0.0.1]:34950 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOUM6-0001mT-6G for submit@debbugs.gnu.org; Tue, 14 Apr 2020 18:48:34 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21394) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOUM4-0001mE-IO for 40629@debbugs.gnu.org; Tue, 14 Apr 2020 18:48:33 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1586904510; cv=none; d=zohomail.com; s=zohoarc; b=LQOHDLaRbZzQtvD+jxQJ6FEF/r0CXQLUORDUJduOy/X1ZRbhWQxF9+8ODnW71YqV0p618aXITwMtdqP0/lI6/p+XEfVbKk3IwPwSynwI5CneAIh9HhTbHneuAOj6EwGNRoe3V4yuD3dvOHdjZy9S/YT11s9IUDlY07AseIS/NwI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586904510; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=Hf17D1P/zJh/v97Rqxb0OOPPY9SW4p9VR1koLgPBSvM=; b=gjdLWSiIJ0zhWfTRHXXKO7hRmgMQvf4o/6SwzF4lmSFQH8aHnas0139k1vtZKiMUDneflO/b5lbQaTUQkl0b5OMCcMoik3X0yNfeAPkwoJ7MgLhcAZ++HPZdxi3FIafTRnjvSL1FN3wAsQdbIZbC0vr7VgFJrpuvFuBYQ3e3JMc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1586904510; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=Hf17D1P/zJh/v97Rqxb0OOPPY9SW4p9VR1koLgPBSvM=; b=fzxeEivBuV/m72HEHGHPQZLqc6lWDHUcs9AKV/iuYLrwKVMDP4hoMZjzZqkoHkE7 0zL7UTn15YpJjRkOhIwTdCCKyeC5CCCBiNloGJOq0OcA/jt1hRb96eI2dOJv9xaypgc 9L1zBF0dGg+G7WvQSJCsdOS22lSSCrLxQ5MMFalw= Received: from localhost (p54AD4D5F.dip0.t-ipconnect.de [84.173.77.95]) by mx.zohomail.com with SMTPS id 1586904509646669.15285440888; Tue, 14 Apr 2020 15:48:29 -0700 (PDT) From: Ricardo Wurmus To: 40629@debbugs.gnu.org Message-ID: <20200414224817.3850-3-rekado@elephly.net> Subject: [PATCH 8/9] import/utils: alist->package: Ignore known inputs. Date: Wed, 15 Apr 2020 00:48:16 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200414224817.3850-1-rekado@elephly.net> References: <20200414224817.3850-1-rekado@elephly.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 40629 Cc: Ricardo Wurmus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/import/utils.scm (alist->package): Accept optional list of known inputs, which are excluded from the specification lookup. * guix/import/print.scm (package->code)[package-lists->code]: Handle inputs which are just symbols. --- guix/import/print.scm | 2 ++ guix/import/utils.scm | 27 ++++++++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/guix/import/print.scm b/guix/import/print.scm index 08f3ec9c34..fd297798da 100644 --- a/guix/import/print.scm +++ b/guix/import/print.scm @@ -92,6 +92,8 @@ when evaluated." (define (package-lists->code lsts) (list 'quasiquote (map (match-lambda + ((? symbol? s) + (cons (symbol->string s) (list 'unquote s))) ((label pkg . out) (let ((mod (package-module-name pkg))) (cons* label diff --git a/guix/import/utils.scm b/guix/import/utils.scm index 94c8cb040b..5fb1322535 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -2,7 +2,7 @@ ;;; Copyright =C2=A9 2012, 2013, 2018, 2019, 2020 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2016 Jelle Licht ;;; Copyright =C2=A9 2016 David Craven -;;; Copyright =C2=A9 2017, 2019 Ricardo Wurmus +;;; Copyright =C2=A9 2017, 2019, 2020 Ricardo Wurmus ;;; Copyright =C2=A9 2018 Oleg Pykhalov ;;; Copyright =C2=A9 2019 Robert Vollmert ;;; @@ -310,7 +310,18 @@ the expected fields of an object." (uri (assoc-ref orig "uri")) (sha256 sha)))))) =20 -(define (alist->package meta) +(define* (alist->package meta #:optional (known-inputs '())) + "Return a package value generated from the alist META. If the list of +strings KNOWN-INPUTS is provided, do not treat the mentioned inputs as +specifications to look up and replace them with plain symbols instead." + (define (process-inputs which) + (let-values (((regular known) + (lset-diff+intersection + string=3D? + (vector->list (or (assoc-ref meta which) #())) + known-inputs))) + (append (specs->package-lists regular) + (map string->symbol known)))) (package (name (assoc-ref meta "name")) (version (assoc-ref meta "version")) @@ -318,15 +329,9 @@ the expected fields of an object." (build-system (lookup-build-system-by-name (string->symbol (assoc-ref meta "build-system")))) - (native-inputs - (specs->package-lists - (vector->list (or (assoc-ref meta "native-inputs") '#())))) - (inputs - (specs->package-lists - (vector->list (or (assoc-ref meta "inputs") '#())))) - (propagated-inputs - (specs->package-lists - (vector->list (or (assoc-ref meta "propagated-inputs") '#())))) + (native-inputs (process-inputs "native-inputs")) + (inputs (process-inputs "inputs")) + (propagated-inputs (process-inputs "propagated-inputs")) (home-page (assoc-ref meta "home-page")) (synopsis --=20 2.25.1 From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 14 18:48:38 2020 Received: (at 40629) by debbugs.gnu.org; 14 Apr 2020 22:48:38 +0000 Received: from localhost ([127.0.0.1]:34953 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOUMA-0001mm-Go for submit@debbugs.gnu.org; Tue, 14 Apr 2020 18:48:38 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21395) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOUM8-0001mb-If for 40629@debbugs.gnu.org; Tue, 14 Apr 2020 18:48:36 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1586904514; cv=none; d=zohomail.com; s=zohoarc; b=YaN4ee+IsfUw5Yo6/Po1sW6KjSLQMQZ0+GBvnyK1EtWXG0U7VLEWksxyAUQDIIOkAT22MvpmpGE7xHDv8t019mE3vWPHtttqIzePNlYZq3dV2UJOxD6ULZBGudp2AT4GtIgfNA3aZPbxO3VITNbN0UvHtrx5sDbH34qECw/168w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586904514; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=QB7S2q24feZbsxpzzRP5TS3cPxZpKLB/jZtMMy89mYM=; b=B94S+jk4mNWyIH8TBwk68DjD7ERTp30lWBrvF7djjhI0AOedtf1+qx89Upgi9vn/4Yjm/psFjh/rMgVMxSu1bHVytbLixoMLVBz1QJ9MvY3wK5TS9O9VjEiupVrnMwdvYTFy4ky1Vqjb6TXOR1PFArR2/rKFeaFyJCBEGo9/mqg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1586904514; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=QB7S2q24feZbsxpzzRP5TS3cPxZpKLB/jZtMMy89mYM=; b=DIc7KBi+cnFRA1GXlrbWJwoDWX9vAH8lOH3xV2o0LKvdlHSTFLie0ZdAPo7z2QB9 V5YiyzSmsyG0JtroAz5LwG/G1zRb7aPK8Y6YScVg1rJzU5OiEXEy7eCV/HygdkvQME+ k2nCd9lpcFBxU60zyn/9XbdZZSsuLMdZ/C00Mqn0= Received: from localhost (p54AD4D5F.dip0.t-ipconnect.de [84.173.77.95]) by mx.zohomail.com with SMTPS id 1586904513373259.79218082697287; Tue, 14 Apr 2020 15:48:33 -0700 (PDT) From: Ricardo Wurmus To: 40629@debbugs.gnu.org Message-ID: <20200414224817.3850-4-rekado@elephly.net> Subject: [PATCH 9/9] import/json: json->code: Handle files with more than one definition. Date: Wed, 15 Apr 2020 00:48:17 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200414224817.3850-1-rekado@elephly.net> References: <20200414224817.3850-1-rekado@elephly.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset=utf8 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 40629 Cc: Ricardo Wurmus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/import/json.scm (json->code): Convert JSON arrays to lists of packag= e definitions. (json->scheme-file): Write all expressions to the target file. --- guix/import/json.scm | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/guix/import/json.scm b/guix/import/json.scm index 8f8dbbd05d..de35984211 100644 --- a/guix/import/json.scm +++ b/guix/import/json.scm @@ -24,8 +24,11 @@ #:use-module (guix http-client) #:use-module (guix import utils) #:use-module (guix import print) + #:use-module (ice-9 match) #:use-module (ice-9 rdelim) + #:use-module (srfi srfi-1) #:use-module (srfi srfi-2) + #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) #:export (json-fetch json->code @@ -50,19 +53,41 @@ the query." result))) =20 (define (json->code file-name) - "Read FILE-NAME containing a JSON package definition and return an -S-expression, or return #F when the JSON is invalid." + "Read FILE-NAME containing one ore more JSON package definitions and ret= urn +a list of S-expressions, or return #F when the JSON is invalid." (catch 'json-invalid (lambda () (let ((json (json-string->scm (with-input-from-file file-name read-string)))) - (package->code (alist->package json)))) + (match json + (#(packages ...) + ;; To allow definitions to refer to one another, collect refere= nces + ;; to local definitions and tell alist->package to ignore them. + (second + (memq #:result + (fold + (lambda (pkg names+result) + (match names+result + ((#:names names #:result result) + (list #:names + (cons (assoc-ref pkg "name") names) + #:result + (append (list + (package->code (alist->package pkg = names)) + (string->symbol (assoc-ref pkg "nam= e"))) + result))))) + (list #:names '() + #:result '()) + packages)))) + (package + (list (package->code (alist->package json)) + (string->symbol (assoc-ref json "name"))))))) (const #f))) =20 (define (json->scheme-file file) "Convert the FILE containing a JSON package definition to a Scheme representation and return the new file name (or #F on error)." - (and-let* ((json (json->code file)) + (and-let* ((sexprs (json->code file)) (file* (let* ((tempdir (or (getenv "TMPDIR") "/tmp")) (template (string-append tempdir "/guix-XXXXXX"= )) (port (mkstemp! template))) @@ -74,5 +99,5 @@ representation and return the new file name (or #F on err= or)." (guix) ((guix licenses) #:prefix license:)) port) - (write json port))) + (for-each (cut write <> port) sexprs))) file*)) --=20 2.25.1 From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 14 18:59:16 2020 Received: (at 40629) by debbugs.gnu.org; 14 Apr 2020 22:59:16 +0000 Received: from localhost ([127.0.0.1]:34964 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOUWO-000222-Rj for submit@debbugs.gnu.org; Tue, 14 Apr 2020 18:59:16 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21350) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOUWN-00021u-AO for 40629@debbugs.gnu.org; Tue, 14 Apr 2020 18:59:11 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1586905148; cv=none; d=zohomail.com; s=zohoarc; b=KYvAdCw8oSnSxVm2lyM+AJ83tXANhlhihO/FOcGdRAEr8tZKElZkkx+84GZAImsuNm9jF2AuDFYVOf7RzyN8fMtd6rYeKwUr3o8RrHsg+LPs1oik49dNMDfUvznT/PhzfE+DnxKJynkJnZIad4KCa0JwX85n1dF02jTUQBRhTmo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586905148; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=Xthvuy7Jh//mvLeGD4LN+ErqRLjNiv3sLtTmqW8HbHE=; b=XcSadAtD9kb2VJ9cxd320qgNBz45OXaN3g82c2gHLwzaAUgIfjb5Pag4upIJzvhGZPR5FKtHXQgq6thFOvVJwhfgezQp5ZsJR6b5DN5L8sP1Q+UhQlzAGtCvhlway+lO/tNZ3TrkP5LxFPf8a9hiRnuNToQwc7rQSR+m9606cOo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1586905148; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:To:Cc:Message-ID:Subject:Date:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=Xthvuy7Jh//mvLeGD4LN+ErqRLjNiv3sLtTmqW8HbHE=; b=UOvuuJcc6dmGjGyzKgE1UqelK+B72LE9YOCvDQLySLt1k04YWuuVRWDq175sYOXw MlJa5jO1T5ODlWV1JQokTGZ0QRr+hlHmWvaL9eTfimhC9eC2ppNisdG3wTX1yz03CDu 29BwsF0/Df0QQvnahukBr4QjKD9Syl/m2Mxv0CRk= Received: from localhost (p54AD4D5F.dip0.t-ipconnect.de [84.173.77.95]) by mx.zohomail.com with SMTPS id 1586905147797662.6808580815199; Tue, 14 Apr 2020 15:59:07 -0700 (PDT) From: Ricardo Wurmus To: 40629@debbugs.gnu.org Message-ID: <20200414225903.10862-1-rekado@elephly.net> Subject: [PATCH v2 8/9] import/utils: alist->package: Ignore known inputs. Date: Wed, 15 Apr 2020 00:59:02 +0200 X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 40629 Cc: Ricardo Wurmus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/import/utils.scm (alist->package): Accept optional list of known inputs, which are excluded from the specification lookup. * guix/import/print.scm (package->code)[package-lists->code]: Handle inputs which are just symbols. --- guix/import/print.scm | 2 ++ guix/import/utils.scm | 27 ++++++++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/guix/import/print.scm b/guix/import/print.scm index 08f3ec9c34..471687c0ff 100644 --- a/guix/import/print.scm +++ b/guix/import/print.scm @@ -92,6 +92,8 @@ when evaluated." (define (package-lists->code lsts) (list 'quasiquote (map (match-lambda + ((? symbol? s) + (list (symbol->string s) (list 'unquote s))) ((label pkg . out) (let ((mod (package-module-name pkg))) (cons* label diff --git a/guix/import/utils.scm b/guix/import/utils.scm index 94c8cb040b..5fb1322535 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -2,7 +2,7 @@ ;;; Copyright =C2=A9 2012, 2013, 2018, 2019, 2020 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2016 Jelle Licht ;;; Copyright =C2=A9 2016 David Craven -;;; Copyright =C2=A9 2017, 2019 Ricardo Wurmus +;;; Copyright =C2=A9 2017, 2019, 2020 Ricardo Wurmus ;;; Copyright =C2=A9 2018 Oleg Pykhalov ;;; Copyright =C2=A9 2019 Robert Vollmert ;;; @@ -310,7 +310,18 @@ the expected fields of an object." (uri (assoc-ref orig "uri")) (sha256 sha)))))) =20 -(define (alist->package meta) +(define* (alist->package meta #:optional (known-inputs '())) + "Return a package value generated from the alist META. If the list of +strings KNOWN-INPUTS is provided, do not treat the mentioned inputs as +specifications to look up and replace them with plain symbols instead." + (define (process-inputs which) + (let-values (((regular known) + (lset-diff+intersection + string=3D? + (vector->list (or (assoc-ref meta which) #())) + known-inputs))) + (append (specs->package-lists regular) + (map string->symbol known)))) (package (name (assoc-ref meta "name")) (version (assoc-ref meta "version")) @@ -318,15 +329,9 @@ the expected fields of an object." (build-system (lookup-build-system-by-name (string->symbol (assoc-ref meta "build-system")))) - (native-inputs - (specs->package-lists - (vector->list (or (assoc-ref meta "native-inputs") '#())))) - (inputs - (specs->package-lists - (vector->list (or (assoc-ref meta "inputs") '#())))) - (propagated-inputs - (specs->package-lists - (vector->list (or (assoc-ref meta "propagated-inputs") '#())))) + (native-inputs (process-inputs "native-inputs")) + (inputs (process-inputs "inputs")) + (propagated-inputs (process-inputs "propagated-inputs")) (home-page (assoc-ref meta "home-page")) (synopsis --=20 2.25.1 From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 14 18:59:18 2020 Received: (at 40629) by debbugs.gnu.org; 14 Apr 2020 22:59:18 +0000 Received: from localhost ([127.0.0.1]:34967 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOUWU-00022M-HK for submit@debbugs.gnu.org; Tue, 14 Apr 2020 18:59:18 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21353) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOUWS-000226-7X for 40629@debbugs.gnu.org; Tue, 14 Apr 2020 18:59:16 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1586905153; cv=none; d=zohomail.com; s=zohoarc; b=LakB16ZUUthPOpnhLm3fml1mZaORqMyHJ8jpTZAB5k5PTfU3TX/5SPNndhtsuME5EWROegH3iyKDJ587JsQcey0v6JHvJRFcjh38oG7qOxxLSAwpme6XznYgXsPGXlC5aZyAlHRwRVVR+ujkuVtOa2zC69ROSAHD/yJ7moh0DO0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586905153; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=aYK6ll64b9PgLkoDr38p35JQJUGeF2wKQfc/BQEsnx0=; b=CIsrrijMtC+f9CxitGsb/iZgEL0UNBJCDK/aHYXSOraqT9h+VXFj2uuPwcOyuigE4+v9+cxZ2x624zaViCXuQNzn925W/Itk+swSNgPnNNcAoiQse2WBRthJ9ILWzvUg4gFCKrzmbrEY09T/LwKHLp9v0V/RuOOZ6U5X1gop5A0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1586905153; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=aYK6ll64b9PgLkoDr38p35JQJUGeF2wKQfc/BQEsnx0=; b=c3/GQaFMNSBtubDfsuUdZXWiELAb2jL5i6u8g/DPR38VZdXXz2Tti0PiTbH8Gdzq lglS6x3z077hqYjTBa5WBEjjsoM8YfuhiN6ln9wex/HSHh8MVfAz4Rhee3JCBvLkU2R E9bLE95brYxMUQNGm308NceIYF4XQ6DdoBqgHIxk= Received: from localhost (p54AD4D5F.dip0.t-ipconnect.de [84.173.77.95]) by mx.zohomail.com with SMTPS id 1586905151321454.3056656523403; Tue, 14 Apr 2020 15:59:11 -0700 (PDT) From: Ricardo Wurmus To: 40629@debbugs.gnu.org Message-ID: <20200414225903.10862-2-rekado@elephly.net> Subject: [PATCH v2 9/9] import/json: json->code: Handle files with more than one definition. Date: Wed, 15 Apr 2020 00:59:03 +0200 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200414225903.10862-1-rekado@elephly.net> References: <20200414225903.10862-1-rekado@elephly.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset=utf8 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 40629 Cc: Ricardo Wurmus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/import/json.scm (json->code): Convert JSON arrays to lists of packag= e definitions. (json->scheme-file): Write all expressions to the target file. --- guix/import/json.scm | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/guix/import/json.scm b/guix/import/json.scm index 8f8dbbd05d..0c98bb25b8 100644 --- a/guix/import/json.scm +++ b/guix/import/json.scm @@ -24,8 +24,11 @@ #:use-module (guix http-client) #:use-module (guix import utils) #:use-module (guix import print) + #:use-module (ice-9 match) #:use-module (ice-9 rdelim) + #:use-module (srfi srfi-1) #:use-module (srfi srfi-2) + #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) #:export (json-fetch json->code @@ -50,19 +53,41 @@ the query." result))) =20 (define (json->code file-name) - "Read FILE-NAME containing a JSON package definition and return an -S-expression, or return #F when the JSON is invalid." + "Read FILE-NAME containing one ore more JSON package definitions and ret= urn +a list of S-expressions, or return #F when the JSON is invalid." (catch 'json-invalid (lambda () (let ((json (json-string->scm (with-input-from-file file-name read-string)))) - (package->code (alist->package json)))) + (match json + (#(packages ...) + ;; To allow definitions to refer to one another, collect refere= nces + ;; to local definitions and tell alist->package to ignore them. + (second + (memq #:result + (fold + (lambda (pkg names+result) + (match names+result + ((#:names names #:result result) + (list #:names + (cons (assoc-ref pkg "name") names) + #:result + (append result + (list + (package->code (alist->package pkg = names)) + (string->symbol (assoc-ref pkg "nam= e")))))))) + (list #:names '() + #:result '()) + packages)))) + (package + (list (package->code (alist->package json)) + (string->symbol (assoc-ref json "name"))))))) (const #f))) =20 (define (json->scheme-file file) "Convert the FILE containing a JSON package definition to a Scheme representation and return the new file name (or #F on error)." - (and-let* ((json (json->code file)) + (and-let* ((sexprs (json->code file)) (file* (let* ((tempdir (or (getenv "TMPDIR") "/tmp")) (template (string-append tempdir "/guix-XXXXXX"= )) (port (mkstemp! template))) @@ -74,5 +99,5 @@ representation and return the new file name (or #F on err= or)." (guix) ((guix licenses) #:prefix license:)) port) - (write json port))) + (for-each (cut write <> port) sexprs))) file*)) --=20 2.25.1 From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 14 19:01:21 2020 Received: (at 40629) by debbugs.gnu.org; 14 Apr 2020 23:01:21 +0000 Received: from localhost ([127.0.0.1]:34972 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOUYS-00027H-VO for submit@debbugs.gnu.org; Tue, 14 Apr 2020 19:01:21 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21305) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOUYQ-000279-La for 40629@debbugs.gnu.org; Tue, 14 Apr 2020 19:01:19 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1586905275; cv=none; d=zohomail.com; s=zohoarc; b=Df4FT7We2xapigjV0q529NbQia4a9DbrqbZHdOL0oRK0vxnLlhm+yXzIwlRQv5KV8lS/OsNI5Kn5kvXM5dHBi+tx+tQZvThV+/2KG9oWhAPkSLNmT3OLdeEibquwOhEgutoxcNhRDxj5tL6j7lMJ83hSsa18saYbrjWw2rFiBuo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586905275; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=mR1N4uT9GYJa3mwlXdGkbvwO1mSNGQzRhul7fgwHS2o=; b=CozYtu3LojTfteiMIqQLuLyRRn//aWmct37xovEM7bYyGxLLgQXWurXpgEwhh8lk7oziyKdcD8FemVRmlHaJfkdtgNm+eEOhWqq2Dvc9mgxD/3WIAtnT1hmw3B/ei5SS/k1eWOcBmQ0aHOw+9+PLfYYYVUAWnmBZOyQjG8g7g8I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1586905275; s=zoho; d=elephly.net; i=rekado@elephly.net; h=References:From:To:Cc:Subject:In-reply-to:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=mR1N4uT9GYJa3mwlXdGkbvwO1mSNGQzRhul7fgwHS2o=; b=TOWU07tGV5HSKFomo5410xJZ0LeZFXUc7Ui7elyU6AfK+vaPQ5Z4xfvPT/Mv4rlk HhovVz/pG3ejaFX7SdYflJ7QXwljQi7AeWgOez7AWZITjEKT/RFG8Oqcw+G5BVBnarK +Ps2A1vEx8X9+I4KxHqafKq0lS3v8dCZnUdQMEBY= Received: from localhost (p54AD4D5F.dip0.t-ipconnect.de [84.173.77.95]) by mx.zohomail.com with SMTPS id 1586905274757182.0088398579037; Tue, 14 Apr 2020 16:01:14 -0700 (PDT) References: <20200414225903.10862-1-rekado@elephly.net> <20200414225903.10862-2-rekado@elephly.net> User-agent: mu4e 1.2.0; emacs 26.3 From: Ricardo Wurmus To: 40629@debbugs.gnu.org Subject: Re: [PATCH v2 9/9] import/json: json->code: Handle files with more than one definition. In-reply-to: <20200414225903.10862-2-rekado@elephly.net> X-URL: https://elephly.net X-PGP-Key: https://elephly.net/rekado.pubkey X-PGP-Fingerprint: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC Date: Wed, 15 Apr 2020 01:01:11 +0200 Message-ID: <87tv1ln03s.fsf@elephly.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 40629 Cc: Ricardo Wurmus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) With these last few changes it=E2=80=99s now possible to have multiple definitions in a JSON array: --8<---------------cut here---------------start------------->8--- [ { "name": "myhello", "version": "2.10", "source": "mirror://gnu/hello/hello-2.10.tar.gz", "build-system": "gnu", "home-page": "https://www.gnu.org/software/hello/", "synopsis": "Hello, GNU world: An example GNU package", "description": "GNU Hello prints a greeting.", "license": "GPL-3.0+", "native-inputs": ["gettext"] }, { "name": "hello2", "version": "2.10", "source": "mirror://gnu/hello/hello-2.10.tar.gz", "build-system": "gnu", "home-page": "https://www.gnu.org/software/hello/", "synopsis": "Hello, GNU world: An example GNU package", "description": "GNU Hello prints a greeting.", "license": "GPL-3.0+", "inputs": ["myhello"], "native-inputs": ["gettext"] } ] --8<---------------cut here---------------end--------------->8--- =E2=80=9Chello2=E2=80=9D has =E2=80=9Cmyhello=E2=80=9D as an input. When t= his file is passed to =E2=80=9Cguix install -f=E2=80=9D both packages will be built and =E2=80=9Chello2=E2=80= =9D will be installed into the profile as it is the last package in the list. -- Ricardo From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 15 14:26:58 2020 Received: (at 40629) by debbugs.gnu.org; 15 Apr 2020 18:26:58 +0000 Received: from localhost ([127.0.0.1]:37134 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOmkU-0002Jq-88 for submit@debbugs.gnu.org; Wed, 15 Apr 2020 14:26:58 -0400 Received: from mira.cbaines.net ([212.71.252.8]:55310) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOmkR-0002Jg-MD for 40629@debbugs.gnu.org; Wed, 15 Apr 2020 14:26:56 -0400 Received: from localhost (unknown [46.237.160.17]) by mira.cbaines.net (Postfix) with ESMTPSA id A08DB27BBE1; Wed, 15 Apr 2020 19:26:54 +0100 (BST) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id a7ead1b6; Wed, 15 Apr 2020 18:26:52 +0000 (UTC) References: <87y2qym5v8.fsf@elephly.net> User-agent: mu4e 1.2.0; emacs 26.3 From: Christopher Baines To: Ricardo Wurmus Subject: Re: [bug#40629] Build and install packages from JSON definitions In-reply-to: <87y2qym5v8.fsf@elephly.net> Date: Wed, 15 Apr 2020 19:26:52 +0100 Message-ID: <87v9m061w3.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 40629 Cc: 40629@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ricardo Wurmus writes: > did you know that we have JSON importer? Admittedly, it=E2=80=99s not ve= ry > useful because people don=E2=80=99t generally use JSON syntax to define G= uix > packages. Not even Guix lets you build and install packages from JSON > definitions, so what=E2=80=99s the point really? > > Well, fret not! This patch set adds support for JSON package > definitions to =E2=80=9Cguix package -f=E2=80=9D and =E2=80=9Cguix build = -f=E2=80=9D. You can now dump > this into a file =E2=80=9Chello.json=E2=80=9D: > > --8<---------------cut here---------------start------------->8--- > { > "name": "hello", > "version": "2.10", > "source": "mirror://gnu/hello/hello-2.10.tar.gz", > "build-system": "gnu", > "home-page": "https://www.gnu.org/software/hello/", > "synopsis": "Hello, GNU world: An example GNU package", > "description": "GNU Hello prints a greeting.", > "license": "GPL-3.0+", > "native-inputs": ["gettext"] > } > --8<---------------cut here---------------end--------------->8--- > > and then install the hello package with =E2=80=9Cguix package -f hello.js= on=E2=80=9D > without having to first run the JSON importer. > > Since the JSON importer doesn=E2=80=99t know how to work with more than o= ne > definition you can=E2=80=99t have more than one custom definition in your= JSON > file, but if there=E2=80=99s interest we can easily add support for this. > > (My patch set does not come with documentation changes for =E2=80=9Cguix > package=E2=80=9D or =E2=80=9Cguix build=E2=80=9D.) > > What do you think? I haven't played with the JSON importer, but this sounds cool. Did you have any ideas for using this in mind? Thanks, Chris --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAl6XUexfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE 9XfAIg//cuFKcc4vHONKLdJ/KgMs/YKZflhtkcwUHCHTlQYEw1M8yymReZIDgf49 SLKKsadvkA3JX/eR1PnO0rkxe4DIBA7xA2b08oqUA80AHEyhwE4Wbk8T16xyF9Uu +IyPuF3vtrYiTexqkBZicBRArWeJ21VbwnWpPbZpTxvWbsA3/+p9OouLVX0WJIc1 UQnTGJu822CPYGF9dVY4HvXpT1wW9si28pSKEZnDl9pfUVg6G6+wHU9HExZZZl7k C9/VsHPJtiwSFmMjw7AdxiVmqOzOB4CspxCp0Pwfb3xNpfadmeZcrv2mvAP88YtX GR0CPCG5T8/Xq9Ph+qR3uJiqX3sIgVwzEjf4iVl736Kl9tzbNpUo8tkVpXmUnop7 boTaN+piA2bAJnc5PQRIunXeR0mtao4cUMxQH2/O4dw1jIVqZ91zotQwLzJd+/un jAIh+djd3l1wiI+gXEse9qDhoMNCzIoobhgzPydOBJ273q5t6G18xJufDun43ZBL Uowd2Tiiwba6aebgUGxsR8twJn0kwWyxDWs3CEwXOYwWV0tSgjosYpEDpHZmSXhn 2IEfmPSKjRafH3/iTFpU1nWb0O+R/j3QDjs6tumhbPxQ39DNegDwMtE4eHwOhxeW jBWvqpRcXosMKZ558D8yUWegvFyHHlambSiVLcj7nXVLi7iLkHE= =U6LM -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 15 18:27:52 2020 Received: (at 40629) by debbugs.gnu.org; 15 Apr 2020 22:27:52 +0000 Received: from localhost ([127.0.0.1]:37242 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOqVc-0000Mk-7d for submit@debbugs.gnu.org; Wed, 15 Apr 2020 18:27:52 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21320) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jOqVX-0000MX-8D for 40629@debbugs.gnu.org; Wed, 15 Apr 2020 18:27:50 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1586989664; cv=none; d=zohomail.com; s=zohoarc; b=OXhlhZluyS6hzMb1VO2i0fFtUcxccM7Yp5sGIXgzoj23cPglE+t3eV9PLppgLeyK+/RU2BN4NpS+nh5Rj5w62WLIod/tzXG7mZ0vVD6NtldGEquJOb1Wg2UbXmojUwdpsuOC4wwnWRWuxZSCLZ+2lSiQ9OySfVvpH+Qua5zIeuM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586989664; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=abokxr4Elo9MHnXb53dwLXcCS+c9llqvmo66EhBtLQo=; b=hy53QKDB3ZYif0S0rYSrK/55oO+jpItPLL7/lU0HAEdAnyu2W3Hg/EmEncBvHB5ABE9AAnXZ0nq0ca/dveMMgkeM7svtveQ0y1oAS9XaSiR0QXWTZb6ZwsJnDtfhbxAumifiS5PqD05Bjs1iow6GCpqps5tpTiWaP/+H495amoo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1586989664; s=zoho; d=elephly.net; i=rekado@elephly.net; h=References:From:To:Cc:Subject:In-reply-to:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=abokxr4Elo9MHnXb53dwLXcCS+c9llqvmo66EhBtLQo=; b=Ym5j3MeJj/e7ZfGX/bRGHpz1vKsQ4xfiVsOT9HBlG0H+/sV8Gn6nPGVeXPJgwpcf hri+yf6JhFtrxfbKIKlm9JYe9/3tVubwwJKaLmpbaXMfihX4j8Wh3Jl5zX1tWiqbgHb eJfH1JCbdbIPIEajrqJKVczfTJ9NFLkqNb44b1Ho= Received: from localhost (p54AD4D8A.dip0.t-ipconnect.de [84.173.77.138]) by mx.zohomail.com with SMTPS id 1586989662638820.1198567250162; Wed, 15 Apr 2020 15:27:42 -0700 (PDT) References: <87y2qym5v8.fsf@elephly.net> <87v9m061w3.fsf@cbaines.net> User-agent: mu4e 1.2.0; emacs 26.3 From: Ricardo Wurmus To: Christopher Baines Subject: Re: [bug#40629] Build and install packages from JSON definitions In-reply-to: <87v9m061w3.fsf@cbaines.net> X-URL: https://elephly.net X-PGP-Key: https://elephly.net/rekado.pubkey X-PGP-Fingerprint: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC Date: Thu, 16 Apr 2020 00:27:39 +0200 Message-ID: <87lfmwmlk4.fsf@elephly.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 40629 Cc: 40629@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Christopher Baines writes: > Ricardo Wurmus writes: > >> did you know that we have JSON importer? Admittedly, it=E2=80=99s not v= ery >> useful because people don=E2=80=99t generally use JSON syntax to define = Guix >> packages. Not even Guix lets you build and install packages from JSON >> definitions, so what=E2=80=99s the point really? >> >> Well, fret not! This patch set adds support for JSON package >> definitions to =E2=80=9Cguix package -f=E2=80=9D and =E2=80=9Cguix build= -f=E2=80=9D. You can now dump >> this into a file =E2=80=9Chello.json=E2=80=9D: >> >> --8<---------------cut here---------------start------------->8--- >> { >> "name": "hello", >> "version": "2.10", >> "source": "mirror://gnu/hello/hello-2.10.tar.gz", >> "build-system": "gnu", >> "home-page": "https://www.gnu.org/software/hello/", >> "synopsis": "Hello, GNU world: An example GNU package", >> "description": "GNU Hello prints a greeting.", >> "license": "GPL-3.0+", >> "native-inputs": ["gettext"] >> } >> --8<---------------cut here---------------end--------------->8--- >> >> and then install the hello package with =E2=80=9Cguix package -f hello.j= son=E2=80=9D >> without having to first run the JSON importer. >> >> Since the JSON importer doesn=E2=80=99t know how to work with more than = one >> definition you can=E2=80=99t have more than one custom definition in you= r JSON >> file, but if there=E2=80=99s interest we can easily add support for this. >> >> (My patch set does not come with documentation changes for =E2=80=9Cguix >> package=E2=80=9D or =E2=80=9Cguix build=E2=80=9D.) >> >> What do you think? > > I haven't played with the JSON importer, but this sounds cool. Did you > have any ideas for using this in mind? When I added the JSON importer long ago I also had a commit to extend =E2=80=9Cguix build=E2=80=9D to install packages from JSON descriptions, bu= t that never actually made it into the repository. Even then I didn=E2=80=99t have a grand plan; I just wanted to be able to t= ell the Scheme-averse that they could use JSON instead, e.g. for environment definitions or simple custom packages. It can be a sneaky way to get people to use Guix even though they are initially uncomfortable with Scheme. -- Ricardo From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 16 17:44:37 2020 Received: (at 40629-done) by debbugs.gnu.org; 16 Apr 2020 21:44:37 +0000 Received: from localhost ([127.0.0.1]:39493 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPCJJ-0001f5-Fl for submit@debbugs.gnu.org; Thu, 16 Apr 2020 17:44:37 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21320) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPCJI-0001ex-BW for 40629-done@debbugs.gnu.org; Thu, 16 Apr 2020 17:44:36 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1587073475; cv=none; d=zohomail.com; s=zohoarc; b=k5m8SkqKJcpVt1cwRQ1YF1eOCVaclmPoKRe46DEZhmGnRmXA9pwfACfrXKNGQt6Hw/C1vWnNIDJ1DzzSjT7gpxvhyTVultvOLXePaX80TbOIIGviwy6A1Rl60yC9VlhVb4uQ7e0/bkkusudk+v/qClueH0vcbtqpBRQ/JrJuoOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587073475; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=4bCLVUyu1ovNN0mrcuUQdY+tbT46H0C4kZOy9LcObHg=; b=UHfiu6I1mhU3ol+/1ClwjfuqBwy/9EuBEBJiM/bwYmATQqzNP2YkmYVaqilm7+07sTVwO/X4QAaCvEuoTHH8k5yN8gFGqJlfHyKb9+kY12g8rc5+/syASBfoDlpJLs4VcNIis34VMeCx1d1VBFA95zwXNguqfaBBbk/M7MQ6WW4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1587073475; s=zoho; d=elephly.net; i=rekado@elephly.net; h=References:From:To:Subject:Message-ID:In-reply-to:Date:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=4bCLVUyu1ovNN0mrcuUQdY+tbT46H0C4kZOy9LcObHg=; b=LZYasFbOvmPJTRtExQ/Ly0E4oBFctQSCXecN1qhuB/DpxGsang3jFUDBK5iRwHo/ CZj+kz1cruCEixoAO3sIvz7mqaHmB8/qBdBryAa3Bqt8TBAxNKJPrALUO3ycUwZsXBw 0rLF4awiQHzXikuKuDLlftsZNJqjDqTaYJybsgWE= Received: from localhost (p54AD4D27.dip0.t-ipconnect.de [84.173.77.39]) by mx.zohomail.com with SMTPS id 1587073472420742.2015191727448; Thu, 16 Apr 2020 14:44:32 -0700 (PDT) References: <87y2qym5v8.fsf@elephly.net> <87v9m061w3.fsf@cbaines.net> <87lfmwmlk4.fsf@elephly.net> User-agent: mu4e 1.2.0; emacs 26.3 From: Ricardo Wurmus To: 40629-done@debbugs.gnu.org Subject: Re: [bug#40629] Build and install packages from JSON definitions Message-ID: <87blnrm7gm.fsf@elephly.net> In-reply-to: <87lfmwmlk4.fsf@elephly.net> X-URL: https://elephly.net X-PGP-Key: https://elephly.net/rekado.pubkey X-PGP-Fingerprint: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC Date: Thu, 16 Apr 2020 23:44:29 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 40629-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) I=E2=80=99ve pushed this to the master branch with documentation and a few = minor changes with commit c9f321e52a. -- Ricardo From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 16 17:45:52 2020 Received: (at 40629) by debbugs.gnu.org; 16 Apr 2020 21:45:52 +0000 Received: from localhost ([127.0.0.1]:39502 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPCKV-0001i8-RV for submit@debbugs.gnu.org; Thu, 16 Apr 2020 17:45:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54486) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPCKT-0001hs-SG for 40629@debbugs.gnu.org; Thu, 16 Apr 2020 17:45:50 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:41852) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jPCKM-0002nV-OO; Thu, 16 Apr 2020 17:45:44 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=42810 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jPCKM-0008Qh-A2; Thu, 16 Apr 2020 17:45:42 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Ricardo Wurmus Subject: Re: [bug#40629] [PATCH 4/5] scripts/build: options->things-to-build: Handle .json files. References: <20200414171959.3428-1-rekado@elephly.net> <20200414171959.3428-4-rekado@elephly.net> Date: Thu, 16 Apr 2020 23:45:39 +0200 In-Reply-To: <20200414171959.3428-4-rekado@elephly.net> (Ricardo Wurmus's message of "Tue, 14 Apr 2020 19:19:58 +0200") Message-ID: <87y2qvdrzw.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -1.5 (-) X-Debbugs-Envelope-To: 40629 Cc: 40629@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.5 (--) Hello! Ricardo Wurmus skribis: > + (let ((file (or (and (string-suffix? ".json" file) > + (json->scheme-file file)) > + file))) > + (ensure-list (load* file (make-user-module '()))))) It would be nice if we could avoid writing to a file and then reading it back, perhaps by having a variant of =E2=80=98load*=E2=80=99 that takes an = sexp instead of a file name. (That could also allow us to improve error reporting because we could attach source properties to the sexp that match the original JSON file.) Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 16 17:50:14 2020 Received: (at 40629) by debbugs.gnu.org; 16 Apr 2020 21:50:14 +0000 Received: from localhost ([127.0.0.1]:39510 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPCOk-0001p8-I3 for submit@debbugs.gnu.org; Thu, 16 Apr 2020 17:50:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54902) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPCOh-0001on-P4 for 40629@debbugs.gnu.org; Thu, 16 Apr 2020 17:50:12 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:41884) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jPCOc-0004uK-I7; Thu, 16 Apr 2020 17:50:06 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=42812 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jPCOb-0000CY-Q0; Thu, 16 Apr 2020 17:50:06 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Ricardo Wurmus Subject: Re: [bug#40629] Build and install packages from JSON definitions References: <87y2qym5v8.fsf@elephly.net> Date: Thu, 16 Apr 2020 23:50:04 +0200 In-Reply-To: <87y2qym5v8.fsf@elephly.net> (Ricardo Wurmus's message of "Tue, 14 Apr 2020 17:44:31 +0200") Message-ID: <87o8rrdrsj.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -1.5 (-) X-Debbugs-Envelope-To: 40629 Cc: 40629@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.5 (--) Hey! Ricardo Wurmus skribis: > did you know that we have JSON importer? Admittedly, it=E2=80=99s not ve= ry > useful because people don=E2=80=99t generally use JSON syntax to define G= uix > packages. Not even Guix lets you build and install packages from JSON > definitions, so what=E2=80=99s the point really? > > Well, fret not! This patch set adds support for JSON package > definitions to =E2=80=9Cguix package -f=E2=80=9D and =E2=80=9Cguix build = -f=E2=80=9D. You can now dump > this into a file =E2=80=9Chello.json=E2=80=9D: > > { > "name": "hello", > "version": "2.10", > "source": "mirror://gnu/hello/hello-2.10.tar.gz", > "build-system": "gnu", > "home-page": "https://www.gnu.org/software/hello/", > "synopsis": "Hello, GNU world: An example GNU package", > "description": "GNU Hello prints a greeting.", > "license": "GPL-3.0+", > "native-inputs": ["gettext"] > } > > and then install the hello package with =E2=80=9Cguix package -f hello.js= on=E2=80=9D > without having to first run the JSON importer. I think that=E2=80=99s pretty cool! In a way, it also looks like a special case of the import-on-the-fly use case we discussed. Namely, if you could write: guix build json:./foo.json guix install pypi:itsdangerous =E2=80=A6 and have the relevant importer automatically invoked, that=E2=80=99d be swe= et. But=E2=80=A6 that=E2=80=99s somewhat ambitious and shouldn=E2=80=99t block = this improvement! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 16 17:53:31 2020 Received: (at 40629) by debbugs.gnu.org; 16 Apr 2020 21:53:31 +0000 Received: from localhost ([127.0.0.1]:39514 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPCRv-0001tY-2A for submit@debbugs.gnu.org; Thu, 16 Apr 2020 17:53:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55141) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPCRs-0001tL-TM for 40629@debbugs.gnu.org; Thu, 16 Apr 2020 17:53:29 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:41913) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jPCRn-0006lz-HD; Thu, 16 Apr 2020 17:53:23 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=42814 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jPCRm-0000RK-IO; Thu, 16 Apr 2020 17:53:23 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Ricardo Wurmus Subject: Re: [bug#40629] [PATCH 4/5] scripts/build: options->things-to-build: Handle .json files. References: <20200414171959.3428-1-rekado@elephly.net> <20200414171959.3428-4-rekado@elephly.net> Date: Thu, 16 Apr 2020 23:53:21 +0200 In-Reply-To: <20200414171959.3428-4-rekado@elephly.net> (Ricardo Wurmus's message of "Tue, 14 Apr 2020 19:19:58 +0200") Message-ID: <87k12fdrn2.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -1.5 (-) X-Debbugs-Envelope-To: 40629 Cc: 40629@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.5 (--) Ricardo Wurmus skribis: > + (let ((file (or (and (string-suffix? ".json" file) > + (json->scheme-file file)) > + file))) > + (ensure-list (load* file (make-user-module '()))))) Actually, perhaps we could have a file handler alist, like: `((".json" ,load-json) (_ ,(cute load* <> (make-user-module '())))) That could be shared with (guix scripts package), and =E2=80=98load-json=E2= =80=99 could do something that avoids going through a file. Late feedback, nightly thoughts. :-) Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 17 01:32:28 2020 Received: (at 40629) by debbugs.gnu.org; 17 Apr 2020 05:32:28 +0000 Received: from localhost ([127.0.0.1]:39821 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPJc4-0002Z6-3r for submit@debbugs.gnu.org; Fri, 17 Apr 2020 01:32:28 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40934) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPJc2-0002Yu-ID for 40629@debbugs.gnu.org; Fri, 17 Apr 2020 01:32:27 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:45958) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jPJbx-0002Jo-7D; Fri, 17 Apr 2020 01:32:21 -0400 Received: from [2001:980:1b4f:1:42d2:832d:bb59:862] (port=54072 helo=dundal.peder.onsbrabantnet.nl) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jPJbw-0007vl-K6; Fri, 17 Apr 2020 01:32:21 -0400 From: Jan Nieuwenhuizen To: Ricardo Wurmus Subject: Re: [bug#40629] [PATCH v2 9/9] import/json: json->code: Handle files with more than one definition. Organization: AvatarAcademy.nl References: <20200414225903.10862-1-rekado@elephly.net> <20200414225903.10862-2-rekado@elephly.net> <87tv1ln03s.fsf@elephly.net> X-Url: http://AvatarAcademy.nl Date: Fri, 17 Apr 2020 07:32:17 +0200 In-Reply-To: <87tv1ln03s.fsf@elephly.net> (Ricardo Wurmus's message of "Wed, 15 Apr 2020 01:01:11 +0200") Message-ID: <87tv1ivfry.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -1.5 (-) X-Debbugs-Envelope-To: 40629 Cc: 40629@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.5 (--) Ricardo Wurmus writes: > With these last few changes it=E2=80=99s now possible to have multiple > definitions in a JSON array: > > [ > { > "name": "myhello", > "version": "2.10", > "source": "mirror://gnu/hello/hello-2.10.tar.gz", > "build-system": "gnu", > "home-page": "https://www.gnu.org/software/hello/", > "synopsis": "Hello, GNU world: An example GNU package", > "description": "GNU Hello prints a greeting.", > "license": "GPL-3.0+", > "native-inputs": ["gettext"] > }, > { > "name": "hello2", > "version": "2.10", > "source": "mirror://gnu/hello/hello-2.10.tar.gz", > "build-system": "gnu", > "home-page": "https://www.gnu.org/software/hello/", > "synopsis": "Hello, GNU world: An example GNU package", > "description": "GNU Hello prints a greeting.", > "license": "GPL-3.0+", > "inputs": ["myhello"], > "native-inputs": ["gettext"] > } > ] > > =E2=80=9Chello2=E2=80=9D has =E2=80=9Cmyhello=E2=80=9D as an input. When= this file is passed to =E2=80=9Cguix > install -f=E2=80=9D both packages will be built and =E2=80=9Chello2=E2=80= =9D will be installed > into the profile as it is the last package in the list. Great! I am imagining this as an s-expression, maybe something like --8<---------------cut here---------------start------------->8--- (define-package (alist->package '((name "hello") (version "2.10") (build-system "gnu") (home-page "https://www.gnu.org/software/hello/") (synopsis "Hello, GNU world: An example GNU package") (description "GNU Hello prints a greeting.") (license "GPL-3.0+") (native-inputs "gettext")))) --8<---------------cut here---------------end--------------->8--- We may need some dots, or (native-inputs #("gettext")) if we are using json->scm in the process; just dreaming out loud here. Greetings, janneke --=20 Jan Nieuwenhuizen | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar=C2=AE http://AvatarAcademy.com From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 17 04:25:22 2020 Received: (at 40629) by debbugs.gnu.org; 17 Apr 2020 08:25:23 +0000 Received: from localhost ([127.0.0.1]:39907 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPMJO-0006rq-E0 for submit@debbugs.gnu.org; Fri, 17 Apr 2020 04:25:22 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21318) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPMJN-0006rh-7X for 40629@debbugs.gnu.org; Fri, 17 Apr 2020 04:25:21 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1587111916; cv=none; d=zohomail.com; s=zohoarc; b=Mys5OOu4It9l3RBY1oDiE5lKl3Xje0hM7qkDeGckSEyUmm74bAWjNKcO6CxKd5jUTSyrlq0ynJ3qV5x5H/hQxEHnKv+VnPI8o14Gf0QNkeK9Q8zc9QhJfOa5a4BhKZg2y4+lYzZCJlnPnrvM6xch+g/vWDpt9jsZbx7EXkCItww= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587111916; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=y/MCxr2T8ijGpYPlTWvjEiBb1IgwOzeWts+TQGRDMEo=; b=fUIFflWRS7wZWdOjit07kHqlzybSKrv2O5slgMLrWYNTUtsqFdtYAfK5xfSlz5ZnPdqySKn+fGFX3zAKE8ZfYhk4X+1ICN6LqTg/f0lmsKFyERwVJuaNxbGiqVd9YhgPjTto76Jki24l2R0Nx0l4YQFrurpWZDeBJQrb+TmFk58= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1587111916; s=zoho; d=elephly.net; i=rekado@elephly.net; h=References:From:To:Cc:Subject:In-reply-to:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=y/MCxr2T8ijGpYPlTWvjEiBb1IgwOzeWts+TQGRDMEo=; b=S+FLFfTeY8wv+yd6tNXjECrsOXbeyz0oUQN9+QQ3+kGxklNX+j6qrvf4MeBZjaLc JGjF3LZbUFzasJn8clIY70YFGy8gywNIUf5+4hbnHQhWjns4NoEsFdbl8BIfEeZbJbM i4WubfnrGIokqg0mKLY0nhIhHj6FqGti7Ec1z64U= Received: from localhost (p54AD4DE5.dip0.t-ipconnect.de [84.173.77.229]) by mx.zohomail.com with SMTPS id 1587111914717884.1470247760052; Fri, 17 Apr 2020 01:25:14 -0700 (PDT) References: <87y2qym5v8.fsf@elephly.net> <87o8rrdrsj.fsf@gnu.org> User-agent: mu4e 1.2.0; emacs 26.3 From: Ricardo Wurmus To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: [bug#40629] Build and install packages from JSON definitions In-reply-to: <87o8rrdrsj.fsf@gnu.org> X-URL: https://elephly.net X-PGP-Key: https://elephly.net/rekado.pubkey X-PGP-Fingerprint: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC Date: Fri, 17 Apr 2020 10:25:11 +0200 Message-ID: <875zdymsd4.fsf@elephly.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 40629 Cc: 40629@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Ludovic Court=C3=A8s writes: >> Well, fret not! This patch set adds support for JSON package >> definitions to =E2=80=9Cguix package -f=E2=80=9D and =E2=80=9Cguix build= -f=E2=80=9D. You can now dump >> this into a file =E2=80=9Chello.json=E2=80=9D: >> >> { >> "name": "hello", >> "version": "2.10", >> "source": "mirror://gnu/hello/hello-2.10.tar.gz", >> "build-system": "gnu", >> "home-page": "https://www.gnu.org/software/hello/", >> "synopsis": "Hello, GNU world: An example GNU package", >> "description": "GNU Hello prints a greeting.", >> "license": "GPL-3.0+", >> "native-inputs": ["gettext"] >> } >> >> and then install the hello package with =E2=80=9Cguix package -f hello.j= son=E2=80=9D >> without having to first run the JSON importer. > > I think that=E2=80=99s pretty cool! > > In a way, it also looks like a special case of the import-on-the-fly use > case we discussed. Namely, if you could write: > > guix build json:./foo.json > guix install pypi:itsdangerous > =E2=80=A6 > > and have the relevant importer automatically invoked, that=E2=80=99d be s= weet. Yes, that was the original goal that motivated writing alist->package (instead of making this specific to JSON). I remember vaguely that I ran into an obstacle back then. I think this may have predated the existence of recursive importers, which meant that I couldn=E2=80=99t gener= ate package objects for packages that had as yet unpackaged inputs. Perhaps this is no longer a problem and we could take a stab at these on-the-fly imports. Infinite packages! :) -- Ricardo From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 17 13:45:13 2020 Received: (at 40629) by debbugs.gnu.org; 17 Apr 2020 17:45:13 +0000 Received: from localhost ([127.0.0.1]:41639 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPV3B-0008OP-Hb for submit@debbugs.gnu.org; Fri, 17 Apr 2020 13:45:13 -0400 Received: from mira.cbaines.net ([212.71.252.8]:58052) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPV3A-0008OI-IX for 40629@debbugs.gnu.org; Fri, 17 Apr 2020 13:45:13 -0400 Received: from localhost (unknown [46.237.173.52]) by mira.cbaines.net (Postfix) with ESMTPSA id 80F8A27BBE1; Fri, 17 Apr 2020 18:45:11 +0100 (BST) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id f66918b9; Fri, 17 Apr 2020 17:45:09 +0000 (UTC) References: <87y2qym5v8.fsf@elephly.net> <87v9m061w3.fsf@cbaines.net> <87lfmwmlk4.fsf@elephly.net> User-agent: mu4e 1.2.0; emacs 26.3 From: Christopher Baines To: Ricardo Wurmus Subject: Re: [bug#40629] Build and install packages from JSON definitions In-reply-to: <87lfmwmlk4.fsf@elephly.net> Date: Fri, 17 Apr 2020 18:45:06 +0100 Message-ID: <87k12e57ml.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 40629 Cc: 40629@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ricardo Wurmus writes: > Christopher Baines writes: > >> Ricardo Wurmus writes: >> >>> did you know that we have JSON importer? Admittedly, it=E2=80=99s not = very >>> useful because people don=E2=80=99t generally use JSON syntax to define= Guix >>> packages. Not even Guix lets you build and install packages from JSON >>> definitions, so what=E2=80=99s the point really? >>> >>> Well, fret not! This patch set adds support for JSON package >>> definitions to =E2=80=9Cguix package -f=E2=80=9D and =E2=80=9Cguix buil= d -f=E2=80=9D. You can now dump >>> this into a file =E2=80=9Chello.json=E2=80=9D: >>> >>> --8<---------------cut here---------------start------------->8--- >>> { >>> "name": "hello", >>> "version": "2.10", >>> "source": "mirror://gnu/hello/hello-2.10.tar.gz", >>> "build-system": "gnu", >>> "home-page": "https://www.gnu.org/software/hello/", >>> "synopsis": "Hello, GNU world: An example GNU package", >>> "description": "GNU Hello prints a greeting.", >>> "license": "GPL-3.0+", >>> "native-inputs": ["gettext"] >>> } >>> --8<---------------cut here---------------end--------------->8--- >>> >>> and then install the hello package with =E2=80=9Cguix package -f hello.= json=E2=80=9D >>> without having to first run the JSON importer. >>> >>> Since the JSON importer doesn=E2=80=99t know how to work with more than= one >>> definition you can=E2=80=99t have more than one custom definition in yo= ur JSON >>> file, but if there=E2=80=99s interest we can easily add support for thi= s. >>> >>> (My patch set does not come with documentation changes for =E2=80=9Cguix >>> package=E2=80=9D or =E2=80=9Cguix build=E2=80=9D.) >>> >>> What do you think? >> >> I haven't played with the JSON importer, but this sounds cool. Did you >> have any ideas for using this in mind? > > When I added the JSON importer long ago I also had a commit to extend > =E2=80=9Cguix build=E2=80=9D to install packages from JSON descriptions, = but that never > actually made it into the repository. > > Even then I didn=E2=80=99t have a grand plan; I just wanted to be able to= tell > the Scheme-averse that they could use JSON instead, e.g. for environment > definitions or simple custom packages. > > It can be a sneaky way to get people to use Guix even though they are > initially uncomfortable with Scheme. Cool, I think it's nice to be able to use a more "data" format if that's useful. I'm sure there will be some useful applications eventually! Thanks, Chris --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAl6Z6yJfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE 9XcHCRAAk1q3kSKjimZEUQNL/HOC+1r7AAmCxwa0C46zZFhZ7qUGei6oua7Er1QW c1RwyP1SsyKVs8IzdbHTEBwiT/OBWDckJkDTnT1twaG6fy8rQBAcng1UhyRmmVtS zRYIIRHRdID2mo+jhkD/hBEa99aCT8FrZRnecsAjsO/4VkrfANnUdgt5lTQl/RhF +pimYNNZeB0uxe8D0GxeoFjdOXNE4iaQsPotDssctIKt+qWV6nBlUpS6A28eUxM4 MeP9RSg3g35AcR2D/DMFwV0GTgL8HJ3LYn1twB8DLoqQ8K1qzL+2EYkq7q6Ooy/W PjYP2k9DEblnmppv8N6B9acwoF/CUYBlX7paWfNKJhTaMDun03+nE5tk7ryRsa1l jgCt9XVIeXz1JuA26nXSLGkpAr1UeCc6jBH4W9Ect3A8TBvNHXnH73zhh63cdUNG va3ivErUfOX6CQxXNdvlneeF1DHw8yYgGaXNbOruFXHTRx3RvK5c9dT9BusjviW0 gsXs+nxHFysfVzfhxjMV56y8RFpWbS3WZT6A+a1jP9JkMrOZCSlWZOCKhn8hJNXr aPV331Lksmk20b5j6cx64DFki7JKUaXNRfEWufNnhcyJmk+vMht2P7xO63+aM0Fj Zu3KZhkAZrA4CF9w6wFQIqxkRp8VdoYqMYf85xJ8lgTLfejPGc0= =XSN/ -----END PGP SIGNATURE----- --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 18 16:24:05 2020 Received: (at 40629) by debbugs.gnu.org; 18 Apr 2020 20:24:06 +0000 Received: from localhost ([127.0.0.1]:43659 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPu0T-0003LF-Ln for submit@debbugs.gnu.org; Sat, 18 Apr 2020 16:24:05 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21369) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jPu0R-0003L7-RG for 40629@debbugs.gnu.org; Sat, 18 Apr 2020 16:24:04 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1587241437; cv=none; d=zohomail.com; s=zohoarc; b=XnSRvubOJRNoUPtbEQ8XhLQFIUhwFKJkE9tPKKjv/UQnV/94vhsSnQYck5S74xRx+Z+aa4o85uOxF1wHwDO3WXN5m3mzjPhR29X11VGnlWJnfS9cQaDkNKBsOhmv87QXM8yOXXkWgQNM02Z4fiVEbg0yF929KQOcvokiEK3uQbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587241437; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=0ZD9Xab39Uvl+6zNO85xlT7urx9E12FhEl/x7gowZcA=; b=l+iBug6SppiXUObza+FT74hl5N3zGCc7icwZEgXLUuqYDFfM1U+ODsoSRAd6YZuRBh5nJi/jvLrQVay7es6X2BJnl9ns/DsZ92jYMZgfhZd6pR2GNgYx6bZutu7BCU47ZOmC/pLvVjSNhUeWB8K+F50+41Ql++SBmre3Qz1BKUA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1587241437; s=zoho; d=elephly.net; i=rekado@elephly.net; h=References:From:To:Cc:Subject:In-reply-to:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=0ZD9Xab39Uvl+6zNO85xlT7urx9E12FhEl/x7gowZcA=; b=KfTkLnzYvnZHe3nPMRtxKG1hsEKfdhJOseUI4ZAztNQcbLaT/3MGVdGqGDgu/Grm QA9hTOe/spbdVZTb7QMmARb3J48ce8cRmAMt7K3T2/HtPoBp77/PRjsg2++d/al4VcO JereU7sLRPugvfwPtOPEt7f+EE13RhHfymiv19jw= Received: from localhost (p54AD4781.dip0.t-ipconnect.de [84.173.71.129]) by mx.zohomail.com with SMTPS id 1587241435739877.303720285942; Sat, 18 Apr 2020 13:23:55 -0700 (PDT) References: <20200414225903.10862-1-rekado@elephly.net> <20200414225903.10862-2-rekado@elephly.net> <87tv1ln03s.fsf@elephly.net> <87tv1ivfry.fsf@gnu.org> User-agent: mu4e 1.2.0; emacs 26.3 From: Ricardo Wurmus To: Jan Nieuwenhuizen Subject: Re: [bug#40629] [PATCH v2 9/9] import/json: json->code: Handle files with more than one definition. In-reply-to: <87tv1ivfry.fsf@gnu.org> X-URL: https://elephly.net X-PGP-Key: https://elephly.net/rekado.pubkey X-PGP-Fingerprint: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC Date: Sat, 18 Apr 2020 22:23:52 +0200 Message-ID: <87y2qslezr.fsf@elephly.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-Spam-Score: -0.8 (/) X-Debbugs-Envelope-To: 40629 Cc: 40629@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.8 (-) Jan Nieuwenhuizen writes: > Ricardo Wurmus writes: > >> With these last few changes it=E2=80=99s now possible to have multiple >> definitions in a JSON array: >> >> [ >> { >> "name": "myhello", >> "version": "2.10", >> "source": "mirror://gnu/hello/hello-2.10.tar.gz", >> "build-system": "gnu", >> "home-page": "https://www.gnu.org/software/hello/", >> "synopsis": "Hello, GNU world: An example GNU package", >> "description": "GNU Hello prints a greeting.", >> "license": "GPL-3.0+", >> "native-inputs": ["gettext"] >> }, >> { >> "name": "hello2", >> "version": "2.10", >> "source": "mirror://gnu/hello/hello-2.10.tar.gz", >> "build-system": "gnu", >> "home-page": "https://www.gnu.org/software/hello/", >> "synopsis": "Hello, GNU world: An example GNU package", >> "description": "GNU Hello prints a greeting.", >> "license": "GPL-3.0+", >> "inputs": ["myhello"], >> "native-inputs": ["gettext"] >> } >> ] >> >> =E2=80=9Chello2=E2=80=9D has =E2=80=9Cmyhello=E2=80=9D as an input. Whe= n this file is passed to =E2=80=9Cguix >> install -f=E2=80=9D both packages will be built and =E2=80=9Chello2=E2= =80=9D will be installed >> into the profile as it is the last package in the list. > > Great! I am imagining this as an s-expression, maybe something like > > --8<---------------cut here---------------start------------->8--- > (define-package > (alist->package > '((name "hello") > (version "2.10") > (build-system "gnu") > (home-page "https://www.gnu.org/software/hello/") > (synopsis "Hello, GNU world: An example GNU package") > (description "GNU Hello prints a greeting.") > (license "GPL-3.0+") > (native-inputs "gettext")))) > --8<---------------cut here---------------end--------------->8--- > > We may need some dots, or (native-inputs #("gettext")) if we are using > json->scm in the process; just dreaming out loud here. Yes, the S-expr equivalent would be: (define-public my-hello (alist->package '(("name" . "hello") ("version" . "2.10") ("build-system" . "gnu") ("source" . "http://example.com") ("home-page" . "https://www.gnu.org/software/hello/") ("synopsis" . "Hello, GNU world: An example GNU package") ("description" . "GNU Hello prints a greeting."") ("native-inputs" . #("gettext")) ("license" . "GPL-3.0+")))) alist->package expects an alist of the kind that json->scm would return; vectors are used for lists to distinguish them from nested alists (which would be used for the =E2=80=9Carguments=E2=80=9D field). --=20 Ricardo From unknown Sat Sep 13 11:13:27 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 17 May 2020 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator