linode-locke-lamora-current-config.scm 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. ;; this is the current configuration for my linode "Guix System"
  2. (add-to-load-path (dirname (current-filename)))
  3. (use-modules (gnu)
  4. (guix modules)
  5. (secret nginx)
  6. (public-keys)
  7. ;;(gnucode-form)
  8. (endlessh-service)
  9. ;;(opensmtpd-records)
  10. (gnu services mail)
  11. (opensmtpd)
  12. ;; ((gnu services mail)
  13. ;; #:hide (opensmtpd-configuration
  14. ;; opensmtpd-configuration?
  15. ;; opensmtpd-service-type
  16. ;; %default-opensmtpd-config-file))
  17. )
  18. (use-service-modules admin ; unattended-upgrades
  19. certbot
  20. ;; mail
  21. mcron
  22. messaging
  23. networking
  24. ssh
  25. vpn ;;wireguard
  26. web)
  27. (use-package-modules admin
  28. certs
  29. package-management
  30. ssh
  31. tls)
  32. (define %nginx-deploy-hook
  33. (program-file
  34. "nginx-deploy-hook"
  35. #~(let ((pid (call-with-input-file "/var/run/nginx/pid" read)))
  36. (kill pid SIGHUP))))
  37. (define %user "joshua")
  38. (operating-system
  39. (host-name "locke-lamora")
  40. (timezone "America/Chicago")
  41. (locale "en_US.UTF-8")
  42. ;; This goofy code will generate the grub.cfg
  43. ;; without installing the grub bootloader on disk.
  44. (bootloader (bootloader-configuration
  45. (bootloader
  46. (bootloader
  47. (inherit grub-bootloader)
  48. (installer #~(const #t))))))
  49. (file-systems (cons (file-system
  50. (device "/dev/sda")
  51. (mount-point "/")
  52. (type "ext4"))
  53. %base-file-systems))
  54. (swap-devices (list "/dev/sdb"))
  55. (initrd-modules (cons "virtio_scsi" ; Needed to find the disk
  56. %base-initrd-modules))
  57. (users (cons* (user-account
  58. (name "joshua")
  59. (group "users")
  60. ;; Adding the account to the "wheel" group
  61. ;; makes it a sudoer.
  62. (supplementary-groups '("wheel"))
  63. (home-directory "/home/joshua"))
  64. ;; (user-account
  65. ;; (name "vmail")
  66. ;; (group "vmail")
  67. ;; (home-directory "vmail")
  68. ;; (system? #t)
  69. ;; (comment "User that dovecot users to deliver emails
  70. ;; to /home/vmail/gnucode.me/joshua"))
  71. %base-user-accounts))
  72. ;; (groups (cons* (user-group
  73. ;; (name "vmail")
  74. ;; (system? #t))
  75. ;; %base-groups))
  76. (sudoers-file
  77. (plain-file "sudoers"
  78. (string-append (plain-file-content %sudoers-specification)
  79. (format #f "~a ALL = NOPASSWD: ALL~%"
  80. "joshua"))))
  81. (packages (cons* nss-certs ;for HTTPS access
  82. openssh-sans-x
  83. %base-packages))
  84. (services (cons*
  85. (service dhcp-client-service-type)
  86. (service certbot-service-type
  87. (certbot-configuration
  88. (email "jbranso@dismail.de")
  89. (webroot "/srv/www")
  90. (certificates
  91. (list
  92. (certificate-configuration
  93. (name "gnucode.me")
  94. (domains '("gnucode.me" "www.gnucode.me"
  95. "imap.gnucode.me"
  96. "smtp.gnucode.me"))
  97. (deploy-hook %nginx-deploy-hook))
  98. (certificate-configuration
  99. (name "gnu-hurd.com")
  100. (domains '("gnu-hurd.com" "www.gnu-hurd.com"))
  101. (deploy-hook %nginx-deploy-hook))
  102. (certificate-configuration
  103. (name "propernaming.org")
  104. (domains '("propernaming.org" "www.propernaming.org"))
  105. (deploy-hook %nginx-deploy-hook))
  106. ))))
  107. (dovecot-service #:config
  108. (dovecot-configuration
  109. (mail-location "maildir:/home/%n/Maildir")
  110. (protocols
  111. (list
  112. (protocol-configuration
  113. (name "imap")
  114. (mail-max-userip-connections 3))
  115. ;;(protocol-configuration name "lmtp")
  116. ))
  117. ;; I am hoping to set up LMTP, that way I can set up Sieve filtering.
  118. ;; https://doc.dovecot.org/configuration_manual/sieve/configuration/
  119. ;; https://doc.dovecot.org/configuration_manual/protocols/lmtp_server/#lmtp-server
  120. ;; (services
  121. ;; (list
  122. ;; (service-configuration
  123. ;; (kind "imap"))))
  124. ;; someone tries to login via joshua@gnucode.me
  125. ;; this strips away that login username to "joshua"
  126. ;; when I set up virtual users, I'll need to delete this!
  127. ;; https://wiki.dovecot.org/DomainLost
  128. ;; auth_username_format = %Ln
  129. ;; lowercases the username but also
  130. ;; drops the domain. Use
  131. ;; auth_username_format = %Lu instead.
  132. ;; (auth-username-format "%Ln")
  133. ;; for now just use the defaults...
  134. ;; (services
  135. ;; (list
  136. ;; (service-configuration
  137. ;; (kind "imap")
  138. ;; (client-limit 2))
  139. ;; (service-configuration
  140. ;; (kind "imap-login")
  141. ;; (clint-limit 2))
  142. ;; (service-configuration
  143. ;; (kind "auth")
  144. ;; (client-limit 2))
  145. ;; (service-configuration
  146. ;; (kind "auth-worker")
  147. ;; (client-limit 2))
  148. ;; (service-configuration
  149. ;; (kind "dict")
  150. ;; (client-limit 2)))
  151. ;; )
  152. ;; perhaps I DO NOT need to use letsencrypt certs...
  153. ;; because guix creates these certs for me by default in
  154. ;; /etc/dovecot/
  155. ;; I guess that I do need/want these certs. Otherwise dovecot
  156. ;; tries to connect to my server insecurely.
  157. ;; which means that I probably need to change my user joshua password
  158. ;; since I have been sending it insecurely!
  159. (ssl-cert "</etc/letsencrypt/live/gnucode.me/fullchain.pem")
  160. (ssl-key "</etc/letsencrypt/live/gnucode.me/privkey.pem")
  161. ))
  162. (service endlessh-service-type)
  163. ;;(service gnucode -form-service-type)
  164. (service mcron-service-type
  165. (mcron-configuration
  166. (jobs (list
  167. ;; run endlessh every 5 minutes
  168. #~(job "*/1 0 * * *"
  169. (string-append #$endlessh "/bin/endlessh -p 22")
  170. #:user "root")))))
  171. (let ([default-listen (list "80" "443 ssl http2"
  172. "[::]:80"
  173. "[::]:443 ssl http2")]
  174. [default-raw-content (list "add_header Strict-Transport-Security max-age=1800;")]
  175. [srv-root-dir "/srv/www/html/"]
  176. [letsencrypt-dir "/etc/letsencrypt/live/"]
  177. [letsencrypt-acme-challenge (nginx-location-configuration ;; for certbot
  178. (uri "/.well-known")
  179. (body (list "root /srv/www;")))])
  180. ;; make a pubnix nginx-servec-configuration
  181. ;; I can use this-operating-system ...read more about it in the manual.
  182. ;; then I can do something like: for all users, make gnucode.me/~<user>/ serve
  183. ;; their html files.
  184. (service nginx-service-type
  185. (nginx-configuration
  186. (server-blocks
  187. (list
  188. (nginx-server-configuration
  189. ;; perhaps make a macro for the next 6 lines:
  190. ;; (letsencrypt-certs "gnucode.me")
  191. ;; local.gnucode.me
  192. (server-name '("gnucode.me"))
  193. (listen default-listen)
  194. (root (string-append srv-root-dir "gnucode.me/site/"))
  195. (ssl-certificate (string-append letsencrypt-dir "gnucode.me/fullchain.pem"))
  196. (ssl-certificate-key (string-append letsencrypt-dir "gnucode.me/privkey.pem"))
  197. ;; tell browsers my site supports HTTPS, and tell them that it will
  198. ;; at least work for 1/2 hour. Gradually, I will increase this number.
  199. (raw-content default-raw-content)
  200. (locations
  201. (list
  202. letsencrypt-acme-challenge ;; for certbot
  203. (nginx-location-configuration
  204. (uri "/form/")
  205. (body '("proxy_pass http://127.0.0.1:8081;")))
  206. %secret-nginx-location
  207. )))
  208. (nginx-server-configuration
  209. (server-name '("gnu-hurd.com"))
  210. (listen default-listen)
  211. (root (string-append srv-root-dir "gnu-hurd.com/"))
  212. (ssl-certificate (string-append letsencrypt-dir "gnu-hurd.com/fullchain.pem"))
  213. (ssl-certificate-key (string-append letsencrypt-dir "gnu-hurd.com/privkey.pem"))
  214. ;; tell browsers my site supports HTTPS, and tell them that it will
  215. ;; at least work for 1/2 hour. Gradually, I will increase this number.
  216. (raw-content default-raw-content)
  217. (locations
  218. (list
  219. letsencrypt-acme-challenge ;; for certbot
  220. )))
  221. (nginx-server-configuration
  222. (server-name '("propernaming.org"))
  223. (listen default-listen)
  224. (root (string-append srv-root-dir "propernaming.org/site/"))
  225. (ssl-certificate (string-append letsencrypt-dir "propernaming.org/fullchain.pem"))
  226. (ssl-certificate-key (string-append letsencrypt-dir "propernaming.org/privkey.pem"))
  227. ;; tell browsers my site supports HTTPS, and tell them that it will
  228. ;; at least work for 1/2 hour. Gradually, I will increase this number.
  229. (raw-content default-raw-content)
  230. (locations
  231. (list
  232. letsencrypt-acme-challenge ;; for certbot
  233. )))
  234. )))))
  235. (service openssh-service-type
  236. (openssh-configuration
  237. (openssh openssh-sans-x)
  238. (password-authentication? #f)
  239. (port-number 63355)
  240. (authorized-keys
  241. `(
  242. ;; ("joshua" ,(local-file "/home/joshua/linode-guix-system-configuration/ssh-keys/joshua_id_rsa.pub"))
  243. ;; ("root" ,(local-file "/home/joshua/linode-guix-system-configuration/ssh-keys/joshua_id_rsa.pub"))
  244. ;; local file is simpler. I can get rid of (use-module (secret ssh-keys))
  245. ("joshua" ,(plain-file "id_rsa.pub" %joshua-ssh-key))
  246. ("root" ,(plain-file "id_rsa.pub" %joshua-ssh-key))
  247. ))))
  248. ;; I've created the prosody admin user, and I imported the cert...
  249. ;; but pidgin tells me that I the XMPP server at gnucode.me does not support encryption.
  250. (service prosody-service-type
  251. (prosody-configuration
  252. ;;(certificates "/etc/")
  253. (admins '("jbranso@gnucode.me"))
  254. (virtualhosts
  255. (list
  256. (virtualhost-configuration
  257. (domain "gnucode.me"))))))
  258. (service mail-aliases-service-type
  259. '(("webmaster" "root")
  260. ("postmaster" "root")
  261. ("abuse" "root")))
  262. ;; I can test send an email from my ssh machine via:
  263. ;; cat test-email.txt | msmtp -- jbranso@dismail.de
  264. (service opensmtpd-service-type
  265. (opensmtpd-configuration
  266. (config-file %smtpd.conf)))
  267. ;; (service opensmtpd-service-type
  268. ;; (opensmtpd-configuration
  269. ;; (pkis (list
  270. ;; (opensmtpd-pki
  271. ;; (domain "smtp.gnucode.me")
  272. ;; (cert "/etc/letsencrypt/live/gnucode.me/fullchain.pem")
  273. ;; (key "/etc/letsencrypt/live/gnucode.me/privkey.pem"))))
  274. ;; (tables (list
  275. ;; (opensmtpd-table
  276. ;; (name "aliases")
  277. ;; (values
  278. ;; (list
  279. ;; (cons "webmaster" "root")
  280. ;; (cons "postmaster" "root")
  281. ;; (cons "abuse" "root"))))
  282. ;; (opensmtpd-table
  283. ;; (name "creds")
  284. ;; (values
  285. ;; (list
  286. ;; (cons "joshua"
  287. ;; "$6$Ec4m8FgKjT2F/03Y$k66ABdse9TzCX6qaALB3WBL9GC1rmAWJmaoSjFMpbhzat7DOpFqpnOwpbZ34wwsQYIK8RQlqwM1I/v6vsRq86."))))
  288. ;; (opensmtpd-table
  289. ;; (name "vdoms")
  290. ;; (values (list "gnucode.me"
  291. ;; "gnu-hurd.com")))
  292. ;; (opensmtpd-table
  293. ;; (name "vusers")
  294. ;; (values (list (cons "joshua@gnucode.me" "joshua")
  295. ;; (cons "jbranso@gnucode.me" "joshua")
  296. ;; (cons "postmaster@gnucode.me" "joshua"))))))
  297. ;; (listen-ons
  298. ;; (list
  299. ;; ;; this forum help suggests that I listen on 0.0.0.0 and NOT eth0
  300. ;; ;; https://serverfault.com/questions/726795/opensmtpd-wont-work-at-reboot
  301. ;; ;; this listens for email from the outside world
  302. ;; (opensmtpd-listen-on
  303. ;; (interface "eth0")
  304. ;; (port 25)
  305. ;; (secure-connection "tls")
  306. ;; (pki "smtp.gnucode.me"))
  307. ;; ;; this lets local users logged into the system via ssh send email
  308. ;; (opensmtpd-listen-on
  309. ;; (interface "lo")
  310. ;; (port 25)
  311. ;; (secure-connection "tls")
  312. ;; (pki "smtp.gnucode.me"))
  313. ;; (opensmtpd-listen-on
  314. ;; (interface "eth0")
  315. ;; (port 465)
  316. ;; (secure-connection "smtps")
  317. ;; (pki "smtp.gnucode.me")
  318. ;; (auth "creds")
  319. ;; (filter "dkimsign"))
  320. ;; (opensmtpd-listen-on
  321. ;; (interface "eth0")
  322. ;; (port 587)
  323. ;; (secure-connection "tls-require")
  324. ;; (pki "smtp.gnucode.me")
  325. ;; (auth "creds")
  326. ;; (filter "dkimsign"))))
  327. ;; (actions
  328. ;; (list
  329. ;; (opensmtpd-action
  330. ;; (name "receive")
  331. ;; (method
  332. ;; (opensmtpd-local-delivery-configuration
  333. ;; (method (opensmtpd-maildir-configuration
  334. ;; (pathname "/home/%{rcpt.user}/Maildir")
  335. ;; (junk #t)))
  336. ;; (virtual "vusers"))))
  337. ;; (opensmtpd-action
  338. ;; (name "send")
  339. ;; (method (opensmtpd-relay-configuration)))))
  340. ;; (matches (list
  341. ;; (opensmtpd-match
  342. ;; (name "send")
  343. ;; (for "for any")
  344. ;; (from "from any")
  345. ;; (auth #t))
  346. ;; (opensmtpd-match
  347. ;; (name "receive")
  348. ;; (from "from any")
  349. ;; (for "for domain <vdoms>"))
  350. ;; (opensmtpd-match
  351. ;; (name "receive")
  352. ;; (for "for local"))))))
  353. (service unattended-upgrade-service-type)
  354. ;; (service wireguard-service-type
  355. ;; (wireguard-configuration
  356. ;; (private-key "/home/joshua/linode-guix-system-configuration/wireguard-keys/server.private.key")
  357. ;; (peers
  358. ;; (list
  359. ;; (wireguard-peer
  360. ;; (name "my servers peer for my laptop")
  361. ;; (public-key "/home/joshua/linode-guix-system-configuration/wireguard-keys/laptop.pub"))))))
  362. %base-services)))