| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 |
|
| 19 | (define-module (gnu services dav)
|
| 20 | #:use-module (gnu packages dav)
|
| 21 | #:use-module (gnu services)
|
| 22 | #:use-module (gnu services configuration)
|
| 23 | #:use-module (gnu services shepherd)
|
| 24 | #:use-module (guix deprecation)
|
| 25 | #:use-module (guix gexp)
|
| 26 | #:use-module (guix records)
|
| 27 | #:use-module (ice-9 match)
|
| 28 | #:export (xandikos-configuration
|
| 29 | xandikos-configuration?
|
| 30 | xandikos-service-type))
|
| 31 |
|
| 32 | |
| 33 | |
| 34 | |
| 35 |
|
| 36 | (define (port? x)
|
| 37 | (and (number? x)
|
| 38 | (and (>= x 0) (<= x 65535))))
|
| 39 |
|
| 40 | (define-configuration/no-serialization xandikos-configuration
|
| 41 | (package
|
| 42 | (file-like xandikos)
|
| 43 | "Xandikos package to use.")
|
| 44 | (directory
|
| 45 | (string "/var/xandikos/dav")
|
| 46 | "Directory to serve from.")
|
| 47 | (listen-address
|
| 48 | (string "127.0.0.1")
|
| 49 | "The address Xandikos listens on.")
|
| 50 | (port
|
| 51 | (port 8080)
|
| 52 | "The port to run Xandikos on.")
|
| 53 | (current-user-principal
|
| 54 | (string "/user/")
|
| 55 | "Path to current user principal.")
|
| 56 | (route-prefix
|
| 57 | (string "/")
|
| 58 | "Path to Xandikos. (Useful when Xandikos is behind a reverse proxy.)")
|
| 59 | (defaults?
|
| 60 | (boolean #t)
|
| 61 | "Create initial calendar and address book.")
|
| 62 | (dump?
|
| 63 | (boolean #f)
|
| 64 | "Print DAV XML request/responses.")
|
| 65 | (avahi?
|
| 66 | (boolean #f)
|
| 67 | "Announce services with avahi.")
|
| 68 | (autocreate?
|
| 69 | (boolean #f)
|
| 70 | "Automatically create necessary directories.")
|
| 71 | (no-strict?
|
| 72 | (boolean #f)
|
| 73 | "Enable workarounds for buggy CalDAV/CardDAV client implementations."))
|
| 74 |
|
| 75 | (define (xandikos-shepherd-service config)
|
| 76 | (match-record config <xandikos-configuration>
|
| 77 | (package directory listen-address port current-user-principal
|
| 78 | route-prefix defaults? dump? avahi? autocreate?
|
| 79 | no-strict?)
|
| 80 | (list
|
| 81 | (shepherd-service
|
| 82 | (provision '(xandikos))
|
| 83 | (documentation "Caldav/CardDAV server")
|
| 84 | (requirement '(networking user-processes))
|
| 85 | (start #~(make-forkexec-constructor
|
| 86 | (list #$(file-append xandikos "/bin/xandikos")
|
| 87 | "--listen-address" #$listen-address
|
| 88 | "--port" #$(number->string port)
|
| 89 | "-d" #$directory
|
| 90 | "--route-prefix" #$route-prefix
|
| 91 | "--current-user-principal" #$current-user-principal
|
| 92 | #$@(if dump? '("--dump-dav-xml") '())
|
| 93 | #$@(if avahi? '("--avahi") '())
|
| 94 | #$@(if autocreate? '("--autocreate") '())
|
| 95 | #$@(if defaults? '("--defaults") '())
|
| 96 | #$@(if no-strict? '("--no-strict") '()))))
|
| 97 | (stop #~(make-kill-destructor))
|
| 98 | (respawn? #t)))))
|
| 99 |
|
| 100 | (define xandikos-service-type
|
| 101 | (service-type
|
| 102 | (name 'xandikos)
|
| 103 | (extensions
|
| 104 | (list (service-extension shepherd-root-service-type
|
| 105 | xandikos-shepherd-service)))
|
| 106 | (default-value (xandikos-configuration))
|
| 107 | (description "Service to run the @code{Xandikos} CalDAV/CardDAV server.")))
|