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 | #:export (keepassxc-configuration |
26 | keepassxc-last-databases |
27 | keepassxc-last-dir |
28 | keepassxc-last-opened-databases |
29 | keepassxc-show-toolbar? |
30 | keepassxc-hide-passwords? |
31 | keepassxc-hide-usernames? |
32 | keepassxc-eaasci? |
33 | keepassxc-ensure-every? |
34 | keepassxc-exclude-alike? |
35 | keepassxc-password-length |
36 | keepassxc-use-lower-case? |
37 | keepassxc-use-numbers? |
38 | keepassxc-use-special-chars? |
39 | keepassxc-type |
40 | keepassxc-use-upper-case? |
41 | keepassxc-word-count |
42 | keepassxc-wordlist |
43 | keepassxc-word-separator |
44 | |
45 | keepassxc-home)) |
46 | |
47 | (define-record-type* <keepassxc-configuration> |
48 | keepassxc-configuration make-keepassxc-configuration |
49 | keepassxc-configuration? |
50 | (last-databases keepassxc-last-databases |
51 | (default '())) |
52 | (last-dir keepassxc-last-dir |
53 | (default #f)) |
54 | (last-opened-databases keepassxc-last-opened-databases |
55 | (default '())) |
56 | (show-toolbar? keepassxc-show-toolbar? |
57 | (default #t)) |
58 | (hide-passwords? keepassxc-hide-passwords? |
59 | (default #t)) |
60 | (hide-usernames? keepassxc-hide-usernames? |
61 | (default #f)) |
62 | (ensure-every? keepassxc-ensure-every? |
63 | (default #t)) |
64 | (exclude-alike? keepassxc-exclude-alike? |
65 | (default #t)) |
66 | (password-length keepassxc-password-length |
67 | (default 28)) |
68 | (use-eascii? keepassxc-use-eascii? |
69 | (default #f)) |
70 | (use-lower-case? keepassxc-use-lower-case? |
71 | (default #t)) |
72 | (use-upper-case? keepassxc-use-upper-case? |
73 | (default #t)) |
74 | (use-numbers? keepassxc-use-numbers? |
75 | (default #t)) |
76 | (use-special-chars? keepassxc-use-special-chars? |
77 | (default #f)) |
78 | (type keepassxc-type |
79 | (default 0)) |
80 | (word-count keepassxc-word-count |
81 | (default 7)) |
82 | (wordlist keepassxc-wordlist |
83 | (default "eff_large.wordlist")) |
84 | (word-separator keepassxc-word-separator |
85 | (default " "))) |
86 | |
87 | (define (keepassxc-home config) |
88 | (computed-file "keepassxc-home" |
89 | (let ((keepassxc.ini (make-ini-file "keepassxc.ini" |
90 | `(("General" |
91 | (("LastDatabases" |
92 | ,(string-join |
93 | (keepassxc-last-databases config) |
94 | ", ")) |
95 | ("LastDir" |
96 | ,(or (keepassxc-last-dir config) "")) |
97 | ("LastOpenedDatabases" |
98 | ,(string-join |
99 | (keepassxc-last-opened-databases config) |
100 | ", ")))) |
101 | ("GUI" |
102 | (("HidePasswords" |
103 | ,(keepassxc-hide-passwords? config)) |
104 | ("HideUsernames" |
105 | ,(keepassxc-hide-usernames? config)))) |
106 | ("generator" |
107 | (("EASCII" |
108 | ,(keepassxc-use-eascii? config)) |
109 | ("EnsureEvery" |
110 | ,(keepassxc-ensure-every? config)) |
111 | ("ExcludeAlike" |
112 | ,(keepassxc-exclude-alike? config)) |
113 | ("Length" |
114 | ,(keepassxc-password-length config)) |
115 | ("LowerCase" |
116 | ,(keepassxc-use-lower-case? config)) |
117 | ("Numbers" |
118 | ,(keepassxc-use-numbers? config)) |
119 | ("SpecialChars" |
120 | ,(keepassxc-use-special-chars? config)) |
121 | ("Type" |
122 | ,(keepassxc-type config)) |
123 | ("UpperCase" |
124 | ,(keepassxc-use-upper-case? config)) |
125 | ("WordCount" |
126 | ,(keepassxc-word-count config)) |
127 | ("WordList" |
128 | ,(keepassxc-wordlist config)) |
129 | ("WordSeparator" |
130 | ,(keepassxc-word-separator config)))))))) |
131 | #~(begin |
132 | (let ((keepassxc-dir (string-append #$output "/.config/keepassxc"))) |
133 | (use-modules (guix build utils)) |
134 | (mkdir-p keepassxc-dir) |
135 | (copy-file #$keepassxc.ini (string-append keepassxc-dir "/keepassxc.ini"))))) |
136 | #:options |
137 | '(#:local-build? #t |
138 | #:modules ((guix build utils))))) |
139 |