diff --git a/nixos/modules/issuer.nix b/nixos/modules/issuer.nix index e0d1f6560e48748854ab5bcd4613b50c2f24cbcd..f5c8575666946022ac70676df8cd18b2bd83972c 100644 --- a/nixos/modules/issuer.nix +++ b/nixos/modules/issuer.nix @@ -139,13 +139,28 @@ in { # https://www.freedesktop.org/software/systemd/man/systemd.exec.html#RuntimeDirectory= # "The specified directory names must be relative" ... this # makes systemd create /var/lib/zkapissuer/ for us: - serviceConfig.StateDirectory = "zkapissuer"; + serviceConfig.StateDirectory = "zkapissuer-vouchers"; serviceConfig.StateDirectoryMode = "0750"; - # Bail if there is still an old (root-owned) DB file on this system. - # If you hit this, and this /var/db/ file is indeed current, move it to - # /var/lib/zkapissuer/vouchers.sqlite3 and chown it to zkapissuer:zkapissuer. - unitConfig.AssertPathExists = "!/var/db/vouchers.sqlite3"; + unitConfig.AssertPathExists = [ + # Bail if there is still an old (root-owned) DB file on this system. + # If you hit this, and this /var/db/ file is indeed current, move it + # to /var/lib/zkapissuer/vouchers.sqlite3 and chown it to + # zkapissuer:zkapissuer. + "!/var/db/vouchers.sqlite3" + + # Similarly, bail if the newer path you were just told to create -- + # /var/lib/zkapissuer/vouchers.sqlite3 -- exists. It needs to be + # moved /var/lib/zkapissuer-vouchers where a dedicated filesystem has + # been created for it. + "!/var/lib/zkapissuer/vouchers.sqlite3" + ]; + + # Only start if the dedicated vouchers database filesystem is mounted so + # that we know we're going to find our vouchers database there (or that + # we will create it in the right place). + unitConfig.Requires = ["local-fs.target"]; + unitConfig.After = ["local-fs.target"]; script = let