unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Ricardo Wurmus <rekado@elephly.net>
To: Jan Nieuwenhuizen <janneke@gnu.org>
Cc: 40629@debbugs.gnu.org
Subject: [bug#40629] [PATCH v2 9/9] import/json: json->code: Handle files with more than one definition.
Date: Sat, 18 Apr 2020 22:23:52 +0200	[thread overview]
Message-ID: <87y2qslezr.fsf@elephly.net> (raw)
In-Reply-To: <87tv1ivfry.fsf@gnu.org>


Jan Nieuwenhuizen <janneke@gnu.org> writes:

> Ricardo Wurmus writes:
>
>> With these last few changes it’s 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"]
>>   }
>> ]
>>
>> “hello2” has “myhello” as an input.  When this file is passed to “guix
>> install -f” both packages will be built and “hello2” 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 “arguments” field).

-- 
Ricardo

  reply	other threads:[~2020-04-18 20:25 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-14 15:44 [bug#40629] Build and install packages from JSON definitions Ricardo Wurmus
2020-04-14 17:19 ` [bug#40629] [PATCH 1/5] import/print: Return license with prefix Ricardo Wurmus
2020-04-14 17:19   ` [bug#40629] [PATCH 2/5] import/print: package->code: Wrap build system value in module reference Ricardo Wurmus
2020-04-14 17:19   ` [bug#40629] [PATCH 3/5] import/json: Add json->scheme-file Ricardo Wurmus
2020-04-14 17:19   ` [bug#40629] [PATCH 4/5] scripts/build: options->things-to-build: Handle .json files Ricardo Wurmus
2020-04-16 21:45     ` Ludovic Courtès
2020-04-16 21:53     ` Ludovic Courtès
2020-04-14 17:19   ` [bug#40629] [PATCH 5/5] scripts/package: Handle JSON files Ricardo Wurmus
2020-04-14 22:48 ` [bug#40629] [PATCH 6/9] import/json: Use json->code Ricardo Wurmus
2020-04-14 22:48   ` [bug#40629] [PATCH 7/9] import/print: package->code: Wrap S-expression in definition Ricardo Wurmus
2020-04-14 22:48   ` [bug#40629] [PATCH 8/9] import/utils: alist->package: Ignore known inputs Ricardo Wurmus
2020-04-14 22:48   ` [bug#40629] [PATCH 9/9] import/json: json->code: Handle files with more than one definition Ricardo Wurmus
2020-04-14 22:59 ` [bug#40629] [PATCH v2 8/9] import/utils: alist->package: Ignore known inputs Ricardo Wurmus
2020-04-14 22:59   ` [bug#40629] [PATCH v2 9/9] import/json: json->code: Handle files with more than one definition Ricardo Wurmus
2020-04-14 23:01     ` Ricardo Wurmus
2020-04-17  5:32       ` Jan Nieuwenhuizen
2020-04-18 20:23         ` Ricardo Wurmus [this message]
2020-04-15 18:26 ` [bug#40629] Build and install packages from JSON definitions Christopher Baines
2020-04-15 22:27   ` Ricardo Wurmus
2020-04-16 21:44     ` bug#40629: " Ricardo Wurmus
2020-04-17 17:45     ` [bug#40629] " Christopher Baines
2020-04-16 21:50 ` Ludovic Courtès
2020-04-17  8:25   ` Ricardo Wurmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y2qslezr.fsf@elephly.net \
    --to=rekado@elephly.net \
    --cc=40629@debbugs.gnu.org \
    --cc=janneke@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).