guixconfig/library.org
2023-12-14 22:49:12 +01:00

1.6 KiB

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.

  (pretty-print
   `(,(string->symbol use-call)
     ,@(map (lambda (x)
              (let ((splits (string-split x #\ )))
                (if (and (= (length splits) 1)
                         (= 0 all-parens))
                    (string->symbol (car splits))
                    (map (lambda (y) (string->symbol y))
                         splits))))
            entries)))

Converting Org lists into Scheme symbol lists.

  • Entry 1
  • Entry 2
  (pretty-print 
   `(list ,@(map string->symbol input)))
(list #{Entry 1}# #{Entry 2}#)

Converting Tables

  (pretty-print
   `(list
     ,@(map
        (lambda (row)
          (let ((service-name (car row))
                (configuration (cadr row)))
            `(service ,(string->symbol (string-append service-name "-service-type"))
                      (,(string->symbol (string-append service-name "-configuration"))
                       ,@(call-with-input-string configuration
                           read)))))
        input)))