From f33e3ec81bb9e0d93dcc2592f85ebcb142746ec0 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 5 Oct 2023 14:32:35 +0100 Subject: 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. --- genenetwork-development.scm | 33 ++++++++++++++++++++++++--------- 1 file 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{} object." + (match-record config + (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 -- cgit v1.2.3