diff options
| -rwxr-xr-x | hipis.scm | 17 | ||||
| -rw-r--r-- | hipis/packages/source/hwp/hwp.scm | 21 | ||||
| -rw-r--r-- | hipis/packages/source/hwp/hwp/download.scm | 20 | ||||
| -rw-r--r-- | hipis/services/web.scm | 59 |
4 files changed, 85 insertions, 32 deletions
| @@ -146,22 +146,15 @@ | |||
| 146 | (ssl-certificate (letsencrypt-certificate "jdlugosz.com")) | 146 | (ssl-certificate (letsencrypt-certificate "jdlugosz.com")) |
| 147 | (ssl-certificate-key (letsencrypt-key "jdlugosz.com"))))))) | 147 | (ssl-certificate-key (letsencrypt-key "jdlugosz.com"))))))) |
| 148 | 148 | ||
| 149 | (service nginx-service-type | ||
| 150 | (nginx-configuration | ||
| 151 | (server-blocks | ||
| 152 | (list | ||
| 153 | (nginx-server-configuration | ||
| 154 | (server-name '("jdlugosz.com")) | ||
| 155 | (listen '("443 ssl")) | ||
| 156 | (ssl-certificate (letsencrypt-certificate "jdlugosz.com")) | ||
| 157 | (ssl-certificate-key (letsencrypt-key "jdlugosz.com")) | ||
| 158 | (root "/srv/http/jdlugosz.com")))))) | ||
| 159 | |||
| 160 | (service quassel-service-type) | 149 | (service quassel-service-type) |
| 161 | 150 | ||
| 162 | (service hwp-service-type | 151 | (service hwp-service-type |
| 163 | (hwp-site-configuration | 152 | (hwp-site-configuration |
| 164 | (name "hwp-base"))) | 153 | (name "hwp-base") |
| 154 | (domains '("jdlugosz.com")) | ||
| 155 | (source-url "https://git.jdlugosz.com/hipis/hipis-website/snapshot/hipis-website-master.tar.gz") | ||
| 156 | (ssl-certificate (letsencrypt-certificate "jdlugosz.com")) | ||
| 157 | (ssl-certificate-key (letsencrypt-key "jdlugosz.com")))) | ||
| 165 | 158 | ||
| 166 | (modify-services %base-services | 159 | (modify-services %base-services |
| 167 | (delete static-networking-service-type)))) | 160 | (delete static-networking-service-type)))) |
diff --git a/hipis/packages/source/hwp/hwp.scm b/hipis/packages/source/hwp/hwp.scm index 6770b5b..c497538 100644 --- a/hipis/packages/source/hwp/hwp.scm +++ b/hipis/packages/source/hwp/hwp.scm | |||
| @@ -1,13 +1,20 @@ | |||
| 1 | (define-module (hwp) | 1 | (define-module (hwp) |
| 2 | #:use-module (hwp site) | 2 | #:use-module (hwp site) |
| 3 | #:use-module (hwp download) | ||
| 3 | #:use-module (hwp ui) | 4 | #:use-module (hwp ui) |
| 4 | #:use-module (ice-9 match) | 5 | #:use-module (ice-9 match) |
| 5 | #:export (hwp-run)) | 6 | #:export (hwp-build |
| 7 | hwp-run)) | ||
| 8 | |||
| 9 | |||
| 10 | (define (hwp-build url dest) | ||
| 11 | (define website-source-dir (download-curl url "/tmp")) | ||
| 12 | (hipis-site website-source-dir dest)) | ||
| 6 | 13 | ||
| 7 | (define (hwp-run args) | 14 | (define (hwp-run args) |
| 8 | (match args | 15 | (match args |
| 9 | ((cmd) | 16 | ((cmd) |
| 10 | (display "To create site: hwp-build [input-path] [output-path]") | 17 | (display "To create site: hwp-build [input-path] [output-path]") |
| 11 | (newline)) | 18 | (newline)) |
| 12 | ((cmd in out) | 19 | ((cmd in out) |
| 13 | (hipis-site in out)))) | 20 | (hipis-site in out)))) |
diff --git a/hipis/packages/source/hwp/hwp/download.scm b/hipis/packages/source/hwp/hwp/download.scm new file mode 100644 index 0000000..be4f292 --- /dev/null +++ b/hipis/packages/source/hwp/hwp/download.scm | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | (define-module (hwp download) | ||
| 2 | #:export (download-curl)) | ||
| 3 | |||
| 4 | |||
| 5 | (define (download-curl url dest) | ||
| 6 | (define file-name (basename url)) | ||
| 7 | (define compressed-file (string-append "/tmp/" file-name)) | ||
| 8 | |||
| 9 | (when (not (= (system* "curl" url "-o" compressed-file) 0)) | ||
| 10 | (error (string-append "Error: cannot download file: " url))) | ||
| 11 | |||
| 12 | (cond | ||
| 13 | ((or (string-suffix? "tar.gz" file-name) | ||
| 14 | (string-suffix? "tar.xz" file-name)) | ||
| 15 | (if (not (= (system* "tar" "-C" dest "-x" "-f" compressed-file) 0)) | ||
| 16 | (error (format #f "Error: when trying to decompress file: ~a in destination: ~a" | ||
| 17 | compressed-file dest)) | ||
| 18 | (string-append dest "/" (string-drop-right file-name 7)))) | ||
| 19 | (#t (error (string-append "Error: file with unspuported format: " dest))))) | ||
| 20 | |||
diff --git a/hipis/services/web.scm b/hipis/services/web.scm index 52cc6db..e7d2ce5 100644 --- a/hipis/services/web.scm +++ b/hipis/services/web.scm | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #:use-module (gnu packages guile) | 18 | #:use-module (gnu packages guile) |
| 19 | #:use-module (guix git-download) | 19 | #:use-module (guix git-download) |
| 20 | #:use-module (gnu services) | 20 | #:use-module (gnu services) |
| 21 | #:use-module (gnu services web) | ||
| 21 | #:use-module (gnu services guix) | 22 | #:use-module (gnu services guix) |
| 22 | #:use-module (hipis packages web) | 23 | #:use-module (hipis packages web) |
| 23 | 24 | ||
| @@ -26,24 +27,51 @@ | |||
| 26 | hwp-site-configuration)) | 27 | hwp-site-configuration)) |
| 27 | 28 | ||
| 28 | 29 | ||
| 30 | ;; (define %hwp-configuration-nginx | ||
| 31 | ;; (nginx-server-configuration)) | ||
| 32 | |||
| 29 | (define-record-type* <hwp-theme-configuration> | 33 | (define-record-type* <hwp-theme-configuration> |
| 30 | hwp-theme-configuration make-hwp-theme-configuration | 34 | hwp-theme-configuration make-hwp-theme-configuration |
| 31 | hwp-theme-configuration-configuration? | 35 | hwp-theme-configuration-configuration? |
| 32 | (primary-color hwp-theme-configuration-primary-color | 36 | (primary-color hwp-theme-configuration-primary-color |
| 33 | (default "#000"))) | 37 | (default "#000")) |
| 38 | (secondary-color hwp-theme-configuration-primary-color | ||
| 39 | (default "#000"))) | ||
| 34 | 40 | ||
| 35 | (define-record-type* <hwp-site-configuration> | 41 | (define-record-type* <hwp-site-configuration> |
| 36 | hwp-site-configuration make-hwp-theme-configuration | 42 | hwp-site-configuration make-hwp-theme-configuration |
| 37 | hwp-site-configuration-configuration? | 43 | hwp-site-configuration-configuration? |
| 38 | (name hwp-site-configuration-name) | 44 | (name hwp-site-configuration-name) |
| 39 | (theme hwp-site-configuration-theme | 45 | (domains hwp-site-configuration-domain) |
| 40 | (default #nil))) | 46 | (source-url hwp-site-configuration-source-url) |
| 47 | (ssl-certificate hwp-site-configuration-nginx | ||
| 48 | (default #f)) | ||
| 49 | (ssl-certificate-key hwp-site-configuration-nginx | ||
| 50 | (default #f)) | ||
| 51 | (theme hwp-site-configuration-theme | ||
| 52 | (default #nil))) | ||
| 53 | |||
| 54 | (define hwp-directory "/var/lib/hwp/") | ||
| 55 | (define (hwp-site-configuration->site-build-dir config) | ||
| 56 | (string-append hwp-directory "www/" (hwp-site-configuration-name config))) | ||
| 41 | 57 | ||
| 58 | (define (hwp-nginx-server-configurations config) | ||
| 59 | (match-record config <hwp-site-configuration> | ||
| 60 | (name domains ssl-certificate ssl-certificate-key) | ||
| 61 | (list | ||
| 62 | (nginx-server-configuration | ||
| 63 | (server-name domains) | ||
| 64 | (listen '("443 ssl")) | ||
| 65 | (ssl-certificate ssl-certificate) | ||
| 66 | (ssl-certificate-key ssl-certificate-key) | ||
| 67 | (root (hwp-site-configuration->site-build-dir config)) | ||
| 68 | )))) | ||
| 42 | 69 | ||
| 43 | (define (make-hwp-start-script config) | 70 | (define (make-hwp-start-script config) |
| 44 | (match-record config <hwp-site-configuration> | 71 | (match-record config <hwp-site-configuration> |
| 45 | (name) | 72 | (name domains) |
| 46 | (program-file (string-append "hwp-" name) | 73 | (program-file |
| 74 | (string-append "build-" name) | ||
| 47 | (with-extensions (cons | 75 | (with-extensions (cons |
| 48 | hipis-web-site | 76 | hipis-web-site |
| 49 | (map cadr | 77 | (map cadr |
| @@ -51,26 +79,31 @@ | |||
| 51 | (package-propagated-inputs hipis-web-site)))) | 79 | (package-propagated-inputs hipis-web-site)))) |
| 52 | #~(begin | 80 | #~(begin |
| 53 | (use-modules (hwp)) | 81 | (use-modules (hwp)) |
| 54 | (hwp-run '(_ "/tmp/in" "/tmp/out"))))))) | 82 | (hwp-build #$(hwp-site-configuration-source-url config) |
| 83 | #$(hwp-site-configuration->site-build-dir config))))))) | ||
| 55 | 84 | ||
| 56 | (define (hwp-activation config) | 85 | (define (hwp-activation config) |
| 57 | (match-record config <hwp-site-configuration> | 86 | (match-record config <hwp-site-configuration> |
| 58 | (name theme) | 87 | (name) |
| 59 | (let* ((hwp-directory "/var/lib/hwp") | 88 | (let* ((hwp-site-script (string-append hwp-directory "/hwp-" name)) |
| 60 | (hwp-site-script (string-append hwp-directory "/hwp-" name)) | 89 | (message (string-append "Script for building website is generated: " |
| 61 | (message (string-append "Script for building websites is generated in: " | ||
| 62 | hwp-site-script))) | 90 | hwp-site-script))) |
| 63 | (with-imported-modules '((guix build utils)) | 91 | (with-imported-modules '((guix build utils)) |
| 64 | #~(begin | 92 | #~(begin |
| 65 | (use-modules (guix build utils)) | 93 | (use-modules (guix build utils)) |
| 66 | (mkdir-p #$hwp-directory) | 94 | (mkdir-p #$hwp-directory) |
| 67 | (copy-file #$(make-hwp-start-script config) #$hwp-site-script) | 95 | (mkdir-p #$(hwp-site-configuration->site-build-dir config)) |
| 96 | (copy-file #$(make-hwp-start-script config) | ||
| 97 | #$hwp-site-script) | ||
| 68 | (display #$message)))))) | 98 | (display #$message)))))) |
| 69 | 99 | ||
| 100 | |||
| 70 | (define hwp-service-type | 101 | (define hwp-service-type |
| 71 | (service-type (name 'hwp) | 102 | (service-type (name 'hwp) |
| 72 | (extensions | 103 | (extensions |
| 73 | (list (service-extension activation-service-type | 104 | (list (service-extension nginx-service-type |
| 105 | hwp-nginx-server-configurations) | ||
| 106 | (service-extension activation-service-type | ||
| 74 | hwp-activation))) | 107 | hwp-activation))) |
| 75 | (description | 108 | (description |
| 76 | "hipis-web-page: Automatically build guile haunt pages."))) | 109 | "hipis-web-page: Automatically build guile haunt pages."))) |
