summaryrefslogtreecommitdiff
path: root/gnu/services
diff options
context:
space:
mode:
authorSören Tempel <soeren+git@soeren-tempel.net>2025-12-30 16:08:16 +0100
committerSören Tempel <soeren+git@soeren-tempel.net>2026-03-29 14:12:56 +0200
commit3f3cec89932673f1d0b039bef469f14ce2f0cbcd (patch)
tree12a9fac4bd42842cfcf9456a01f04b27432b22b9 /gnu/services
parent829b7e108de9b47bc7b70bdd021fd9ca8d799e51 (diff)
services: web: Add sogogi service.
* gnu/services/web.scm (sogogi-service-type): New services. (sogogi-serialize-section, sogogi-serialize-field) (sogogi-serialize-string, sogogi-serialize-list-of-strings) (sogogi-serialize-sogogi-user, sogogi-serialize-sogogi-location) (sogogi-serialize-list-of-sogogi-user): New procedures. (sogogi-user, sogogi-location) (sogogi-configuration): New record types. (sogogi-account-service): New variable. (sogogi-config-file, sogogi-shepherd-service): New procedures. * gnu/tests/web.scm (%test-sogogi): Add tests for the service. * doc/guix.texi (Web Services): Document it. Change-Id: I5cc6dd84d6c7c8d5d13b685853b19c5d433ed7e5
Diffstat (limited to 'gnu/services')
-rw-r--r--gnu/services/web.scm131
1 files changed, 131 insertions, 0 deletions
diff --git a/gnu/services/web.scm b/gnu/services/web.scm
index 7df1c66b9fa..8addaa8d5ac 100644
--- a/gnu/services/web.scm
+++ b/gnu/services/web.scm
@@ -313,6 +313,15 @@
313 patchwork-virtualhost 313 patchwork-virtualhost
314 patchwork-service-type 314 patchwork-service-type
315 315
316 sogogi-service-type
317 sogogi-configuration
318 sogogi-config-file
319 sogogi-configuration?
320 sogogi-user
321 sogogi-user?
322 sogogi-location
323 sogogi-location?
324
316 mumi-configuration 325 mumi-configuration
317 mumi-configuration? 326 mumi-configuration?
318 mumi-configuration-mumi 327 mumi-configuration-mumi
@@ -2184,6 +2193,128 @@ WSGIPassAuthorization On
2184 2193
2185 2194
2186;;; 2195;;;
2196;;; sogogi.
2197;;;
2198
2199(define (sogogi-serialize-section section-name value fields)
2200 (let ((first-field (car fields)))
2201 #~(format #f "~a ~a {~%~a}~%"
2202 #$(object->string section-name)
2203 #$((configuration-field-getter first-field) value)
2204 #$(serialize-configuration value (cdr fields)))))
2205
2206(define (sogogi-serialize-field field-name value)
2207 (let ((field (object->string field-name)))
2208 #~(format #f "~a ~a~%" #$field #$value)))
2209
2210(define sogogi-serialize-string sogogi-serialize-field)
2211(define (sogogi-serialize-list-of-strings field-name value)
2212 #~(string-append
2213 #$@(map (cut sogogi-serialize-string field-name <>)
2214 value)))
2215
2216(define-maybe string (prefix sogogi-))
2217(define-maybe list-of-strings (prefix sogogi-))
2218
2219(define-configuration sogogi-user
2220 (name
2221 maybe-string
2222 "Name of the user.")
2223
2224 (password
2225 maybe-string
2226 "Password of the user.")
2227
2228 (prefix sogogi-))
2229
2230(define (sogogi-serialize-sogogi-user field-name value)
2231 (sogogi-serialize-section field-name value sogogi-user-fields))
2232
2233(define-configuration sogogi-location
2234 (path
2235 string
2236 "HTTP path at which the directory will be exposed.")
2237
2238 (dir
2239 string
2240 "Path to local directory to serve.")
2241
2242 (grant
2243 maybe-list-of-strings
2244 "Grant remote users access to the directory.")
2245
2246 (prefix sogogi-))
2247
2248(define (sogogi-serialize-sogogi-location field-name value)
2249 (sogogi-serialize-section field-name value sogogi-location-fields))
2250
2251(define (sogogi-serialize-list-of-sogogi-location field-name value)
2252 #~(string-append #$@(map (cut sogogi-serialize-sogogi-location field-name <>) value)))
2253
2254(define (sogogi-serialize-list-of-sogogi-user field-name value)
2255 #~(string-append #$@(map (cut sogogi-serialize-sogogi-user field-name <>) value)))
2256
2257(define list-of-sogogi-user? (list-of sogogi-user?))
2258(define list-of-sogogi-location? (list-of sogogi-location?))
2259
2260(define-configuration sogogi-configuration
2261 (listen
2262 (string "localhost:8080")
2263 "Listening address.")
2264
2265 (location
2266 (list-of-sogogi-location '())
2267 "Local directories to expose via a HTTP path.")
2268
2269 (user
2270 (list-of-sogogi-user '())
2271 "Users with access to the location.")
2272
2273 (prefix sogogi-))
2274
2275(define (sogogi-config-file config)
2276 (mixed-text-file "sogogi.conf"
2277 (serialize-configuration
2278 config
2279 sogogi-configuration-fields)))
2280
2281(define (sogogi-shepherd-service config)
2282 (let ((config-file (sogogi-config-file config)))
2283 (list (shepherd-service
2284 (documentation "Sogogi daemon.")
2285 (provision '(sogogi))
2286 ;; sogogi may be bound to a particular IP address, hence
2287 ;; only start it after the networking service has started.
2288 (requirement '(user-processes networking))
2289 (actions (list (shepherd-configuration-action config-file)))
2290 (start #~(make-forkexec-constructor
2291 (list (string-append #$sogogi "/bin/sogogi")
2292 "-config" #$config-file)))
2293 (stop #~(make-kill-destructor))))))
2294
2295(define sogogi-account-service
2296 (list (user-group (name "sogogi") (system? #t))
2297 (user-account
2298 (name "sogogi")
2299 (group "sogogi")
2300 (system? #t)
2301 (comment "Sogogi daemon user")
2302 (home-directory "/var/empty")
2303 (shell (file-append shadow "/sbin/nologin")))))
2304
2305(define sogogi-service-type
2306 (service-type (name 'sogogi)
2307 (description "Run the sogogi WebDAV server.")
2308 (extensions
2309 (list (service-extension account-service-type
2310 (const sogogi-account-service))
2311 (service-extension shepherd-root-service-type
2312 sogogi-shepherd-service)))
2313 (compose concatenate)
2314 (default-value (sogogi-configuration))))
2315
2316
2317;;;
2187;;; Mumi. 2318;;; Mumi.
2188;;; 2319;;;
2189 2320