dotfiles/oni/home/services/guile.scm

64 lines
2.1 KiB
Scheme

(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)
(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) '())))
(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
(λ (port)
(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")))