db
The db host uses postgres, backups and import. knixl writes 2 files for it: the host module and 1 side-file it imports. The Nix below is the golden test output, so it is exactly what knixl emits.
host "db" { system "x86_64-linux"
postgres version=16 { listen-tcp #true // override the base preset's enableTCPIP = false database "app" database "metrics" }
backups { repo "s3:https://s3.example.com/backups/db" schedule "daily" when "config.services.postgresql.enable" // emitted as lib.mkIf <raw cond> }
import "../local/pg-tuning.nix" // hand-written module, imported beside the side-files}Generated
Section titled “Generated”# Generated by knixl 1.5.2 from hosts/db.kdl# Do NOT edit. Regenerate from the KDL source.# Overrides: add a sibling module and use lib.mkForce / lib.mkAfter.{ config, lib, pkgs, ...}:{ imports = [ ./db-backup.nix ../../local/pg-tuning.nix ];
nixpkgs.hostPlatform = "x86_64-linux"; networking.hostName = "db"; services.postgresql.enable = true; services.postgresql.package = pkgs.postgresql_16; services.postgresql.ensureDatabases = [ "app" "metrics" ]; # listen-tcp #true overrides the base preset (enableTCPIP = false) services.postgresql.enableTCPIP = (lib.mkForce true);}# Generated by knixl 1.5.2 from hosts/db.kdl# Do NOT edit. Regenerate from the KDL source.# Overrides: add a sibling module and use lib.mkForce / lib.mkAfter.{ config, lib, pkgs, ...}:{ services.restic.backups."db" = lib.mkIf (config.services.postgresql.enable) { initialize = true; pruneOpts = [ "--keep-daily 7" "--keep-weekly 4" ]; repository = "s3:https://s3.example.com/backups/db"; timerConfig = { OnCalendar = "daily"; }; };}