updated haven.nix error code

This commit is contained in:
2026-03-25 11:49:04 -05:00
parent 1dc0df2004
commit cf1c6c3ad3

View File

@@ -107,7 +107,7 @@ lib.mkIf (config.sovran_systemsOS.features.haven && npub != "") {
]; ];
systemd.services.haven-whitelist-setup = { systemd.services.haven-whitelist-setup = {
description = "Ensure Haven whitelisted_npubs.json exists"; description = "Ensure Haven whitelisted_npubs.json is valid";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
before = [ "haven.service" ]; before = [ "haven.service" ];
serviceConfig = { serviceConfig = {
@@ -115,10 +115,14 @@ lib.mkIf (config.sovran_systemsOS.features.haven && npub != "") {
RemainAfterExit = true; RemainAfterExit = true;
}; };
script = '' script = ''
if [ ! -f /var/lib/haven/whitelisted_npubs.json ]; then FILE="/var/lib/haven/whitelisted_npubs.json"
echo '[]' > /var/lib/haven/whitelisted_npubs.json if [ ! -s "$FILE" ] || ! ${pkgs.jq}/bin/jq empty "$FILE" 2>/dev/null; then
chown haven:haven /var/lib/haven/whitelisted_npubs.json echo '[]' > "$FILE"
chmod 770 /var/lib/haven/whitelisted_npubs.json chown haven:haven "$FILE"
chmod 770 "$FILE"
echo "Wrote valid empty JSON array to $FILE"
else
echo "$FILE already contains valid JSON, skipping"
fi fi
''; '';
}; };