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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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. ;; (secret public-keys)
  7. ;;(gnucode-form)
  8. (endlessh-service)
  9. (dkimproxy)
  10. (opensmtpd))
  11. (use-service-modules admin ; unattended-upgrades
  12. certbot
  13. mail
  14. mcron
  15. messaging
  16. networking
  17. ssh
  18. vpn ;;wireguard
  19. web)
  20. (use-package-modules admin
  21. certs
  22. package-management
  23. ssh
  24. tls)
  25. (define %nginx-deploy-hook
  26. (program-file
  27. "nginx-deploy-hook"
  28. #~(let ((pid (call-with-input-file "/var/run/nginx/pid" read)))
  29. (kill pid SIGHUP))))
  30. (define %user "joshua")
  31. (operating-system
  32. (host-name "locke-lamora")
  33. (timezone "America/Chicago")
  34. (locale "en_US.UTF-8")
  35. ;; This goofy code will generate the grub.cfg
  36. ;; without installing the grub bootloader on disk.
  37. (bootloader (bootloader-configuration
  38. (bootloader
  39. (bootloader
  40. (inherit grub-bootloader)
  41. (installer #~(const #t))))))
  42. (file-systems (cons (file-system
  43. (device "/dev/sda")
  44. (mount-point "/")
  45. (type "ext4"))
  46. %base-file-systems))
  47. (swap-devices (list "/dev/sdb"))
  48. (initrd-modules (cons "virtio_scsi" ; Needed to find the disk
  49. %base-initrd-modules))
  50. (users (cons* (user-account
  51. (name "joshua")
  52. (group "users")
  53. ;; Adding the account to the "wheel" group
  54. ;; makes it a sudoer.
  55. (supplementary-groups '("wheel"))
  56. (home-directory "/home/joshua"))
  57. ;; (user-account
  58. ;; (name "vmail")
  59. ;; (group "vmail")
  60. ;; (home-directory "vmail")
  61. ;; (system? #t)
  62. ;; (comment "User that dovecot users to deliver emails
  63. ;; to /home/vmail/gnucode.me/joshua"))
  64. %base-user-accounts))
  65. ;; (groups (cons* (user-group
  66. ;; (name "vmail")
  67. ;; (system? #t))
  68. ;; %base-groups))
  69. (sudoers-file
  70. (plain-file "sudoers"
  71. (string-append (plain-file-content %sudoers-specification)
  72. (format #f "~a ALL = NOPASSWD: ALL~%"
  73. "joshua"))))
  74. (packages (cons* nss-certs ;for HTTPS access
  75. openssh-sans-x
  76. %base-packages))
  77. (services (cons*
  78. (service dhcp-client-service-type)
  79. (service certbot-service-type
  80. (certbot-configuration
  81. (email "jbranso@dismail.de")
  82. (webroot "/srv/www")
  83. (certificates
  84. (list
  85. (certificate-configuration
  86. (name "gnucode.me")
  87. (domains '("gnucode.me" "www.gnucode.me"
  88. "mail.gnucode.me" "imap.gnucode.me"
  89. "smtp.gnucode.me" "wireguard.gnucode.me"))
  90. (deploy-hook %nginx-deploy-hook))
  91. (certificate-configuration
  92. (name "gnu-hurd.com")
  93. (domains '("gnu-hurd.com" "www.gnu-hurd.com"))
  94. (deploy-hook %nginx-deploy-hook))
  95. (certificate-configuration
  96. (name "propernaming.org")
  97. (domains '("propernaming.org" "www.propernaming.org"))
  98. (deploy-hook %nginx-deploy-hook))
  99. ))))
  100. (dovecot-service #:config
  101. (dovecot-configuration
  102. (mail-location "maildir:/home/%n/Maildir")
  103. (protocols
  104. (list
  105. (protocol-configuration
  106. (name "imap")
  107. (mail-max-userip-connections 3))))
  108. ;; someone tries to login via joshua@gnucode.me
  109. ;; this strips away that login username to "joshua"
  110. ;; when I set up virtual users, I'll need to delete this!
  111. ;; https://wiki.dovecot.org/DomainLost
  112. ;; auth_username_format = %Ln
  113. ;; lowercases the username but also
  114. ;; drops the domain. Use
  115. ;; auth_username_format = %Lu instead.
  116. ;; (auth-username-format "%Ln")
  117. ;; for now just use the defaults...
  118. ;; (services
  119. ;; (list
  120. ;; (service-configuration
  121. ;; (kind "imap")
  122. ;; (client-limit 2))
  123. ;; (service-configuration
  124. ;; (kind "imap-login")
  125. ;; (clint-limit 2))
  126. ;; (service-configuration
  127. ;; (kind "auth")
  128. ;; (client-limit 2))
  129. ;; (service-configuration
  130. ;; (kind "auth-worker")
  131. ;; (client-limit 2))
  132. ;; (service-configuration
  133. ;; (kind "dict")
  134. ;; (client-limit 2)))
  135. ;; )
  136. ;; perhaps I DO NOT need to use letsencrypt certs...
  137. ;; because guix creates these certs for me by default in
  138. ;; /etc/dovecot/
  139. ;; (ssl-cert "/etc/letsencrypt/live/gnucode.me/fullchain.pem")
  140. ;; (ssl-key "/etc/letsencrypt/live/gnucode.me/privkey.pem")
  141. ))
  142. (service endlessh-service-type)
  143. ;;(service gnucode -form-service-type)
  144. (service mcron-service-type
  145. (mcron-configuration
  146. (jobs (list
  147. ;; run endlessh every 5 minutes
  148. #~(job "*/1 0 * * *"
  149. (string-append #$endlessh "/bin/endlessh -p 22")
  150. #:user "root")))))
  151. (service nginx-service-type
  152. (nginx-configuration
  153. (server-blocks
  154. (list
  155. (nginx-server-configuration
  156. (server-name '("gnucode.me"))
  157. (listen '("80" "443 ssl http2"
  158. "[::]:80" "[::]:443 ssl http2"))
  159. (root "/srv/www/html/gnucode.me/site/")
  160. ;; tell browsers my site supports HTTPS, and tell them that it will
  161. ;; at least work for 1/2 hour. Gradually, I will increase this number.
  162. (ssl-certificate "/etc/letsencrypt/live/gnucode.me/fullchain.pem")
  163. (ssl-certificate-key "/etc/letsencrypt/live/gnucode.me/privkey.pem")
  164. (raw-content (list "add_header Strict-Transport-Security max-age=1800;"))
  165. (locations
  166. (list
  167. (nginx-location-configuration ;certbot
  168. (uri "/.well-known")
  169. (body (list "root /srv/www;")))
  170. (nginx-location-configuration
  171. (uri "/form/")
  172. (body '("proxy_pass http://127.0.0.1:8081;")))
  173. %secret-nginx-location
  174. )))
  175. (nginx-server-configuration
  176. (server-name '("gnu-hurd.com"))
  177. (listen '("80" "443 ssl"))
  178. (root "/srv/www/html/gnu-hurd.com/")
  179. (ssl-certificate "/etc/letsencrypt/live/gnu-hurd.com/fullchain.pem")
  180. (ssl-certificate-key "/etc/letsencrypt/live/gnu-hurd.com/privkey.pem")
  181. ;; tell browsers my site supports HTTPS, and tell them that it will
  182. ;; at least work for 1/2 hour. Gradually, I will increase this number.
  183. (raw-content (list "add_header Strict-Transport-Security max-age=1800;"))
  184. (locations
  185. (list
  186. (nginx-location-configuration ;certbot
  187. (uri "/.well-known")
  188. (body (list "root /srv/www;"))))))
  189. (nginx-server-configuration
  190. (server-name '("propernaming.org"))
  191. (listen '("80" "443 ssl"))
  192. (root "/srv/www/html/propernaming.org/site/")
  193. (ssl-certificate "/etc/letsencrypt/live/propernaming.org/fullchain.pem")
  194. (ssl-certificate-key "/etc/letsencrypt/live/propernaming.org/privkey.pem")
  195. ;; tell browsers my site supports HTTPS, and tell them that it will
  196. ;; at least work for 1/2 hour. Gradually, I will increase this number.
  197. (raw-content (list "add_header Strict-Transport-Security max-age=1800;"))
  198. (locations
  199. (list
  200. (nginx-location-configuration ;certbot
  201. (uri "/.well-known")
  202. (body (list "root /srv/www;"))))))
  203. ))))
  204. (service openssh-service-type
  205. (openssh-configuration
  206. (openssh openssh-sans-x)
  207. (password-authentication? #f)
  208. (port-number 63355)
  209. (authorized-keys
  210. `(
  211. ("joshua" ,(local-file "/home/joshua/linode-guix-system-configuration/ssh-keys/joshua_id_rsa.pub"))
  212. ("root" ,(local-file "/home/joshua/linode-guix-system-configuration/ssh-keys/joshua_id_rsa.pub"))
  213. ;; local file is simpler. I can get rid of (use-module (secret ssh-keys))
  214. ;; ("joshua" ,(plain-file "id_rsa.pub" %joshua-ssh-key))
  215. ;;("root" ,(local-file "/home/joshua/linode-guix-system-configuration/id_rsa.pub"))
  216. ))))
  217. ;; I've created the prosody admin user, and I imported the cert...
  218. ;; but pidgin tells me that I the XMPP server at gnucode.me does not support encryption.
  219. (service prosody-service-type
  220. (prosody-configuration
  221. (admins '("jbranso@dismail.de"))
  222. (virtualhosts
  223. (list
  224. (virtualhost-configuration
  225. (domain "gnucode.me"))))))
  226. (service mail-aliases-service-type
  227. '(("webmaster" "root")
  228. ("postmaster" "root")
  229. ("abuse" "root")))
  230. ;; I can test send an email from my ssh machine via:
  231. ;; cat test-email.txt | msmtp -- jbranso@dismail.de
  232. (service opensmtpd-service-type
  233. (opensmtpd-configuration
  234. (config-file %smtpd.conf)))
  235. (service dkimproxy-out-service-type
  236. (dkimproxy-out-configuration
  237. (listen "127.0.0.1:10027")
  238. (relay "127.0.0.1:10028")
  239. (sender-map
  240. `(("gnucode.me"
  241. (,(dkimproxy-out-signature-configuration
  242. (type 'dkim)
  243. ;; has to be a absolute path or it won't work.
  244. ;; DO NOT use (key (local-file "./relative/path/key") that means anyone can read the key file.
  245. (key "/home/joshua/linode-guix-system-configuration/email-dkim-ssh-keys/20201004-gnucode.me.key")
  246. ;; let's assume my key will work with the below
  247. (algorithm "rsa-sha256")
  248. (method "relaxed")
  249. (selector "dkim"))
  250. ,(dkimproxy-out-signature-configuration
  251. (type 'domainkeys)
  252. (method "nofws"))))))))
  253. (service unattended-upgrade-service-type)
  254. ;; (service wireguard-service-type
  255. ;; (wireguard-configuration
  256. ;; (private-key "/home/joshua/linode-guix-system-configuration/wireguard-keys/privatekey")
  257. ;; (peers
  258. ;; (list
  259. ;; (wireguard-peer
  260. ;; (name "my servers peer for my laptop")
  261. ;; (public-key ""))))))
  262. %base-services)))