system-configuration/systems/ene.scm

ene.scm

1
;;; Tyreunom's system administration and configuration tools.
2
;;;
3
;;; Copyright © 2019, 2020 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 version-control))
26
(use-modules (gnu services web))
27
(use-modules (gnu system))
28
29
(use-modules (gnu packages libunwind))
30
(use-modules (gnu packages mail))
31
(use-modules (gnu packages web))
32
(use-modules (guix packages))
33
(use-modules (guix utils))
34
35
(use-modules (config certbot) (config dns) (config iptables)
36
             (config mail) (config os) (config static-web)
37
	     (services gitile) (packages gitile))
38
39
;; Copy from (gnu bootloader u-boot)
40
(define install-allwinner-u-boot
41
  #~(lambda (bootloader device mount-point)
42
      (let ((u-boot (string-append bootloader
43
                                   "/libexec/u-boot-sunxi-with-spl.bin")))
44
        (write-file-on-device u-boot (stat:size (stat u-boot))
45
                              device (* 8 1024)))))
46
47
(define u-boot-cubietruck-bootloader
48
  (bootloader
49
    (inherit u-boot-bootloader)
50
    (package u-boot-cubietruck)
51
    (installer install-allwinner-u-boot)))
52
53
(operating-system
54
  (inherit (tyreunom-os "ene"))
55
  (bootloader
56
    (bootloader-configuration
57
      (target "/dev/mmcblk0")
58
      (bootloader u-boot-cubietruck-bootloader)))
59
  (initrd-modules (cons* "sunxi-mmc" "sd_mod" "ahci_sunxi" %base-initrd-modules))
60
  (file-systems (cons (file-system
61
                        (mount-point "/")
62
                        (device "/dev/sda1")
63
                        (type "ext4"))
64
                      %base-file-systems))
65
  (services
66
    (append
67
      (list
68
        (service dhcp-client-service-type)
69
        lepiller-iptables-service
70
        (agetty-service
71
          (agetty-configuration
72
            (extra-options '("-L"))
73
            (baud-rate "115200")
74
            (term "vt100")
75
            (tty "ttyS0")))
76
        (service tor-service-type)
77
        (tor-hidden-service "mail"
78
                            '((25 "127.0.0.1:25")
79
                              (143 "127.0.0.1:143")
80
                              (587 "127.0.0.1:587")
81
                              (993 "127.0.0.1:993")))
82
        (service knot-service-type
83
                 (knot-configuration
84
                   (includes '("/etc/knot/secrets.conf"))
85
                   (acls (list master-acl))
86
                   (remotes (list hermes))
87
                   (zones (list lepiller-master-zone
88
                                ipv4-reverse-master-zone
89
                                ipv6-reverse-master-zone))))
90
        (certbot-service `(("courriel.lepiller.eu" "imap.lepiller.eu")
91
                           ("ene.lepiller.eu" "rennes.lepiller.eu")
92
                           ("avatar.lepiller.eu")
93
                           ("git.lepiller.eu")))
94
        (service nginx-service-type)
95
        (service php-fpm-service-type)
96
        (service fcgiwrap-service-type
97
                 (fcgiwrap-configuration
98
                   (group "git")))
99
        (cat-avatar-generator-service
100
          #:configuration
101
          (nginx-server-configuration
102
            (server-name '("avatar.lepiller.eu"))
103
            (ssl-certificate
104
              "/etc/letsencrypt/live/avatar.lepiller.eu/fullchain.pem")
105
            (ssl-certificate-key
106
              "/etc/letsencrypt/live/avatar.lepiller.eu/privkey.pem")
107
            (listen '("443 ssl http2" "[::]:443 ssl http2"))))
108
        (simple-service 'default-http-server nginx-service-type
109
          (list (nginx-server-configuration
110
                  (ssl-certificate
111
                    "/etc/letsencrypt/live/ene.lepiller.eu/fullchain.pem")
112
                  (ssl-certificate-key
113
                    "/etc/letsencrypt/live/ene.lepiller.eu/privkey.pem")
114
                  (listen '("443 ssl http2" "[::]:443 ssl http2"))
115
                  (server-name '(default))(root "/srv/http/default"))))
116
	(service gitile-service-type)
117
        (simple-service 'git-server nginx-service-type
118
          (list (nginx-server-configuration
119
                  (ssl-certificate
120
                    "/etc/letsencrypt/live/git.lepiller.eu/fullchain.pem")
121
                  (ssl-certificate-key
122
                    "/etc/letsencrypt/live/git.lepiller.eu/privkey.pem")
123
                  (listen '("443 ssl http2" "[::]:443 ssl http2"))
124
                  (server-name '("git.lepiller.eu"))
125
                  (root "/srv/http/git/public")
126
                  (locations
127
                    (append
128
                      (list
129
                        (git-http-nginx-location-configuration
130
                          (git-http-configuration
131
                            (uri-path "/git/")
132
                            (git-root "/var/lib/gitolite/repositories")))
133
                        (nginx-location-configuration
134
                          (uri "/")
135
                          (body
136
                            (list
137
                              "proxy_pass http://127.0.0.1:8080/;"))))
138
                      (map
139
                        (lambda (loc)
140
                          (nginx-location-configuration
141
                            (uri loc)
142
                            (body
143
                              (list
144
                                "root /srv/http/git/public;"))))
145
                        '("/css" "/images" "~* .*/manual/.*" "= /"
146
                          "= /index.html")))))))
147
        (service static-web-site-service-type
148
                 (static-web-site-configuration
149
                  (git-url "https://git.lepiller.eu/git/guile-netlink")
150
                  (git-ref '(branch . "master"))
151
                  (directory "/srv/http/git/guile-netlink-manual")
152
                  (build-file "doc/build.scm")))
153
        ;; on activation, gitolite chmods its home directory to #o700, disabling
154
        ;; access to git-http-backend.  Re-enable that access.
155
        (simple-service 'gitolite-home-permissions
156
                        activation-service-type
157
                        #~(chmod "/var/lib/gitolite" #o750))
158
        (service gitolite-service-type
159
          (gitolite-configuration
160
            (admin-pubkey (local-file "../keys/tyreunom.pub"))
161
            (rc-file
162
              (gitolite-rc-file
163
                (umask #o0027)
164
                (git-config-keys "gitweb.*"))))))
165
      (modify-services
166
        (lepiller-mail-services
167
          #:interface "eth0"
168
          #:domain "courriel.lepiller.eu")
169
        (dovecot-service-type config =>
170
         (dovecot-configuration
171
           (inherit config)
172
           (dovecot (package
173
                      (inherit dovecot)
174
                      (arguments
175
                        `(#:tests? #f
176
                          ,@(package-arguments dovecot))))))))
177
      (server-services "ene"))))
178