diff options
author | Efraim Flashner | 2019-12-22 03:49:03 -0600 |
---|---|---|
committer | Efraim Flashner | 2019-12-22 03:49:03 -0600 |
commit | 5856fb3878e69a2091afbfdd3b15268e310f82e3 (patch) | |
tree | a4bd7cf668275279bcbf01ede37954f8087d7172 /gn/services/bnw-container.scm | |
parent | 3035ea5144af76b6ff260b1bceef3feafec8a177 (diff) | |
download | guix-bioinformatics-5856fb3878e69a2091afbfdd3b15268e310f82e3.tar.gz |
gn: Update bnw service
Diffstat (limited to 'gn/services/bnw-container.scm')
-rw-r--r-- | gn/services/bnw-container.scm | 88 |
1 files changed, 69 insertions, 19 deletions
diff --git a/gn/services/bnw-container.scm b/gn/services/bnw-container.scm index 13a9317..2e5e521 100644 --- a/gn/services/bnw-container.scm +++ b/gn/services/bnw-container.scm @@ -1,8 +1,69 @@ (define-module (gn services bnw-container)) (use-modules (gnu) - (gn packages bnw)) -(use-service-modules base networking web) + (gn packages bnw) + (guix records) + (ice-9 match)) +(use-service-modules networking web) + +(define-record-type* <bnw-configuration> + bnw-configuration + make-bnw-configuration + bnw-configuration? + (package bnw-configuration-package ; package + (default bnw)) + (deploy-directory bnw-deploy-directory ; string + (default "/home/bnw/server")) + (port bnw-configuration-port ; list of strings + (default '("8880")))) + +(define bnw-activation + (match-lambda + (($ <bnw-configuration> package deploy-directory port) + #~(begin + (use-modules (guix build utils)) + (when (directory-exists? #$deploy-directory) + (delete-file-recusively #$deploy-directory)) + (mkdir-p #$deploy-directory) + (copy-recursively #$package #$deploy-directory) + (system* #$(file-append coreutils "/bin/chmod") "a+w" + (string-append #$deploy-directory "/sourcecodes/data")))))) + +(define bnw-nginx-config + (match-lambda + (($ <bnw-configuration> package deploy-directory port) + (list + (nginx-server-configuration + (server-name '("Bayesian Network")) + (listen port) + ;(root package) + (root "/srv/http") + (locations + (list + (nginx-php-location) + ;(nginx-location-configuration + ; (uri "/sourcecodes/data/") + ; (body (list "alias /tmp/bnw/;"))) + ))))))) + +(define bnw-service-type + (service-type + (name 'bnw) + (extensions + (list + (service-extension activation-service-type + bnw-activation) + (service-extension nginx-service-type + bnw-nginx-config) + ;; Make sure BNW doesn't get garbage collected. + (service-extension profile-service-type + (compose list bnw-configuration-package)) + ;; Make sure php-fpm is instantiated. + (service-extension php-fpm-service-type + (const #t)))) + (default-value (bnw-configuration)) + (description + "Run a Bayesian Network Webserver."))) (operating-system (host-name "bnw") @@ -17,20 +78,9 @@ (firmware '()) (services (list (service dhcp-client-service-type) - (service php-fpm-service-type) - (service nginx-service-type - (nginx-configuration - (server-blocks - (list - (nginx-server-configuration - (server-name '("Bayesian Network")) - (listen '("8888")) - (root bnw) - (locations - (list - (nginx-php-location) - (nginx-location-configuration - (uri "/sourcecodes/data/") - (body (list "alias /tmp/bnw/;"))) - )) - )))))))) + (service bnw-service-type + ;; The following is for testing: + ;(bnw-configuration + ; (deploy-directory "/home/efraimf/bnw") + ; (port '("8888"))) + )))) |