flatpak service
This commit is contained in:
parent
7eb6780a58
commit
1511f0cd92
3 changed files with 90 additions and 1 deletions
79
guix-config/home/services/flatpak.scm
Normal file
79
guix-config/home/services/flatpak.scm
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
(define-module (guix-config home services flatpak)
|
||||
#:use-module (gnu home services)
|
||||
#:use-module (gnu home services utils)
|
||||
#: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-service config)
|
||||
(list
|
||||
;; 1. Ensure flatpak installed
|
||||
(simple-service
|
||||
'flatpak-packages
|
||||
home-profile-service-type
|
||||
(list (home-flatpak-configuration-flatpak-package config)))
|
||||
|
||||
;; 2. Add flatpak apps to XDG_DATA_DIRS
|
||||
;; https://forum.systemcrafters.net/t/gnome-software-center-flatpak-support/1702/3
|
||||
(simple-service
|
||||
'flatpak-env
|
||||
home-shell-profile-service-type
|
||||
(list (local-file
|
||||
(string-append (getenv "HOME") "/.guix-profile/etc/profile.d/flatpak.sh")
|
||||
"flatpak.sh")))
|
||||
|
||||
|
||||
;; 3. Activation phase
|
||||
(simple-service
|
||||
'flatpak-activation
|
||||
home-activation-service-type
|
||||
(home-flatpak-activation config))))
|
||||
|
||||
(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-activation-service-type
|
||||
home-flatpak-activation)))
|
||||
(default-value (home-flatpak-configuration))
|
||||
(description "Set up Flatpak with user remotes and apps.")))
|
||||
Loading…
Add table
Add a link
Reference in a new issue