add tmpfiles

This commit is contained in:
Jeffrey C. Ollie 2023-08-10 15:34:31 -05:00
parent ed882a6b26
commit 6cf67346c4
Signed by: jeff
GPG key ID: 6F86035A6D97044E
2 changed files with 32 additions and 0 deletions

27
database-setup.nu Normal file
View file

@ -0,0 +1,27 @@
def main [
user_config: string
database_config: string
] {
alias psql = ^psql --tuples-only --no-align
if not ($user_config | path exists) {
print $"($user_config) does not exist!"
exit 1
}
if not ($database_config | path exists) {
print $"($database_config) does not exist!"
exit 1
}
let users = ($user_config | open)
let databases = ($database_config | open)
$users | debug
$databases | debug
$users | each {
|user|
let exists = ("SELECT 1 FROM pg_roles WHERE rolname=:'username';" | psql --variable username=$"($user.username)")
$exists | debug
}
}

View file

@ -427,6 +427,11 @@
useDefaultShell = true;
};
systemd.tmpfiles.rules = [
"d /var/lib/posgresql 0750 postgresql postgresql -"
"d /var/lib/posgresql/15 0700 postgresql postgresql -"
];
systemd.services.postgresql =
let
hbaFile = pkgs.writeTextDir "pg_hba.conf" ''