Refactor cron jobs to use a common helper function
systems/xana.scm
22 | 22 | (use-modules (gnu services networking)) | |
23 | 23 | (use-modules (gnu services web)) | |
24 | 24 | (use-modules (config certbot) (config cuirass) (config network) (config os)) | |
25 | - | (use-modules (gnu packages base)) | |
26 | 25 | (use-modules (guix gexp)) | |
26 | + | (use-package-modules base compression gettext guile guile-xyz linux version-control | |
27 | + | wget) | |
28 | + | ||
29 | + | (define (makefile-job directory target packages env) | |
30 | + | #~(lambda () | |
31 | + | (define path | |
32 | + | (string-join | |
33 | + | (map (lambda (p) (string-append p "/bin")) (list #$@packages)) | |
34 | + | ":")) | |
35 | + | (define (get-path dir) | |
36 | + | (string-join | |
37 | + | (map (lambda (p) (string-append p "/" path) (list #$@packages))) | |
38 | + | ":")) | |
39 | + | (setenv "PATH" path) | |
40 | + | (setenv "GIT_SSL_CAINFO" "/etc/ssl/certs/ca-certificates.crt") | |
41 | + | (setenv "SSL_CERT_DIR" "/etc/ssl/certs") | |
42 | + | (setenv "SSL_CERT_FILE" "/etc/ssl/certs/ca-certificates.crt") | |
43 | + | (setenv "LANG" "en_US.UTF-8") | |
44 | + | (for-each | |
45 | + | (lambda (env) | |
46 | + | (setenv (car env) (get-path (cdr env)))) | |
47 | + | (quote #$env)) | |
48 | + | (execl #$(file-append gnu-make "/bin/make") "make" "-C" #$directory #$target))) | |
27 | 49 | ||
28 | 50 | (define i18n-download-job | |
29 | 51 | #~(job '(next-minute-from (next-hour '(05)) '(51)) | |
30 | - | (lambda () | |
31 | - | (execl #$(file-append gnu-make "/bin/make") | |
32 | - | "-C" "/srv/http/i18n" "fdroid-update")))) | |
52 | + | #$(makefile-job "/srv/http/i18n" "fdroid-update" | |
53 | + | (list gnu-make coreutils findutils git) | |
54 | + | '()))) | |
33 | 55 | ||
34 | 56 | (define i18n-compile-job | |
35 | 57 | #~(job '(next-minute-from (next-hour '(06)) '(21)) | |
36 | - | (lambda () | |
37 | - | (execl #$(file-append gnu-make "/bin/make") | |
38 | - | "-C" "/srv/http/i18n")))) | |
58 | + | #$(makefile-job "/srv/http/i18n" "all" | |
59 | + | (list gnu-make coreutils findutils git grep util-linux) | |
60 | + | '()))) | |
39 | 61 | ||
40 | 62 | (define nani-download-job | |
41 | 63 | #~(job '(next-minute-from (next-hour-from (next-day (range 1 31 5)) '(02)) '(12)) | |
42 | - | (lambda () | |
43 | - | (execl #$(file-append gnu-make "/bin/make") | |
44 | - | "-C" "/srv/http/nani" "download")))) | |
64 | + | #$(makefile-job "/srv/http/nani" "download" | |
65 | + | (list gnu-make coreutils findutils grep gzip libiconv | |
66 | + | sed tar unzip util-linux wget xz) | |
67 | + | '()))) | |
45 | 68 | ||
46 | 69 | (define nani-update-job | |
47 | 70 | #~(job '(next-minute-from (next-hour-from (next-day (range 1 31 5)) '(03)) '(12)) | |
48 | - | (lambda () | |
49 | - | (execl #$(file-append gnu-make "/bin/make") | |
50 | - | "-C" "/srv/http/nani" "download")))) | |
71 | + | #$(makefile-job "/srv/http/nani" "all" | |
72 | + | (list gnu-make coreutils findutils gnu-gettext grep guile-3.0 | |
73 | + | haunt sed) | |
74 | + | '(("GUILE_LOAD_PATH" . "share/guile/site/3.0") | |
75 | + | ("GUILE_LOAD_COMPILED_PATH" . "share/guile/site/3.0"))))) | |
51 | 76 | ||
52 | 77 | (operating-system | |
53 | 78 | (inherit (tyreunom-os "xana")) | |
… | |||
66 | 91 | (list | |
67 | 92 | (service dhcp-client-service-type) | |
68 | 93 | (service nginx-service-type) | |
69 | - | (simple-service 'i18n-cron mcron-service-type | |
94 | + | (simple-service 'website-cron mcron-service-type | |
70 | 95 | (list i18n-download-job i18n-compile-job | |
71 | 96 | nani-download-job nani-update-job)) | |
72 | 97 | (certbot-service `(("xana.lepiller.eu") | |
73 | - | ("nani.lepiller.eu"))) | |
98 | + | ("nani.lepiller.eu") | |
99 | + | ("i18n.lepiller.eu"))) | |
74 | 100 | (simple-service 'nani-http-server nginx-service-type | |
75 | 101 | (list (nginx-server-configuration | |
76 | 102 | (ssl-certificate | |
… | |||
80 | 106 | (listen '("443 ssl http2" "[::]:443 ssl http2")) | |
81 | 107 | (server-name '("nani.lepiller.eu")) | |
82 | 108 | (root "/srv/http/nani/public")))) | |
109 | + | (simple-service 'i18n-http-server nginx-service-type | |
110 | + | (list (nginx-server-configuration | |
111 | + | (ssl-certificate | |
112 | + | "/etc/letsencrypt/live/i18n.lepiller.eu/fullchain.pem") | |
113 | + | (ssl-certificate-key | |
114 | + | "/etc/letsencrypt/live/i18n.lepiller.eu/privkey.pem") | |
115 | + | (listen '("443 ssl http2" "[::]:443 ssl http2")) | |
116 | + | (server-name '("i18n.lepiller.eu")) | |
117 | + | (root "/srv/http/i18n/public")))) | |
83 | 118 | (simple-service 'default-http-server nginx-service-type | |
84 | 119 | (list (nginx-server-configuration | |
85 | 120 | (ssl-certificate |