diff -ur --label \#\ --label \#\ /tmp/buffer-content-YQhGgT /tmp/buffer-content-GVVcs3 --- # +++ # @@ -9,23 +9,13 @@ #:use-module (gnu services configuration) #:use-module (gnu system shadow) #:use-module (guix gexp) + #:use-module (srfi srfi-1) #:use-module (guix packages) #:use-module (guix records) + #:use-module (gnu build linux-container) #:export (dicomd-configuration dicomd-configuration? dicomd-service-type)) - -(define-record-type* - dicomd-configuration make-dicomd-configuration dicomd-configuration? - (package dicomd-configuration-package - (default dcmtk)) - (port dicomd-configuration-port - (default 104)) - (aetitle dicomd-configuration-aetitle - (default "DICOMD")) - (storage-dir dicomd-configuration-storage-dir - (default "/var/dicom-store"))) - (define %dicomd-account-service (list (user-account (name "dicomd") @@ -39,14 +29,31 @@ (name "dicom") (system? #t)))) +(define-record-type* + dicomd-configuration make-dicomd-configuration dicomd-configuration? + (package dicomd-configuration-package + (default dcmtk)) + (port dicomd-configuration-port + (default 1025)) + (aetitle dicomd-configuration-aetitle + (default "DICOMD")) + (storage-dir dicomd-configuration-storage-dir + (default "/var/dicom-store")) + (account dicomd-configuration-account + (default (car %dicomd-account-service))) + (group dicomd-configuration-group + (default (cadr %dicomd-account-service)))) + (define dicomd-shepherd-service (match-lambda - (($ package port aetitle storage-dir) + (($ package port aetitle storage-dir account) (let ((dicomd (least-authority-wrapper (file-append package "/bin/storescp") #:name "dicomd" + #:namespaces + (fold delq %namespaces '(net)) #:mappings (list (file-system-mapping - (source "/var/dicom-store") + (source storage-dir) (target source) (writable? #t)))))) (shepherd-service @@ -55,19 +62,21 @@ (documentation "DICOMD Service") (auto-start? #t) (start #~(make-forkexec-constructor - (list #$dicomd))) - ;; "--output-dir" #$storage-dir - ;; #$(number->string port) - ;; #:user "dicomd" #:group "dicom"))) + (list #$dicomd + "--output-directory" #$storage-dir + #$(number->string port)) + + ;; #$(number->string port) + + #:user #$(user-account-name account) #:group #$(user-account-group account))) (stop #~(make-kill-destructor))))))) -(define dicomd-activation +(define (dicomd-activation config) (with-imported-modules '((guix build utils)) #~(begin (use-modules (guix build utils)) - - (let* ((user (getpw "dicomd")) - (directory "/var/dicom-store")) + (let* ((user (getpw #$(user-account-name (dicomd-configuration-account config)))) + (directory #$(dicomd-configuration-storage-dir config))) ;; dicomd creates a Unix-domain socket in DIRECTORY. (mkdir-p directory) (chown directory (passwd:uid user) (passwd:gid user)))))) @@ -78,9 +87,12 @@ (description "DICOMD Service") (extensions (list (service-extension account-service-type - (const %dicomd-account-service)) + (lambda (config) + (list + (dicomd-configuration-account config) + (dicomd-configuration-group config)))) (service-extension activation-service-type - (const dicomd-activation)) + dicomd-activation) (service-extension shepherd-root-service-type (compose list dicomd-shepherd-service)))) (default-value (dicomd-configuration))))