home: Add keepassxc support.

Julien LepillerWed Jun 26 23:25:54+0200 2019

e4b7388

home: Add keepassxc support. * home/keepassxc.scm: New file. * doc/keepassxc.md: New file.

doc/keepassxc.md unknown status 1

1+
Keepassxc
2+
=========
3+
4+
Keepassxc is a password manager.  Parts of the configuration file is used for
5+
storing states.  Unfortunately, we cannot store parts of that file as read-write
6+
and the rest as read-only.  We treat this file as a static configuration file,
7+
but you can also create a symlink with the home utilities if you prefer.
8+
9+
Main Configuration
10+
------------------
11+
12+
The main configuration is not complete compared to the configuration possibilities
13+
of keepassxc.  It currently implemets most of the configuration, but excludes
14+
a few difficult parts.
15+
16+
**Scheme Procedure**: (keepassxc-home config)
17+
18+
Generates a configuration file for keepassxc, according to config, a
19+
keepassxc-configuration object.
20+
21+
**Data Type**: keepassxc-configuration
22+
23+
Data type that represents the Keepassxc configuration.  This data type has the
24+
following fields:
25+
26+
* **last-databases** (default '()): A list of databases the user last tried to
27+
  open.  This should probably set to the list of databases you want to use.
28+
* **last-dir** (default #f): The last directory opened by the user.  This
29+
  should probably set to your data directory, `/data/alice` in the installation
30+
  example.
31+
* **last-databases** (default '()): A list of databases the user last opened.
32+
  This should probably set to the list of databases you want to use.
33+
* **show-toolbar?** (default #t): Undocumented.
34+
* **hide-passwords?** (default #t): Whether to show passwords on the GUI.
35+
* **hide-usernames?** (default #f): Whether to show user names on the GUI.
36+
* **ensure-every?** (default #t): Whether to use every class of characters in
37+
  password, or allow passwords that don't contain every enables classes.
38+
* **exclude-alike?** (default #t): Whether to prevent using similar characters.
39+
* **password-length** (default 28): The default generated password length.
40+
* **use-eascii?** (default #f): Whether to use extended ascii in generated
41+
  passwords.
42+
* **use-lower-case?** (default #t): Whether to use lower case letters in
43+
  generated passwords.
44+
* **use-upper-case?** (default #t): Whether to use upper case letters in
45+
  generated passwords.
46+
* **use-numbers?** (default #t): Whether to use numbers in generated passwords.
47+
* **use-special-chars?** (default #f): Whether to use special characters in
48+
  generated passwords.
49+
* **type** (default 0): Undocumented.
50+
* **word-count** (default 7): Undocumented.
51+
* **wordlist** (default "eff_large.wordlist"): Undocumented.
52+
* **word-separator** (default " "): Undocumented.
53+
54+
Example
55+
-------
56+
57+
```scheme
58+
(keepassxc-home
59+
  (keepassxc-configuration
60+
    (last-databases '("/data/alice/pass.kbdx"))
61+
    (last-dir "/data/alice")
62+
    (last-opened-databases '("/data/alice/pass.kbdx"))))
63+
```

home/keepassxc.scm unknown status 1

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)))))