about summary refs log tree commit diff
path: root/genenetwork-development.scm
diff options
context:
space:
mode:
authorArun Isaac2023-10-05 14:32:35 +0100
committerArun Isaac2023-10-05 15:00:31 +0100
commitf33e3ec81bb9e0d93dcc2592f85ebcb142746ec0 (patch)
tree38d1ecb7de46c9f9591894ec3dbb8d5622684143 /genenetwork-development.scm
parent424aed11628f6b9dbffe5a1996a7c87cb89981a1 (diff)
downloadgn-machines-f33e3ec81bb9e0d93dcc2592f85ebcb142746ec0.tar.gz
Construct yoyo.ini using guile-ini.
Constructing INI files from S-expressions instead of using string
substitutions is a little nicer.

* genenetwork-development.scm (gn-auth-migrations-yoyo-ini-gexp): New
function.
(gn-auth-migrations): Use gn-auth-migrations-yoyo-ini-gexp.
Diffstat (limited to 'genenetwork-development.scm')
-rw-r--r--genenetwork-development.scm33
1 files changed, 24 insertions, 9 deletions
diff --git a/genenetwork-development.scm b/genenetwork-development.scm
index a9b8934..687f95f 100644
--- a/genenetwork-development.scm
+++ b/genenetwork-development.scm
@@ -35,7 +35,7 @@
              ((gnu packages gnupg) #:select (guile-gcrypt))
              ((gnu packages graphviz) #:select (graphviz))
              ((gnu packages guile) #:select (guile-3.0 guile-git guile-zlib))
-             ((gnu packages guile-xyz) #:select (guile-dbd-mysql guile-dbi guile-hashing guile-lib guile-libyaml))
+             ((gnu packages guile-xyz) #:select (guile-dbd-mysql guile-dbi guile-hashing guile-ini guile-lib guile-libyaml guile-smc))
              ((gnu packages guile-xyz) #:select (guile-sparql) #:prefix guix:)
              ((gnu packages haskell-apps) #:select (shellcheck))
              ((gnu packages python-check) #:select (python-mypy))
@@ -227,6 +227,27 @@ command to be executed."
   (genenetwork3-tests (list "pytest" "-k" "unit_test")
                       (package->development-manifest genenetwork3)))
 
+(define (gn-auth-migrations-yoyo-ini-gexp config)
+  "Return a G-expression to construct a @file{yoyo.ini} configuration
+file for a genenetwork service described by @var{config}, a
+@code{<genenetwork-configuration>} object."
+  (match-record config <genenetwork-configuration>
+    (auth-db-path)
+    (with-extensions (list guile-ini guile-lib guile-smc)
+      #~ (begin
+           (use-modules (srfi srfi-26)
+                        (ini))
+
+           (call-with-output-file #$output
+             (cut scm->ini
+                  `(("DEFAULT"
+                     ("sources" . "gn-auth/migrations/auth/")
+                     ("database" . #$(string-append "sqlite:///" auth-db-path))
+                     ("migration_table" . "_yoyo_migration")
+                     ("batch_mode" . "on")
+                     ("verbosity" . "2")))
+                  #:port <>))))))
+
 (define (gn-auth-migrations config)
   "Return a G-expression that runs the migrations for the
 auth(entic|oris)ation database. This is the actual migration run by
@@ -245,14 +266,8 @@ the genenetwork user."
           ;; Run migrations.
 	  (invoke #$(file-append yoyo-migrations "/bin/yoyo")
 		  "apply" "--config"
-		  #$(mixed-text-file
-		     "yoyo.ini"
-		     "[DEFAULT]\n"
-		     "sources = gn-auth/migrations/auth/\n"
-		     "database = sqlite:///" auth-db-path "\n"
-		     "migration_table = _yoyo_migration\n"
-		     "batch_mode = on\n"
-		     "verbosity = 2"))))))
+                  #$(computed-file "yoyo.ini"
+                                   (gn-auth-migrations-yoyo-ini-gexp config)))))))
 
 (define (gn-auth-migrations-laminar config)
   "Return a G-expression that runs the migrations for the