nixos/restic-rest-server: Autocreate empty .htpasswd if needed for service boot

When `privateRepos = true`, the service will not start if the `.htpasswd` does not exist.
Use `systemd-tmpfiles` to autocreate an (empty) file to ensure the service can boot
before actual `htpasswd` contents are registered.

This is safe as restic-rest-server will deny all entry if the file is empty.
This commit is contained in:
Aneesh Agrawal 2022-01-02 04:07:11 -05:00
parent 4bc4c7f1a0
commit 8729e8e261

View file

@ -95,6 +95,10 @@ in
};
};
systemd.tmpfiles.rules = mkIf cfg.privateRepos [
"f ${cfg.dataDir}/.htpasswd 0700 restic restic -"
];
users.users.restic = {
group = "restic";
home = cfg.dataDir;