Skip to content

Commit

Permalink
nixos/plausible: Fix shell scripting errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
nh2 committed Jul 13, 2021
1 parent 45fc7d4 commit 8613698
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions nixos/modules/services/web-apps/plausible.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ let

# FIXME consider using LoadCredential as soon as it actually works.
envSecrets = ''
export ADMIN_USER_PWD="$(<${cfg.adminUser.passwordFile})"
export SECRET_KEY_BASE="$(<${cfg.server.secretKeybaseFile})"
ADMIN_USER_PWD="$(<${cfg.adminUser.passwordFile})"
export ADMIN_USER_PWD # separate export to make `set -e` work
SECRET_KEY_BASE="$(<${cfg.server.secretKeybaseFile})"
export SECRET_KEY_BASE # separate export to make `set -e` work
${optionalString (cfg.mail.smtp.passwordFile != null) ''
export SMTP_USER_PWD="$(<${cfg.mail.smtp.passwordFile})"
SMTP_USER_PWD="$(<${cfg.mail.smtp.passwordFile})"
export SMTP_USER_PWD # separate export to make `set -e` work
''}
'';
in {
Expand Down Expand Up @@ -228,6 +233,7 @@ in {
WorkingDirectory = "/var/lib/plausible";
StateDirectory = "plausible";
ExecStartPre = "@${pkgs.writeShellScript "plausible-setup" ''
set -eu -o pipefail
${envSecrets}
${pkgs.plausible}/createdb.sh
${pkgs.plausible}/migrate.sh
Expand All @@ -238,6 +244,7 @@ in {
''}
''} plausible-setup";
ExecStart = "@${pkgs.writeShellScript "plausible" ''
set -eu -o pipefail
${envSecrets}
plausible start
''} plausible";
Expand Down

0 comments on commit 8613698

Please sign in to comment.