# define-configuration-expand-1.scm -rw-r--r-- 1.8 KiB View raw
                                                                                
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
(begin
  (define-record-type*
    <home-sway-configuration>
    %home-sway-configuration
    make-home-sway-configuration
    home-sway-configuration?
    this-home-sway-configuration
    (%location
      -location
      (default
        (and=> (current-source-location)
               source-properties->location))
      (innate))
    (package
      home-sway-configuration-package
      (thunked)
      (default sway))
    (config
      home-sway-configuration-config
      (thunked)
      (default
        `((include
            ,(file-append
               (home-sway-configuration-package
                 this-home-sway-configuration)
               "/etc/sway/config"))))))
  (define home-sway-configuration-fields
    (list (configuration-field
            (name 'package)
            (type 'package)
            (getter home-sway-configuration-package)
            (predicate package?)
            (serializer serialize-package)
            (default-value-thunk (lambda () sway))
            (documentation "Sway package to use."))
          (configuration-field
            (name 'config)
            (type 'sway-config)
            (getter home-sway-configuration-config)
            (predicate sway-config?)
            (serializer serialize-sway-config)
            (default-value-thunk
              (lambda ()
                `((include
                    ,(file-append
                       (home-sway-configuration-package
                         this-home-sway-configuration)
                       "/etc/sway/config")))))
            (documentation "Documenation here"))))
  (define-syntax-rule
    (home-sway-configuration arg ...)
    (let ((conf (%home-sway-configuration arg ...)))
      (validate-configuration
        conf
        home-sway-configuration-fields)
      conf)))