From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:49778) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jPu1P-0001pe-18 for guix-patches@gnu.org; Sat, 18 Apr 2020 16:25:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jPu1O-00041a-HK for guix-patches@gnu.org; Sat, 18 Apr 2020 16:25:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:60346) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jPu1O-00041I-4G for guix-patches@gnu.org; Sat, 18 Apr 2020 16:25:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jPu1O-0003MY-0G for guix-patches@gnu.org; Sat, 18 Apr 2020 16:25:02 -0400 Subject: [bug#40629] [PATCH v2 9/9] import/json: json->code: Handle files with more than one definition. Resent-Message-ID: References: <20200414225903.10862-1-rekado@elephly.net> <20200414225903.10862-2-rekado@elephly.net> <87tv1ln03s.fsf@elephly.net> <87tv1ivfry.fsf@gnu.org> From: Ricardo Wurmus In-reply-to: <87tv1ivfry.fsf@gnu.org> 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 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Jan Nieuwenhuizen Cc: 40629@debbugs.gnu.org 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