2022-07-22 21:36:36 +02:00
|
|
|
(define-module (oni home services guile)
|
|
|
|
#:use-module (ice-9 match)
|
|
|
|
#:use-module (gnu home services)
|
|
|
|
#:use-module (gnu packages guile)
|
|
|
|
#:use-module (gnu packages guile-xyz)
|
|
|
|
#:use-module (gnu services configuration)
|
|
|
|
#:use-module (guix packages)
|
|
|
|
#:use-module (guix gexp)
|
|
|
|
|
|
|
|
#:export (home-guile-service-type
|
|
|
|
home-guile-configuration))
|
|
|
|
|
|
|
|
(define (serialize-boolean field value)
|
|
|
|
(match field
|
|
|
|
('use-readline
|
|
|
|
(if value
|
|
|
|
"(use-modules (ice-9 readline))
|
|
|
|
(activate-readline)\n"
|
|
|
|
""))
|
|
|
|
('use-colorized
|
|
|
|
(if value
|
|
|
|
"(use-modules (ice-9 colorized))
|
|
|
|
(activate-colorized)\n"
|
|
|
|
""))))
|
|
|
|
|
|
|
|
(define-configuration home-guile-configuration
|
|
|
|
(package
|
|
|
|
(package guile-3.0-latest)
|
|
|
|
"Package to use for setting Guile")
|
|
|
|
(use-readline
|
|
|
|
(boolean #f)
|
|
|
|
"Should readline be initialized in Guile?")
|
|
|
|
(use-colorized
|
|
|
|
(boolean #f)
|
|
|
|
"Should the colorized module be initialized in Guile?"))
|
|
|
|
|
|
|
|
(define (add-guile-packages config)
|
2022-07-23 06:14:27 +02:00
|
|
|
(append (list (home-guile-configuration-package config))
|
|
|
|
(if (home-guile-configuration-use-readline config) (list guile-readline) '())
|
|
|
|
(if (home-guile-configuration-use-colorized config) (list guile-colorized) '())))
|
2022-07-22 21:36:36 +02:00
|
|
|
|
|
|
|
(define (serialize-guile-configuration config)
|
|
|
|
(serialize-configuration config home-guile-configuration-fields))
|
|
|
|
|
|
|
|
(define (home-guile-config-file config)
|
|
|
|
(computed-file "guile"
|
|
|
|
#~(call-with-output-file #$output
|
2023-06-21 08:06:25 +02:00
|
|
|
(λ (port)
|
2022-07-22 21:36:36 +02:00
|
|
|
(display #$(serialize-guile-configuration config) port)))))
|
|
|
|
|
|
|
|
(define (home-guile-config-files config)
|
|
|
|
`((".guile" ,(home-guile-config-file config))))
|
|
|
|
|
|
|
|
(define home-guile-service-type
|
|
|
|
(service-type (name 'home-guile)
|
|
|
|
(extensions
|
|
|
|
(list (service-extension
|
|
|
|
home-files-service-type
|
|
|
|
home-guile-config-files)
|
|
|
|
(service-extension
|
|
|
|
home-profile-service-type
|
|
|
|
add-guile-packages)))
|
|
|
|
(default-value (home-guile-configuration))
|
|
|
|
(description "Configure guile")))
|