guixconfig/library.org

44 lines
1.3 KiB
Org Mode
Raw Normal View History

2023-12-01 13:22:33 +00:00
#+TITLE: Babel Library
This library contains code blocks to be used by other files in this repository.
* Converting Lists
Converting org lists into guix ~use-~ calls.
#+NAME: list-to-use
2023-12-01 13:32:56 +00:00
#+begin_src emacs-lisp :var use-call="use-modules" :var entries='() :var all-parens=0 :results code pp
2023-12-01 13:22:33 +00:00
`(,(make-symbol use-call)
,@(mapcar (lambda (x)
2023-12-01 13:27:53 +00:00
(let ((splits (split-string x)))
2023-12-01 13:32:56 +00:00
(if (and (length= splits 1)
(= 0 all-parens))
2023-12-01 13:27:53 +00:00
(make-symbol (car splits))
(mapcar (lambda (y) (make-symbol y))
splits))))
2023-12-01 13:22:33 +00:00
entries))
#+end_src
Converting Org lists into Scheme symbol lists.
#+NAME: org-to-scheme-sym-list
2023-12-01 13:27:53 +00:00
#+begin_src emacs-lisp :var input='() :results code pp
2023-12-01 13:22:33 +00:00
`(list
,@(mapcar (lambda (x) (make-symbol x)) input))
#+end_src
* Converting Tables
#+NAME: service-converter
2023-12-01 13:27:53 +00:00
#+begin_src emacs-lisp :var input='() :colnames yes :results code pp
2023-12-01 13:22:33 +00:00
`(list
,@(mapcar
(lambda (row)
(let ((service-name (cl-first row))
(configuration (cl-second row)))
`(,(make-symbol (s-concat service-name "-service-type"))
(,(make-symbol (s-concat service-name "-configuration"))
,@(car (read-from-string configuration))))))
input))
#+end_src