summaryrefslogtreecommitdiff
path: root/users/id1000.scm
blob: c4d0ceac27fd9bbe0578e339511901af61eea6c1 (about) (plain)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
(define-module (users id1000)
  ;; home-environment
  #:use-module (gnu home)

  ;; home-profile-service-type
  ;; home-xdg-configuration-files-service-type
  #:use-module (gnu home services)

  ;; gparted
  #:use-module (gnu packages disk)

  ;; emacs
  #:use-module (gnu packages emacs)

  ;; emacs-org-roam
  ;; emacs-paredit
  #:use-module (gnu packages emacs-xyz)

  ;; git
  #:use-module (gnu packages version-control)

  ;; simple-service
  #:use-module (gnu services)

  ;; user-account
  #:use-module (gnu system shadow)

  ;; local-file
  #:use-module (guix gexp)

  ;; %suweren-home-services
  #:use-module (suweren home))

(define dovecot-imap-login-inet-configuration
  ((@ (gnu services mail)
      inet-listener-configuration)
   (address "192.168.10.2")
   (port 993)
   (protocol "imaps")))

(define dovecot-lmtp-inet-configuration
  ((@ (gnu services mail)
      inet-listener-configuration)
   (address "192.168.10.2 127.0.0.1")
   (port 24)
   (protocol "lmtp")))

(define dovecot-lmtp-unix-configuration
  ((@ (gnu services mail)
      unix-listener-configuration)
   (group "vmail")
   (mode "0666")
   (path "lmtp")
   (user "vmail")))

(define mailbox-marekpasnikowski-archive
  ((@ (gnu services mail)
      mailbox-configuration)
   (name "Archive")
   (auto "subscribe")
   (special-use (list "\\Archive"))))

(define mailbox-marekpasnikowski-drafts
  ((@ (gnu services mail)
      mailbox-configuration)
   (name "Drafts")
   (auto "subscribe")
   (special-use (list "\\Drafts"))))

(define mailbox-marekpasnikowski-junk
  ((@ (gnu services mail)
      mailbox-configuration)
   (name "Junk")
   (auto "subscribe")
   (special-use (list "\\Junk"))))

(define mailbox-marekpasnikowski-sent
  ((@ (gnu services mail)
      mailbox-configuration)
   (name "Sent")
   (auto "subscribe")
   (special-use (list "\\Sent"))))

(define mailbox-marekpasnikowski-trash
  ((@ (gnu services mail)
      mailbox-configuration)
   (name "Trash")
   (auto "subscribe")
   (special-use (list "\\Trash"))))

;;;

(define dovecot-imap
  ((@ (gnu services mail)
      protocol-configuration)
   (name "imap")))

(define dovecot-imap-login-configuration
  ((@ (gnu services mail)
      service-configuration)
   (kind "imap-login")
   (listeners (list dovecot-imap-login-inet-configuration))))

(define dovecot-lmtp
  ((@ (gnu services mail)
      protocol-configuration)
   (name "lmtp")))

(define dovecot-lmtp-configuration
  ((@ (gnu services mail)
      service-configuration)
   (kind "lmtp")
   (listeners (list dovecot-lmtp-inet-configuration
		    dovecot-lmtp-unix-configuration))))

(define dovecot-passwd-file
  ((@ (gnu services mail)
      passdb-configuration)
   (args (list "username_format=%n"
	       "/secrets/dovecot"))
   (driver "passwd-file")))

(define dovecot-namespace-marekpasnikowski
  ((@ (gnu services mail)
      namespace-configuration)
   (name "inbox")
   (inbox? #t)
   (mailboxes (list mailbox-marekpasnikowski-archive
		    mailbox-marekpasnikowski-drafts
		    mailbox-marekpasnikowski-junk
		    mailbox-marekpasnikowski-sent
		    mailbox-marekpasnikowski-trash))))

(define dovecot-userdb-static-configuration
  ((@ (gnu services mail)
      userdb-configuration)
   (args (list "gid=vmail"
	       "home=/home/vmail/%n"
	       "uid=vmail"))
   (driver "static")))

(define ssl-cert-path
  (string-append "</etc/letsencrypt/live/"
		 "marekpasnikowski.pl"
		 "/fullchain.pem"))

(define ssl-key-path
  (string-append "</etc/letsencrypt/live/"
		 "marekpasnikowski.pl"
		 "privkey.pem"))

;;;

(define dovecot-configuration*
  ((@ (gnu services mail)
      dovecot-configuration)
   (disable-plaintext-auth? #t)
   (mail-location "maildir:~/Maildir")
   (namespaces (list dovecot-namespace-marekpasnikowski))
   (passdbs (list dovecot-passwd-file))
   (protocols (list dovecot-imap
		    dovecot-lmtp))
   (services (list dovecot-lmtp-configuration
		   dovecot-imap-login-configuration))
   (ssl? "required")
   (ssl-cert ssl-cert-path)
   (ssl-key ssl-key-path)
   (ssl-min-protocol "TLSv1.2")
   (userdbs (list dovecot-userdb-static-configuration))))

(define groups
  (list "kvm"
	"wheel"))

;;;

(define-public dovecot-service
  (service (@ (gnu services mail)
	      dovecot-service-type)
	   dovecot-configuration*))

(define-public uid1000-name
  "marek")

(define-public uid1000-account
  (user-account (name uid1000-name)
		(group "users")
		(supplementary-groups groups)
		(uid 1000)
		(comment "Marek Paśnikowski")
		(home-directory "/home/marek")))

(define-public uid1000-home-environment
  (lambda (host-name*)
    (let* ((gitconfig-file (local-file "uid1000-gitconfig")) ; TODO modularize
	   (gitignore-file (local-file "uid1000-gitignore")) ; TODO review the contents

	   (gitconfig (list "git/config"
			    gitconfig-file))
	   (gitignore (list "git/ignore"
			    gitignore-file))

	   (emacs-packages (list emacs
				 emacs-org-roam
				 emacs-paredit))
	   (git-configuration-files (list gitconfig
					  gitignore))
	   (git-packages (list git))
	   (packages (list gparted))

	   (emacs-software (simple-service 'emacs-packages
					   home-profile-service-type
					   emacs-packages))
	   (git-configuration (simple-service 'git-configuration
					      home-xdg-configuration-files-service-type
					      git-configuration-files))
	   (git-software (simple-service 'git-packages
					 home-profile-service-type
					 git-packages))
	   (profile (simple-service 'user-packages
				    home-profile-service-type
				    packages))

	   (%suweren-home-services* (%suweren-home-services host-name*))
	   (user-services (list emacs-software
				git-configuration
				git-software
				profile))

	   (services* (append %suweren-home-services*
			      user-services)))
      (home-environment (services services*)))))