- Nix 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| AGENTS.md | ||
| COPYING | ||
| flake.lock | ||
| flake.nix | ||
| module.nix | ||
| README.md | ||
PostgreSQL collation repair
A NixOS module that detects collation-version drift after PostgreSQL package or
system collation-library upgrades, then refreshes the recorded PostgreSQL
collation versions. It exports nixosModules.default.
PostgreSQL records and compares per-database collation versions starting with PostgreSQL 15. On earlier releases the service exits without making changes, because that tracking is unavailable.
Warning
By default, drifted databases are reindexed before their collation version is refreshed.
REINDEX DATABASEcan take substantial time and acquire locks that block database activity. Plan maintenance windows and backups accordingly. Disabling reindexing only clears PostgreSQL's mismatch warning; indexes retain the old sort order and may be incorrect unless rebuilt separately.
Use
Add the flake as an input and import its NixOS module:
{
inputs.postgresql-collation.url = "...";
outputs = { postgresql-collation, ... }: {
nixosConfigurations.host = nixpkgs.lib.nixosSystem {
modules = [ postgresql-collation.nixosModules.default ];
};
};
}
The repair service is enabled automatically whenever services.postgresql.enable
is enabled, and reindexes before refreshing versions:
{
services.postgresql.enable = true;
}
To keep the service enabled but refresh versions without reindexing, explicitly accept the operational risk and configure:
{
services.postgresql = {
enable = true;
collationRepair.reindex = false;
};
}
To disable the service entirely, set services.postgresql.collationRepair.enable = false.
License
Copyright 2026 Alexander Khodyrev. Licensed under the GNU Affero General Public License, version 3 or later. See COPYING.