summaryrefslogtreecommitdiffstats
path: root/ftp.replicant.us_stage1.scm
blob: 98db9b0bcb44d403cb4b1bf4ae1bd0ca467f0e26 (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
;; TODO before migration
;; - Change the IP address
;; - Change the domain name with the certificates

(use-modules (gnu))
(use-service-modules certbot networking ssh web)
(use-package-modules admin base emacs rsync screen tls version-control vim web)

;; Variables specific to the vm
;; Change them when deploying this configuration in production
(define %vm-domain-name "ftp.replicant.cyberdimension.org")
(define %ethernet-interface-name "eth0")
(define %ipv4-interface-address "192.168.10.43")
(define %ipv4-interface-netmask "255.255.255.0")
(define %ipv4-interface-gateway "192.168.10.1")
(define %ipv4-interface-dns1 "192.168.10.1")
(define %ipv4-interface-dns2 "192.168.10.1")
(define %ipv6-interface-address "2001:910:1314:ffff:ffff::43/80")
(define %ipv6-interface-gateway "2001:910:1314:ffff:ffff::1")

;; Hack to Add IPv6 support
(define %ip-prog "/run/current-system/profile/sbin/ip")
(system* %ip-prog "addr" "add" %ipv6-interface-address "dev" %ethernet-interface-name)
(system* %ip-prog "route" "add" "default" "via" %ipv6-interface-gateway)

(define %nginx-deploy-hook
  (program-file
   "nginx-deploy-hook"
   #~(let ((pid (call-with-input-file "/var/run/nginx/pid" read)))
       (kill pid SIGHUP))))

(operating-system
 (host-name %vm-domain-name)
 (locale "en_US.utf8")
 (timezone "America/New_York")
 (bootloader
  (bootloader-configuration
   (bootloader grub-bootloader)
   (target "/dev/vda")))
 (file-systems
  (cons* (file-system
	  (mount-point "/")
	  (device
	   (uuid "b1ecb69d-4bb6-4bcf-9ab6-6a4d40c227f8"
		 'ext4))
	  (type "ext4"))
	 %base-file-systems))

 (users (cons* (user-account
		(name "gnutoo")
		(comment "GNUtoo")
		(group "users")
		(home-directory "/home/gnutoo")
		(supplementary-groups
		 '("wheel")))
	       (user-account
		(name "putti")
		(comment "Putti")
		(group "users")
		(home-directory "/home/putti")
		(supplementary-groups
		 '("wheel")))
	       %base-user-accounts))
 (packages
  (append
   (list (specification->package "nss-certs")
	 certbot
	 emacs-no-x
	 git
	 htop
	 rsync
	 screen
	 vim)
   %base-packages))
 (services
  (append
   (list (service openssh-service-type
		  (openssh-configuration
		   (port-number 222)
		   (permit-root-login #t)
		   (password-authentication? #f)
		   (challenge-response-authentication? #f)
		   (authorized-keys
		    `(("root", (local-file "keys/gnutoo.pub"),
		       (local-file "keys/putti.pub"))
		      ("gnutoo", (local-file "keys/gnutoo.pub"))
		      ("putti", (local-file "keys/putti.pub"))
		      )
		    )
		   (use-pam? #f)))

	 ;; A public IP address is needed to test that configuration file as
	 ;; things like letsencrypt depends on it.
	 ;; The vm will have a public IPv4 IP address when deployed, however
	 ;; for testing we still need some sort of public IP address.
	 ;; As the static-networking-service doesn't have ipv6 support yet,
	 ;; because a netlink guile binding would be required to add support
	 ;; for it in a clean way. It will eventually get done as it seem
	 ;; important for GuiX to get it done.
	 ;; In the mean time, we either need to switch to DHCP for testing and
	 ;; get a public IPv6 address through that, or use some OpenVPN service
	 ;; to get a public IPv4 address.
	 (static-networking-service %ethernet-interface-name
				    %ipv4-interface-address
				    #:gateway %ipv4-interface-gateway
				    #:netmask %ipv4-interface-netmask
				    #:name-servers `(
						     (unquote
						      %ipv4-interface-dns1)
						     (unquote
						      %ipv4-interface-dns2)
						     ))

	 (service certbot-service-type
		  (certbot-configuration
		   (email "contact@replicant.us")
		   (default-location #f)
		   ;; /!\ When deploying rsync, Only act as an rsync master
		   ;; and not client, else any person controlling the server
		   ;; from which we rsync may be able to get certificates issues
		   ;; for ftp.replicant.us
		   (webroot "/srv/ftp")
		   (certificates
		    (list
		     (certificate-configuration
		      (domains `((unquote %vm-domain-name)))
		      (deploy-hook %nginx-deploy-hook)
		      (challenge #f)
		      )
		     )
		    )
		   )
		  )

	 ;; Nginx has more of its configuration available through GuiX than
	 ;; apache
	 (service nginx-service-type
		  (nginx-configuration
		   (server-blocks
		    (list
		     (nginx-server-configuration
		      (listen '("80"))
		      (root "/srv/ftp/"))
		     )
		    )
		   )
		  )
	 )
   %base-services)
  )
 )