system-configuration/systems/ene.scm

ene.scm

1
;;; Tyreunom's system administration and configuration tools.
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
(use-modules (gnu))
19
(use-modules (gnu bootloader))
20
(use-modules (gnu bootloader u-boot))
21
(use-modules (gnu packages bootloaders))
22
(use-modules (gnu services dns))
23
(use-modules (gnu services mail))
24
(use-modules (gnu services networking))
25
(use-modules (gnu services web))
26
(use-modules (gnu system))
27
28
(use-modules (gnu packages libunwind))
29
(use-modules (gnu packages mail))
30
(use-modules (gnu packages web))
31
(use-modules (guix packages))
32
(use-modules (guix utils))
33
34
(use-modules (config certbot) (config dns) (config iptables)
35
	     (config mail) (config os))
36
37
;; Copy from (gnu bootloader u-boot)
38
(define install-allwinner-u-boot
39
  #~(lambda (bootloader device mount-point)
40
      (let ((u-boot (string-append bootloader
41
                                   "/libexec/u-boot-sunxi-with-spl.bin")))
42
        (write-file-on-device u-boot (stat:size (stat u-boot))
43
                              device (* 8 1024)))))
44
45
(define u-boot-cubietruck-bootloader
46
  (bootloader
47
    (inherit u-boot-bootloader)
48
    (package u-boot-cubietruck)
49
    (installer install-allwinner-u-boot)))
50
51
(operating-system
52
  (inherit (tyreunom-os "ene"))
53
  (bootloader
54
    (bootloader-configuration
55
      (target "/dev/mmcblk0")
56
      (bootloader u-boot-cubietruck-bootloader)))
57
  (initrd-modules (cons* "sunxi-mmc" "sd_mod" "ahci_sunxi" %base-initrd-modules))
58
  (file-systems (cons (file-system
59
                        (mount-point "/")
60
                        (device "/dev/sda1")
61
                        (type "ext4"))
62
                      %base-file-systems))
63
  (services
64
    (append
65
      (list
66
        (service dhcp-client-service-type)
67
        lepiller-iptables-service
68
        (agetty-service
69
          (agetty-configuration
70
            (extra-options '("-L"))
71
            (baud-rate "115200")
72
            (term "vt100")
73
            (tty "ttyS0")))
74
        (service nginx-service-type)
75
        (service knot-service-type
76
                 (knot-configuration
77
                   (includes '("/etc/knot/secrets.conf"))
78
                   (acls (list master-acl))
79
                   (remotes (list hermes))
80
                   (zones (list lepiller-master-zone
81
                                ipv4-reverse-master-zone
82
                                ipv6-reverse-master-zone))))
83
        (certbot-service `(("courriel.lepiller.eu" "imap.lepiller.eu")
84
                           ("ene.lepiller.eu" "rennes.lepiller.eu")
85
                           ("avatar.lepiller.eu")))
86
        (service php-fpm-service-type)
87
        (cat-avatar-generator-service
88
          #:configuration
89
          (nginx-server-configuration
90
            (server-name '("avatar.lepiller.eu"))
91
            (ssl-certificate "/etc/letsencrypt/live/avatar.lepiller.eu/fullchain.pem")
92
            (ssl-certificate-key "/etc/letsencrypt/live/avatar.lepiller.eu/privkey.pem")
93
            (listen '("443 ssl http2" "[::]:443 ssl http2"))))
94
        (simple-service 'default-http-server nginx-service-type
95
          (list (nginx-server-configuration
96
                  (ssl-certificate "/etc/letsencrypt/live/ene.lepiller.eu/fullchain.pem")
97
                  (ssl-certificate-key "/etc/letsencrypt/live/ene.lepiller.eu/privkey.pem")
98
                  (listen '("443 ssl http2" "[::]:443 ssl http2"))
99
                  (server-name '(default))(root "/srv/http/default")))))
100
      (modify-services
101
        (lepiller-mail-services
102
          #:interface "eth0"
103
          #:domain "courriel.lepiller.eu")
104
        (dovecot-service-type
105
          config =>
106
          (dovecot-configuration
107
            (inherit config)
108
            (dovecot
109
              (package
110
                (inherit dovecot)
111
		(arguments
112
		  (append `(#:tests? #f) (package-arguments dovecot))))))))
113
      (server-services "ene"))))
114