utils: Add ‘hidden-desktop-entry’.

* modules/rosenthal/utils/file.scm (hidden-desktop-entry): New procedure.
This commit is contained in:
Hilton Chain 2025-06-27 20:18:29 +08:00
parent dc6ed8b930
commit 8c1b2e9c61
No known key found for this signature in database
GPG Key ID: ACC66D09CA528292

View File

@ -5,7 +5,11 @@
#:use-module (ice-9 textual-ports) #:use-module (ice-9 textual-ports)
#:use-module (guix gexp) #:use-module (guix gexp)
#:export (computed-substitution-with-inputs #:export (computed-substitution-with-inputs
file-content)) file-content
hidden-desktop-entry))
;; XXX: substitute* doesn't fully support Unicode:
;; https://codeberg.org/guix/guix/src/commit/a88d6a45e422cede96d57d7a953439dc27c6a50c/guix/build/utils.scm#L964
(define (computed-substitution-with-inputs name file inputs) (define (computed-substitution-with-inputs name file inputs)
(with-imported-modules '((guix build utils)) (with-imported-modules '((guix build utils))
@ -20,3 +24,13 @@
(define (file-content file) (define (file-content file)
(call-with-input-file (canonicalize-path file) get-string-all)) (call-with-input-file (canonicalize-path file) get-string-all))
(define (hidden-desktop-entry name file)
(computed-file name
(with-imported-modules '((guix build utils))
#~(begin
(use-modules (guix build utils))
(copy-file #$file #$output)
(substitute* #$output
(("[Desktop Entry]" all)
(string-append all "NoDisplay=true\n")))))))