syntax-draft.org 5.0 KB

S-expressions

Package parameter combination declaration

Hello, this document is a draft that covers some ideas for parameter syntax. The idea for this format came from a mailing-list reply to my post on parameterized packages; instead of using a huge number of confusing symbols, it could be possible to specify parameters using just S-expressions


(parameters ; the parameters section of a package 'zoo'
  (required ant beaver) ; these are REQUIRED to build the package
  (required-off zebra) ; these are REQUIRED TO BE OFF, useful for forcing errors
  (optional (cat dog) elephant) ; these are optional, cat and dog are default
  (one-of cat flamingo gorilla) ; only one of these is allowed, cat is default
  (one-of none hippo impala) ; only one of these is allowed, none are default
  (special (on flamingo) ; flamingo, if ON, has a special transform
           (off cat hippo))) ; these will have them when OFF

User parameter argument declaration


  (parameters
   (on ant beaver cat) ; these will be ON
   (off flamingo zebra)) ; these will be OFF

Using these parameters

Keys

Package parameter combination declaration

There are three ways that these can be used: 1) The --with-parameters transform #+BEGIN_SRC shell guix build zoo --with-parameters="(on ant beaver cat) (off flamingo zebra)" #+END_SRC 2) The --with-recursive-parameters transform #+BEGIN_SRC shell guix build zoo --with-recursive-parameters="(on ant beaver cat) (off flamingo zebra)" #+END_SRC (These parameters will recurse over the dependencies of the package) 3) The operating-system's "transformations" entry #+BEGIN_SRC scheme (operating-system ;; ... (transformations ;; ... (with-parameters . "(on ant beaver cat) (off flamingo zebra)"))) #+END_SRC A less S-expression heavy way to use these could be to use #:keys


(parameters ; the parameters section of a package 'zoo'
  #:required ant beaver ; these are REQUIRED to build the package
  #:required-off zebra ; these are REQUIRED TO BE OFF, useful for forcing errors
  #:optional (cat dog) elephant ; these are optional, cat and dog are default
  #:one-of cat flamingo gorilla ; only one of these is allowed, cat is default
  #:one-of none hippo impala ; only one of these is allowed, none are default
  #:special #:on flamingo ; flamingo, if ON, has a special transform
            #:off cat hippo) ; these will have them when OFF

User parameter argument declaration


  (parameters
   #:on ant beaver cat ; these will be ON
   #:off flamingo zebra) ; these will be OFF

Using these parameters

Original

Package parameter combination declaration

There are three ways that these can be used: 1) The --with-parameters transform #+BEGIN_SRC shell guix build zoo --with-parameters="#:on ant beaver cat #:off flamingo zebra" #+END_SRC 2) The --with-recursive-parameters transform #+BEGIN_SRC shell guix build zoo --with-recursive-parameters="#:on ant beaver cat #:off flamingo zebra" #+END_SRC (These parameters will recurse over the dependencies of the package) 3) The operating-system's "transformations" entry #+BEGIN_SRC scheme (operating-system ;; ... (transformations ;; ... (with-parameters . "#:on ant beaver cat #:off flamingo zebra"))) #+END_SRC This is the original idea I had given in the proposal and the blog post


  (parameters (and
    ant beaver zebra! ; ant and beaver are REQUIRED, zebra is REQUIRED TO BE OFF
    (optional cat^ dog^ elephant) ; these are optional, cat and dog are default
    (one-of cat^* flamingo* gorilla) ; only one of these is allowed, cat is default
    (one-of hippo* impala))) ; only one of these is allowed, none are default
  ;; flamingo, cat and hippo have special transforms

User parameter argument declaration


   ant beaver cat ; these will be ON
   flamingo! zebra! ; these will be OFF

Using these parameters

Conclusion

There are three ways that these can be used: 1) The --with-parameters transform #+BEGIN_SRC shell guix build zoo --with-parameters="ant beaver cat flamingo! zebra!" #+END_SRC 2) The --with-recursive-parameters transform #+BEGIN_SRC shell guix build zoo --with-recursive-parameters="ant beaver cat flamingo! zebra!" #+END_SRC (These parameters will recurse over the dependencies of the package) 3) The operating-system's "transformations" entry #+BEGIN_SRC scheme (operating-system ;; ... (transformations ;; ... (with-parameters . "ant beaver cat flamingo! zebra!"))) #+END_SRC Ultimately, either one of these or a combination of these could be used to implement parameters. The syntax itself is malleable as long as the underlying technology has been built.