summaryrefslogtreecommitdiff
path: root/tw/services
diff options
context:
space:
mode:
authorTimo Wilken2023-06-03 23:59:17 +0200
committerTimo Wilken2023-06-03 23:59:17 +0200
commit1bb96ebf8b93b856de64d7bb02c8fb47254932cb (patch)
treec7159da346a3179333c72d36248b2a4620758c22 /tw/services
parentbb169097d97e9ff20e56d7d1a950866c6b25f007 (diff)
Indent *-file functions more conveniently
Files with potentially long or complex contents shouldn't be indented quite as far.
Diffstat (limited to 'tw/services')
-rw-r--r--tw/services/media.scm34
-rw-r--r--tw/services/nextcloud.scm21
-rw-r--r--tw/services/restic.scm79
3 files changed, 65 insertions, 69 deletions
diff --git a/tw/services/media.scm b/tw/services/media.scm
index ec4d0afc..36637093 100644
--- a/tw/services/media.scm
+++ b/tw/services/media.scm
@@ -44,16 +44,15 @@ run the download script. By default, picks a random time between 04:00 and
(string-append (yt-dlp-configuration-media-directory config)
"/.yt-dlp/yt-dlp"))))
#~(job #$(yt-dlp-configuration-schedule config)
- #$(program-file
- "yt-dlp-command"
- #~(begin
- (setenv "SSL_CERT_DIR" #$(file-append nss-certs "/etc/ssl/certs"))
- (chdir #$(yt-dlp-configuration-media-directory config))
- ;; Auto-update if we're using yt-dlp from the media directory.
- #$@(if yt-dlp-package '()
- (list #~(system* #$yt-dlp-executable "--ignore-config" "--update")))
- (execl #$yt-dlp-executable
- "yt-dlp" "--ignore-config" "--config-location" ".yt-dlp")))
+ #$(program-file "yt-dlp-command"
+ #~(begin
+ (setenv "SSL_CERT_DIR" #$(file-append nss-certs "/etc/ssl/certs"))
+ (chdir #$(yt-dlp-configuration-media-directory config))
+ ;; Auto-update if we're using yt-dlp from the media directory.
+ #$@(if yt-dlp-package '()
+ (list #~(system* #$yt-dlp-executable "--ignore-config" "--update")))
+ (execl #$yt-dlp-executable
+ "yt-dlp" "--ignore-config" "--config-location" ".yt-dlp")))
#:user #$(yt-dlp-configuration-user config)))))
(define yt-dlp-service-type
@@ -77,14 +76,13 @@ run the download script. By default, picks a random time between 01:00 and
(define (get-iplayer-cronjob config)
(list
#~(job #$(get-iplayer-configuration-schedule config)
- #$(program-file
- "get-iplayer-command"
- #~(begin
- (setenv "SSL_CERT_DIR" #$(file-append nss-certs "/etc/ssl/certs"))
- (execl #$(file-append (get-iplayer-configuration-get-iplayer config)
- "/bin/get_iplayer")
- "get_iplayer" "--pvr" "--profile-dir"
- #$(get-iplayer-configuration-config-directory config))))
+ #$(program-file "get-iplayer-command"
+ #~(begin
+ (setenv "SSL_CERT_DIR" #$(file-append nss-certs "/etc/ssl/certs"))
+ (execl #$(file-append (get-iplayer-configuration-get-iplayer config)
+ "/bin/get_iplayer")
+ "get_iplayer" "--pvr" "--profile-dir"
+ #$(get-iplayer-configuration-config-directory config))))
#:user #$(get-iplayer-configuration-user config))))
(define get-iplayer-service-type
diff --git a/tw/services/nextcloud.scm b/tw/services/nextcloud.scm
index 7545474d..6ede7005 100644
--- a/tw/services/nextcloud.scm
+++ b/tw/services/nextcloud.scm
@@ -104,17 +104,16 @@ Header always set Strict-Transport-Security \"max-age=15552000\"
;; Nextcloud cron
(simple-service 'nextcloud-cron mcron-service-type
(list #~(job "*/5 * * * *"
- #$(program-file
- "nextcloud-cron-command"
- #~(begin
- ;; `setgid' first while we're still root
- (setgid (group:gid (getgr "httpd")))
- (setuid (passwd:uid (getpw "httpd")))
- (chdir "/var/www/nextcloud")
- ;; Nextcloud News needs this to fetch HTTPS feeds.
- (setenv "SSL_CERT_DIR" #$(file-append nss-certs "/etc/ssl/certs"))
- (execl #$(file-append php "/bin/php") "php"
- "-c" #$%nextcloud-php.ini "cron.php"))))
+ #$(program-file "nextcloud-cron-command"
+ #~(begin
+ ;; `setgid' first while we're still root
+ (setgid (group:gid (getgr "httpd")))
+ (setuid (passwd:uid (getpw "httpd")))
+ (chdir "/var/www/nextcloud")
+ ;; Nextcloud News needs this to fetch HTTPS feeds.
+ (setenv "SSL_CERT_DIR" #$(file-append nss-certs "/etc/ssl/certs"))
+ (execl #$(file-append php "/bin/php") "php"
+ "-c" #$%nextcloud-php.ini "cron.php"))))
;; Nextcloud backups
;; Requires: sudo, php, btrfs, mysqldump, rsync
diff --git a/tw/services/restic.scm b/tw/services/restic.scm
index 62764750..f3ad6f82 100644
--- a/tw/services/restic.scm
+++ b/tw/services/restic.scm
@@ -151,26 +151,26 @@ true."
(define (cronjob repo)
#~(job #$(restic-cleanup-repository-schedule repo)
#$(program-file
- ;; Make cron commands for different repos easier to distinguish.
- (format #f "restic-cleanup-~a-command"
- (string-trim-right (basename (restic-cleanup-repository-url repo)) #\/))
- #~(begin
- ;; `setgid' first, while we're still root.
- (setgid (group:gid (getgr #$%restic-group)))
- (setuid (passwd:uid (getpw #$%restic-user)))
- (setenv "RESTIC_REPOSITORY" '#$(restic-cleanup-repository-url repo))
- (setenv "RESTIC_PASSWORD_FILE" '#$(restic-cleanup-repository-password-file repo))
- (execl #$(file-append (restic-cleanup-repository-restic repo) "/bin/restic")
- "restic" "forget" "--no-cache"
- #$@(arg-with-value "--prune" (restic-cleanup-repository-prune? repo))
- #$@(arg-with-value "--path" (restic-cleanup-repository-snapshot-paths repo))
- #$@(arg-with-value "--keep-within" (restic-cleanup-repository-keep-within repo))
- #$@(arg-with-value "--keep-last" (restic-cleanup-repository-keep-last repo))
- #$@(arg-with-value "--keep-hourly" (restic-cleanup-repository-keep-hourly repo))
- #$@(arg-with-value "--keep-daily" (restic-cleanup-repository-keep-daily repo))
- #$@(arg-with-value "--keep-weekly" (restic-cleanup-repository-keep-weekly repo))
- #$@(arg-with-value "--keep-monthly" (restic-cleanup-repository-keep-monthly repo))
- #$@(arg-with-value "--keep-yearly" (restic-cleanup-repository-keep-yearly repo)))))))
+ ;; Make cron commands for different repos easier to distinguish.
+ (format #f "restic-cleanup-~a-command"
+ (string-trim-right (basename (restic-cleanup-repository-url repo)) #\/))
+ #~(begin
+ ;; `setgid' first, while we're still root.
+ (setgid (group:gid (getgr #$%restic-group)))
+ (setuid (passwd:uid (getpw #$%restic-user)))
+ (setenv "RESTIC_REPOSITORY" '#$(restic-cleanup-repository-url repo))
+ (setenv "RESTIC_PASSWORD_FILE" '#$(restic-cleanup-repository-password-file repo))
+ (execl #$(file-append (restic-cleanup-repository-restic repo) "/bin/restic")
+ "restic" "forget" "--no-cache"
+ #$@(arg-with-value "--prune" (restic-cleanup-repository-prune? repo))
+ #$@(arg-with-value "--path" (restic-cleanup-repository-snapshot-paths repo))
+ #$@(arg-with-value "--keep-within" (restic-cleanup-repository-keep-within repo))
+ #$@(arg-with-value "--keep-last" (restic-cleanup-repository-keep-last repo))
+ #$@(arg-with-value "--keep-hourly" (restic-cleanup-repository-keep-hourly repo))
+ #$@(arg-with-value "--keep-daily" (restic-cleanup-repository-keep-daily repo))
+ #$@(arg-with-value "--keep-weekly" (restic-cleanup-repository-keep-weekly repo))
+ #$@(arg-with-value "--keep-monthly" (restic-cleanup-repository-keep-monthly repo))
+ #$@(arg-with-value "--keep-yearly" (restic-cleanup-repository-keep-yearly repo)))))))
(map cronjob repositories))
@@ -207,26 +207,25 @@ passwords in @code{rest:} URLs.")
(define (restic-backup-cronjobs repositories)
(define (cronjob repo)
#~(job #$(restic-backup-repository-schedule repo)
- #$(program-file
- "restic-backup-command"
- #~(begin
- (use-modules (ice-9 popen)
- (ice-9 textual-ports)
- (srfi srfi-1))
- (define (replace-home path)
- (if (string-prefix? "~/" path)
- (string-replace path (getenv "HOME") 0 1)
- path))
- (setenv "RESTIC_PASSWORD_COMMAND"
- '#$(restic-backup-repository-password-command repo))
- (let ((pipe (open-pipe '#$(restic-backup-repository-url-command repo) OPEN_READ)))
- (setenv "RESTIC_REPOSITORY" (string-trim-right (get-string-all pipe) #\newline))
- (close-pipe pipe))
- (apply execl #$(file-append (restic-backup-repository-restic repo) "/bin/restic")
- "restic" "backup" "--cleanup-cache"
- #$@(append-map (lambda (tag) (list "--tag" tag))
- (restic-backup-repository-tags repo))
- (map replace-home '#$(restic-backup-repository-paths repo)))))))
+ #$(program-file "restic-backup-command"
+ #~(begin
+ (use-modules (ice-9 popen)
+ (ice-9 textual-ports)
+ (srfi srfi-1))
+ (define (replace-home path)
+ (if (string-prefix? "~/" path)
+ (string-replace path (getenv "HOME") 0 1)
+ path))
+ (setenv "RESTIC_PASSWORD_COMMAND"
+ '#$(restic-backup-repository-password-command repo))
+ (let ((pipe (open-pipe '#$(restic-backup-repository-url-command repo) OPEN_READ)))
+ (setenv "RESTIC_REPOSITORY" (string-trim-right (get-string-all pipe) #\newline))
+ (close-pipe pipe))
+ (apply execl #$(file-append (restic-backup-repository-restic repo) "/bin/restic")
+ "restic" "backup" "--cleanup-cache"
+ #$@(append-map (lambda (tag) (list "--tag" tag))
+ (restic-backup-repository-tags repo))
+ (map replace-home '#$(restic-backup-repository-paths repo)))))))
(map cronjob repositories))
(define home-restic-backup-service-type