diff --git a/oni/home/data/config.scm b/oni/home/data/config.scm index 0c89d5b..f54221f 100644 --- a/oni/home/data/config.scm +++ b/oni/home/data/config.scm @@ -25,6 +25,7 @@ #:use-module (oni home services syncthing) #:use-module (oni home services unclutter) #:use-module (oni home services dunst) + #:use-module (oni home services guile) #:use-module (oni packages hlwm-run-or-raise) #:use-module (oni packages pick-random-wallpaper)) @@ -444,4 +445,9 @@ LocalForward 2812 localhost:2812")) ("gPodder" (appname "gPodder") (background "#7f5785") - (foreground "#ffffff"))))))))) + (foreground "#ffffff")))))) + + (service home-guile-service-type + (home-guile-configuration + (use-readline #t) + (use-colorized #t)))))) diff --git a/oni/home/services/guile.scm b/oni/home/services/guile.scm new file mode 100644 index 0000000..a8b17f5 --- /dev/null +++ b/oni/home/services/guile.scm @@ -0,0 +1,66 @@ +(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) + (let ((package-list (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) '())))) + (display package-list) + package-list)) + +(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 + (lambda (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")))