guix-home-manager/home/keepassxc.scm

keepassxc.scm

1
;;; Guix Home Manager.
2
;;;
3
;;; Copyright © 2019 Julien Lepiller <julien@lepiller.eu>
4
;;;
5
;;; This program is free software: you can redistribute it and/or modify
6
;;; it under the terms of the GNU General Public License as published by
7
;;; the Free Software Foundation, either version 3 of the License, or
8
;;; (at your option) any later version.
9
;;;
10
;;; This program is distributed in the hope that it will be useful,
11
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
;;; GNU General Public License for more details.
14
;;;
15
;;; You should have received a copy of the GNU General Public License
16
;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18
(define-module (home keepassxc)
19
  #:use-module (guix build utils)
20
  #:use-module (guix gexp)
21
  #:use-module (guix records)
22
  #:use-module (gnu packages lxde)
23
  #:use-module (ice-9 match)
24
  #:use-module (home utils)
25
  #:use-module (home)
26
  #:export (keepassxc-configuration
27
            keepassxc-last-databases
28
            keepassxc-last-dir
29
            keepassxc-last-opened-databases
30
            keepassxc-show-toolbar?
31
            keepassxc-hide-passwords?
32
            keepassxc-hide-usernames?
33
            keepassxc-eaasci?
34
            keepassxc-ensure-every?
35
            keepassxc-exclude-alike?
36
            keepassxc-password-length
37
            keepassxc-use-lower-case?
38
            keepassxc-use-numbers?
39
            keepassxc-use-special-chars?
40
            keepassxc-type
41
            keepassxc-use-upper-case?
42
            keepassxc-word-count
43
            keepassxc-wordlist
44
            keepassxc-word-separator
45
46
            keepassxc-home-type))
47
48
(define-record-type* <keepassxc-configuration>
49
  keepassxc-configuration make-keepassxc-configuration
50
  keepassxc-configuration?
51
  (last-databases        keepassxc-last-databases
52
                         (default '()))
53
  (last-dir              keepassxc-last-dir
54
                         (default #f))
55
  (last-opened-databases keepassxc-last-opened-databases
56
                         (default '()))
57
  (show-toolbar?         keepassxc-show-toolbar?
58
                         (default #t))
59
  (hide-passwords?       keepassxc-hide-passwords?
60
                         (default #t))
61
  (hide-usernames?       keepassxc-hide-usernames?
62
                         (default #f))
63
  (ensure-every?         keepassxc-ensure-every?
64
                         (default #t))
65
  (exclude-alike?        keepassxc-exclude-alike?
66
                         (default #t))
67
  (password-length       keepassxc-password-length
68
                         (default 28))
69
  (use-eascii?           keepassxc-use-eascii?
70
                         (default #f))
71
  (use-lower-case?       keepassxc-use-lower-case?
72
                         (default #t))
73
  (use-upper-case?       keepassxc-use-upper-case?
74
                         (default #t))
75
  (use-numbers?          keepassxc-use-numbers?
76
                         (default #t))
77
  (use-special-chars?    keepassxc-use-special-chars?
78
                         (default #f))
79
  (type                  keepassxc-type
80
                         (default 0))
81
  (word-count            keepassxc-word-count
82
                         (default 7))
83
  (wordlist              keepassxc-wordlist
84
                         (default "eff_large.wordlist"))
85
  (word-separator        keepassxc-word-separator
86
                         (default " ")))
87
88
(define keepassxc-home-type
89
  (home-type
90
    (name 'keepassxc)
91
    (extensions
92
      (list
93
        (home-extension
94
          (target root-home-type)
95
          (compute (lambda (config)
96
                     (let ((keepassxc.ini
97
                             (make-ini-file "keepassxc.ini"
98
                              `(("General"
99
                                 (("LastDatabases"
100
                                   ,(string-join
101
                                      (keepassxc-last-databases config)
102
                                      ", "))
103
                                  ("LastDir"
104
                                   ,(or (keepassxc-last-dir config) ""))
105
                                  ("LastOpenedDatabases"
106
                                   ,(string-join
107
                                      (keepassxc-last-opened-databases config)
108
                                      ", "))))
109
                                ("GUI"
110
                                 (("HidePasswords"
111
                                   ,(keepassxc-hide-passwords? config))
112
                                  ("HideUsernames"
113
                                   ,(keepassxc-hide-usernames? config))))
114
                                ("generator"
115
                                 (("EASCII"
116
                                   ,(keepassxc-use-eascii? config))
117
                                  ("EnsureEvery"
118
                                   ,(keepassxc-ensure-every? config))
119
                                  ("ExcludeAlike"
120
                                   ,(keepassxc-exclude-alike? config))
121
                                  ("Length"
122
                                   ,(keepassxc-password-length config))
123
                                  ("LowerCase"
124
                                   ,(keepassxc-use-lower-case? config))
125
                                  ("Numbers"
126
                                   ,(keepassxc-use-numbers? config))
127
                                  ("SpecialChars"
128
                                   ,(keepassxc-use-special-chars? config))
129
                                  ("Type"
130
                                   ,(keepassxc-type config))
131
                                  ("UpperCase"
132
                                   ,(keepassxc-use-upper-case? config))
133
                                  ("WordCount"
134
                                   ,(keepassxc-word-count config))
135
                                  ("WordList"
136
                                   ,(keepassxc-wordlist config))
137
                                  ("WordSeparator"
138
                                   ,(keepassxc-word-separator config))))))))
139
                       `((".config/keepassxc/keepassxc.ini" ,keepassxc.ini))))))))))
140