diff options
Diffstat (limited to 'gnu/machine')
| -rw-r--r-- | gnu/machine/digital-ocean.scm | 52 |
1 files changed, 40 insertions, 12 deletions
diff --git a/gnu/machine/digital-ocean.scm b/gnu/machine/digital-ocean.scm index bc8dadc147a..dc89862ca26 100644 --- a/gnu/machine/digital-ocean.scm +++ b/gnu/machine/digital-ocean.scm | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #:use-module (gnu machine ssh) | 22 | #:use-module (gnu machine ssh) |
| 23 | #:use-module (gnu machine) | 23 | #:use-module (gnu machine) |
| 24 | #:use-module (gnu services) | 24 | #:use-module (gnu services) |
| 25 | #:use-module (gnu services base) | ||
| 25 | #:use-module (gnu services networking) | 26 | #:use-module (gnu services networking) |
| 26 | #:use-module (gnu system) | 27 | #:use-module (gnu system) |
| 27 | #:use-module (gnu system pam) | 28 | #:use-module (gnu system pam) |
| @@ -188,11 +189,24 @@ an environment type of 'digital-ocean-environment-type'." | |||
| 188 | ;;; System deployment. | 189 | ;;; System deployment. |
| 189 | ;;; | 190 | ;;; |
| 190 | 191 | ||
| 192 | ;; XXX Copied from (gnu services base) | ||
| 193 | (define* (ip+netmask->cidr ip netmask #:optional (family AF_INET)) | ||
| 194 | "Return the CIDR notation (a string) for @var{ip} and @var{netmask}, two | ||
| 195 | @var{family} address strings, where @var{family} is @code{AF_INET} or | ||
| 196 | @code{AF_INET6}." | ||
| 197 | (let* ((netmask (inet-pton family netmask)) | ||
| 198 | (bits (logcount netmask))) | ||
| 199 | (string-append ip "/" (number->string bits)))) | ||
| 200 | |||
| 191 | ;; The following script was adapted from the guide available at | 201 | ;; The following script was adapted from the guide available at |
| 192 | ;; <https://wiki.pantherx.org/Installation-digital-ocean/>. | 202 | ;; <https://wiki.pantherx.org/Installation-digital-ocean/>. |
| 193 | (define (guix-infect network) | 203 | (define (guix-infect network) |
| 194 | "Given NETWORK, an alist describing the Droplet's public IPv4 network | 204 | "Given NETWORK, an alist describing the Droplet's public IPv4 network |
| 195 | interface, return a Bash script that will install the Guix system." | 205 | interface, return a Bash script that will install the Guix system." |
| 206 | (define cidr | ||
| 207 | (ip+netmask->cidr | ||
| 208 | (assoc-ref network "ip_address") | ||
| 209 | (assoc-ref network "netmask"))) | ||
| 196 | (format #f "#!/bin/bash | 210 | (format #f "#!/bin/bash |
| 197 | 211 | ||
| 198 | apt-get update | 212 | apt-get update |
| @@ -229,7 +243,7 @@ export GUIX_LOCPATH=\"$HOME/.guix-profile/lib/locale\" | |||
| 229 | guix package -i openssl | 243 | guix package -i openssl |
| 230 | cat > /etc/bootstrap-config.scm << EOF | 244 | cat > /etc/bootstrap-config.scm << EOF |
| 231 | (use-modules (gnu)) | 245 | (use-modules (gnu)) |
| 232 | (use-service-modules networking ssh) | 246 | (use-service-modules base networking ssh) |
| 233 | 247 | ||
| 234 | (operating-system | 248 | (operating-system |
| 235 | (host-name \"gnu-bootstrap\") | 249 | (host-name \"gnu-bootstrap\") |
| @@ -244,10 +258,17 @@ cat > /etc/bootstrap-config.scm << EOF | |||
| 244 | (type \"ext4\")) | 258 | (type \"ext4\")) |
| 245 | %base-file-systems)) | 259 | %base-file-systems)) |
| 246 | (services | 260 | (services |
| 247 | (append (list (static-networking-service \"eth0\" \"~a\" | 261 | (append (list (service static-networking-service-type |
| 248 | #:netmask \"~a\" | 262 | (list (static-networking |
| 249 | #:gateway \"~a\" | 263 | (addresses |
| 250 | #:name-servers '(\"84.200.69.80\" \"84.200.70.40\")) | 264 | (list (network-address |
| 265 | (device \"eth0\") | ||
| 266 | (value \"~a\")))) | ||
| 267 | (routes | ||
| 268 | (list (network-route | ||
| 269 | (destination \"default\") | ||
| 270 | (gateway \"~a\")))) | ||
| 271 | (name-servers '(\"84.200.69.80\" \"84.200.70.40\"))))) | ||
| 251 | (simple-service 'guile-load-path-in-global-env | 272 | (simple-service 'guile-load-path-in-global-env |
| 252 | session-environment-service-type | 273 | session-environment-service-type |
| 253 | \\`((\"GUILE_LOAD_PATH\" | 274 | \\`((\"GUILE_LOAD_PATH\" |
| @@ -268,8 +289,7 @@ mv /etc /old-etc | |||
| 268 | mkdir /etc | 289 | mkdir /etc |
| 269 | cp -r /old-etc/{passwd,group,shadow,gshadow,mtab,guix,bootstrap-config.scm} /etc/ | 290 | cp -r /old-etc/{passwd,group,shadow,gshadow,mtab,guix,bootstrap-config.scm} /etc/ |
| 270 | guix system reconfigure /etc/bootstrap-config.scm" | 291 | guix system reconfigure /etc/bootstrap-config.scm" |
| 271 | (assoc-ref network "ip_address") | 292 | cidr |
| 272 | (assoc-ref network "netmask") | ||
| 273 | (assoc-ref network "gateway"))) | 293 | (assoc-ref network "gateway"))) |
| 274 | 294 | ||
| 275 | (define (machine-wait-until-available machine) | 295 | (define (machine-wait-until-available machine) |
| @@ -301,11 +321,19 @@ named DROPLET-NAME." | |||
| 301 | configuration for the public IPv4 network described by the alist NETWORK." | 321 | configuration for the public IPv4 network described by the alist NETWORK." |
| 302 | (operating-system | 322 | (operating-system |
| 303 | (inherit (machine-operating-system target)) | 323 | (inherit (machine-operating-system target)) |
| 304 | (services (cons* (static-networking-service "eth0" | 324 | (services (cons* (service static-networking-service-type |
| 305 | (assoc-ref network "ip_address") | 325 | (list (static-networking |
| 306 | #:netmask (assoc-ref network "netmask") | 326 | (addresses |
| 307 | #:gateway (assoc-ref network "gateway") | 327 | (list (network-address |
| 308 | #:name-servers '("84.200.69.80" "84.200.70.40")) | 328 | (device "eth0") |
| 329 | (value (ip+netmask->cidr | ||
| 330 | (assoc-ref network "ip_address") | ||
| 331 | (assoc-ref network "netmask")))))) | ||
| 332 | (routes | ||
| 333 | (list (network-route | ||
| 334 | (destination "default") | ||
| 335 | (gateway (assoc-ref network "gateway"))))) | ||
| 336 | (name-servers '("84.200.69.80" "84.200.70.40"))))) | ||
| 309 | (simple-service 'guile-load-path-in-global-env | 337 | (simple-service 'guile-load-path-in-global-env |
| 310 | session-environment-service-type | 338 | session-environment-service-type |
| 311 | `(("GUILE_LOAD_PATH" | 339 | `(("GUILE_LOAD_PATH" |
