66 lines
2.3 KiB
Scheme
66 lines
2.3 KiB
Scheme
(define-module (guix-config home services flatpak)
|
|
#:use-module (gnu home services)
|
|
#:use-module (gnu home services utils)
|
|
#:use-module (gnu home services shells)
|
|
#:use-module (gnu services)
|
|
#:use-module (gnu packages package-management)
|
|
#:use-module (guix gexp)
|
|
#:use-module (guix records)
|
|
#:export (home-flatpak-configuration
|
|
home-flatpak-service-type))
|
|
|
|
;; Configuration record
|
|
(define-record-type* <home-flatpak-configuration>
|
|
home-flatpak-configuration make-home-flatpak-configuration
|
|
home-flatpak-configuration?
|
|
(flatpak-package home-flatpak-configuration-flatpak-package
|
|
(default flatpak))
|
|
(remotes home-flatpak-configuration-remotes
|
|
(default '(("flathub" . "https://flathub.org/repo/flathub.flatpakrepo"))))
|
|
(apps home-flatpak-configuration-apps (default '())))
|
|
|
|
;; Service type
|
|
(define (home-flatpak-activation config)
|
|
#~(begin
|
|
(use-modules (ice-9 popen) (ice-9 rdelim) (srfi srfi-1))
|
|
|
|
(define (run cmd)
|
|
(format #t "Running: ~a~%" cmd)
|
|
(system* "bash" "-c" cmd))
|
|
|
|
;; Add remotes if missing
|
|
(for-each
|
|
(lambda (pair)
|
|
(let ((name (car pair))
|
|
(url (cdr pair)))
|
|
(run (string-append
|
|
"flatpak remote-add --user --if-not-exists "
|
|
name " " url))))
|
|
'#$(home-flatpak-configuration-remotes config))
|
|
|
|
;; Install apps
|
|
(for-each
|
|
(lambda (app)
|
|
(run (string-append "flatpak install -y --user " app)))
|
|
'#$(home-flatpak-configuration-apps config))))
|
|
|
|
(define (home-flatpak-env config)
|
|
(home-bash-extension
|
|
(bashrc
|
|
(list
|
|
(file-append (home-flatpak-configuration-flatpak-package config)
|
|
"/etc/profile.d/flatpak.sh")))))
|
|
|
|
|
|
(define home-flatpak-service-type
|
|
(service-type
|
|
(name 'home-flatpak)
|
|
(extensions
|
|
(list (service-extension home-profile-service-type
|
|
(compose list home-flatpak-configuration-flatpak-package))
|
|
(service-extension home-bash-service-type
|
|
home-flatpak-env)
|
|
(service-extension home-activation-service-type
|
|
home-flatpak-activation)))
|
|
(default-value (home-flatpak-configuration))
|
|
(description "Set up Flatpak with user remotes and apps.")))
|