~ruther/guix-exprs

ref: 75eae2a21ecb408498bff4d5582f93bef9ce15cd guix-exprs/modules/ruther/home/services/xdg-desktop-portals.scm -rw-r--r-- 3.1 KiB
75eae2a2 — Rutherther chore: move modules to modules subfolder 15 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
(define-module (ruther home services xdg-desktop-portals)
  #:use-module (srfi srfi-1)

  #:use-module (guix gexp)
  #:use-module (guix packages)
  #:use-module (guix build-system copy)

  #:use-module (rde serializers ini)
  #:use-module (gnu services)
  #:use-module (gnu home services)
  #:use-module (gnu packages freedesktop)
  #:use-module (gnu services configuration)

  #:export (xdg-desktop-portals-conf
            xdg-desktop-portal-configuration))

(define-configuration/no-serialization xdg-desktop-portals-conf
  (name string "Name of the portals configuration, like sway.
Set your XDG_CURRENT_DESKTOP to this name to use this config")
  (config ini-config "Configuration for the given x-portals.conf."))

(define (list-of-xdg-portals-conf? lst)
  (every xdg-desktop-portals-conf? lst))

(define (list-of-file-like? lst)
  (every file-like? lst))

(define-configuration/no-serialization xdg-desktop-portal-configuration
  (xdg-desktop-portal (file-like xdg-desktop-portal) "The xdg-desktop-portal to add to the home profile.")
  (implementations list-of-file-like "The implementations of xdg-desktop-portal interfaces to add to the home profile.")
  (configs
   list-of-xdg-portals-conf
   "Configurations to provide for xdg portals.confs"))

(define (xdg-desktop-portals-conf-files config)
  (computed-file
   "union-of-portals.conf"
   (with-imported-modules '((guix build utils))
     #~(begin
         (use-modules (guix build utils))
         (mkdir-p (string-append #$output "/share/xdg-desktop-portal"))
         (for-each
          (lambda (portals-conf)
            (call-with-output-file (string-append
                                    #$output
                                    "/share/xdg-desktop-portal/"
                                    (car portals-conf) "-portals.conf")
              (lambda (port)
                (display (apply string-append (cdr portals-conf)) port))))
          '#$(map
              (lambda (x) (cons (xdg-desktop-portals-conf-name x)
                                (serialize-ini-config (xdg-desktop-portals-conf-config x)
                                                      #:equal-string "=")))
              (xdg-desktop-portal-configuration-configs config)))))))

(define (add-xdg-desktop-portals-packages config)
  (cons* (xdg-desktop-portal-configuration-xdg-desktop-portal config)
         (package
           (name "union-of-portals.conf")
           (version "0.0.0")
           (source (xdg-desktop-portals-conf-files config))
           (build-system copy-build-system)
           (synopsis "Union of portals.conf files")
           (description "Union of portals.conf files")
           (license #f)
           (home-page #f))
         (xdg-desktop-portal-configuration-implementations config)))

(define-public home-xdg-desktop-portal-service-type
  (service-type
   (name 'xdg-desktop-portal-service)
   (description "A service to provide xdg-desktop-portal config files, and add implementations to the home profile.")
   (extensions (list (service-extension home-profile-service-type
                                        add-xdg-desktop-portals-packages)))))
Do not follow this link