utils: Add json-file.

* modules/rosenthal/utils/file.scm (json-file): New procedure.
* modules/rosenthal/services/desktop.scm (%rosenthal-skeletons-installer)
[.cache/noctalia/shell-state.json]: Use it.
This commit is contained in:
Hilton Chain committed 2026-02-25 16:18:45 +08:00
1 parent c2630512c6
commit f8fb2556c3
2 files changed
+19 -14

No files matched your search

+13
View File
@@ -7,12 +7,14 @@
;; Utilities
#:use-module (guix gexp)
;; Guix packages
#:use-module (gnu packages guile)
#:use-module (gnu packages guile-xyz)
#:export (computed-substitution-with-inputs
file-content
hidden-desktop-entry
ini-file
json-file
yaml-file))
;; XXX: ‘substitute*’ doesn't fully support Unicode:
@@ -67,6 +69,17 @@ format."
(call-with-output-file #$output
(cut scm->ini #$exp #:port <>))))))
;; https://github.com/aconchillo/guile-json
(define (json-file name exp)
"Return file-like object NAME, serialized from G-expression EXP in JSON
format."
(computed-file name
(with-extensions (list guile-json-4)
#~(begin
(use-modules (srfi srfi-26) (json))
(call-with-output-file #$output
(cut scm->json #$exp <> #:pretty #t))))))
;; https://gitlab.com/yorgath/guile-yamlpp
(define (yaml-file name exp)
"Return file-like object NAME, serialized from G-expression EXP in YAML