{ config, lib, ... }: let dataDir = "/var/lib/postgresql/16"; in { options.services.postgresql.impermanence.enable = lib.mkOption { type = lib.types.bool; default = config.services.postgresql.enable && config.storage.impermanence.enable; }; config = lib.mkIf config.services.postgresql.enable { storage.datasets.replicate."system/root" = { directories."${dataDir}" = lib.mkIf config.services.postgresql.impermanence.enable { owner.name = "postgres"; group.name = "postgres"; }; }; }; }