summaryrefslogtreecommitdiff
path: root/tw/services/php-fpm.scm
blob: ff9618019e47f8f1c9d56e20dc7555cf0b2da0e8 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
(define-module (tw services php-fpm)
  #:use-module (gnu services)
  #:use-module (gnu services shepherd)
  #:use-module (gnu services admin)
  #:use-module (gnu system pam)
  #:use-module (gnu system shadow)
  #:use-module (gnu packages certs)
  #:use-module (guix gexp)
  #:use-module ((guix store) #:select (text-file))
  #:use-module ((guix utils) #:select (version-major))
  #:use-module ((guix packages) #:select (package-version))
  #:use-module (ice-9 match)
  #:use-module ((gnu services web) #:select (php-fpm-configuration))
  #:export (php-fpm-service-type))

(define <php-fpm-configuration> (@@ (gnu services web) <php-fpm-configuration>))
(define default-php-fpm-config (@@ (gnu services web) default-php-fpm-config))

(define php-fpm-shepherd-service
  (match-lambda
    (($ <php-fpm-configuration> php socket user group socket-user socket-group
                                pid-file log-file pm display-errors
                                timezone workers-log-file file php-ini-file)
     (list (shepherd-service
            (provision '(php-fpm))
            (documentation "Run the php-fpm daemon.")
            (requirement '(networking))
            (start #~(make-forkexec-constructor
                      '(#$(file-append php "/sbin/php-fpm")
                        "--fpm-config"
                        #$(or file
                              (default-php-fpm-config socket user group
                                socket-user socket-group pid-file log-file
                                pm display-errors timezone workers-log-file))
                        #$@(if php-ini-file
                               `("-c" ,php-ini-file)
                               '()))
                      ;; XXX: this stanza added, for Nextcloud News
                      #:environment-variables
                      (cons*
                       (string-append "SSL_CERT_DIR=" #$nss-certs "/etc/ssl/certs")
                       (default-environment-variables))
                      #:pid-file #$pid-file))
            (stop #~(make-kill-destructor)))))))

(define php-fpm-service-type
  (service-type
   (name 'php-fpm)
   (description
    "Run @command{php-fpm} to provide a fastcgi socket for calling php through
a webserver.")
   (extensions
    (list (service-extension shepherd-root-service-type
                             php-fpm-shepherd-service)
          (service-extension activation-service-type
                             (@@ (gnu services web) php-fpm-activation))
          (service-extension account-service-type
                             (@@ (gnu services web) php-fpm-accounts))))
   (default-value (php-fpm-configuration))))