mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 04:05:40 +03:00
treewide: format all inactive Nix files
After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
This commit is contained in:
parent
b32a094368
commit
4f0dadbf38
21293 changed files with 701351 additions and 428307 deletions
|
@ -1,9 +1,15 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
|
||||
cfg = config.services.postgresqlBackup;
|
||||
|
||||
postgresqlBackupService = db: dumpCmd:
|
||||
postgresqlBackupService =
|
||||
db: dumpCmd:
|
||||
let
|
||||
compressSuffixes = {
|
||||
"none" = "";
|
||||
|
@ -23,14 +29,18 @@ let
|
|||
prevFile = mkSqlPath ".prev" compressSuffix;
|
||||
prevFiles = map (mkSqlPath ".prev") (lib.attrValues compressSuffixes);
|
||||
inProgressFile = mkSqlPath ".in-progress" compressSuffix;
|
||||
in {
|
||||
in
|
||||
{
|
||||
enable = true;
|
||||
|
||||
description = "Backup of ${db} database(s)";
|
||||
|
||||
requires = [ "postgresql.service" ];
|
||||
|
||||
path = [ pkgs.coreutils config.services.postgresql.package ];
|
||||
path = [
|
||||
pkgs.coreutils
|
||||
config.services.postgresql.package
|
||||
];
|
||||
|
||||
script = ''
|
||||
set -e -o pipefail
|
||||
|
@ -57,12 +67,13 @@ let
|
|||
startAt = cfg.startAt;
|
||||
};
|
||||
|
||||
in {
|
||||
in
|
||||
{
|
||||
|
||||
imports = [
|
||||
(lib.mkRemovedOptionModule [ "services" "postgresqlBackup" "period" ] ''
|
||||
A systemd timer is now used instead of cron.
|
||||
The starting time can be configured via <literal>services.postgresqlBackup.startAt</literal>.
|
||||
A systemd timer is now used instead of cron.
|
||||
The starting time can be configured via <literal>services.postgresqlBackup.startAt</literal>.
|
||||
'')
|
||||
];
|
||||
|
||||
|
@ -81,7 +92,7 @@ in {
|
|||
};
|
||||
|
||||
backupAll = lib.mkOption {
|
||||
default = cfg.databases == [];
|
||||
default = cfg.databases == [ ];
|
||||
defaultText = lib.literalExpression "services.postgresqlBackup.databases == []";
|
||||
type = lib.types.bool;
|
||||
description = ''
|
||||
|
@ -94,7 +105,7 @@ in {
|
|||
};
|
||||
|
||||
databases = lib.mkOption {
|
||||
default = [];
|
||||
default = [ ];
|
||||
type = lib.types.listOf lib.types.str;
|
||||
description = ''
|
||||
List of database names to dump.
|
||||
|
@ -121,7 +132,11 @@ in {
|
|||
};
|
||||
|
||||
compression = lib.mkOption {
|
||||
type = lib.types.enum ["none" "gzip" "zstd"];
|
||||
type = lib.types.enum [
|
||||
"none"
|
||||
"gzip"
|
||||
"zstd"
|
||||
];
|
||||
default = "gzip";
|
||||
description = ''
|
||||
The type of compression to use on the generated database dump.
|
||||
|
@ -144,13 +159,14 @@ in {
|
|||
{
|
||||
assertions = [
|
||||
{
|
||||
assertion = cfg.backupAll -> cfg.databases == [];
|
||||
assertion = cfg.backupAll -> cfg.databases == [ ];
|
||||
message = "config.services.postgresqlBackup.backupAll cannot be used together with config.services.postgresqlBackup.databases";
|
||||
}
|
||||
{
|
||||
assertion = cfg.compression == "none" ||
|
||||
(cfg.compression == "gzip" && cfg.compressionLevel >= 1 && cfg.compressionLevel <= 9) ||
|
||||
(cfg.compression == "zstd" && cfg.compressionLevel >= 1 && cfg.compressionLevel <= 19);
|
||||
assertion =
|
||||
cfg.compression == "none"
|
||||
|| (cfg.compression == "gzip" && cfg.compressionLevel >= 1 && cfg.compressionLevel <= 9)
|
||||
|| (cfg.compression == "zstd" && cfg.compressionLevel >= 1 && cfg.compressionLevel <= 19);
|
||||
message = "config.services.postgresqlBackup.compressionLevel must be set between 1 and 9 for gzip and 1 and 19 for zstd";
|
||||
}
|
||||
];
|
||||
|
@ -161,17 +177,21 @@ in {
|
|||
];
|
||||
})
|
||||
(lib.mkIf (cfg.enable && cfg.backupAll) {
|
||||
systemd.services.postgresqlBackup =
|
||||
postgresqlBackupService "all" "pg_dumpall";
|
||||
systemd.services.postgresqlBackup = postgresqlBackupService "all" "pg_dumpall";
|
||||
})
|
||||
(lib.mkIf (cfg.enable && !cfg.backupAll) {
|
||||
systemd.services = lib.listToAttrs (map (db:
|
||||
let
|
||||
cmd = "pg_dump ${cfg.pgdumpOptions} ${db}";
|
||||
in {
|
||||
name = "postgresqlBackup-${db}";
|
||||
value = postgresqlBackupService db cmd;
|
||||
}) cfg.databases);
|
||||
systemd.services = lib.listToAttrs (
|
||||
map (
|
||||
db:
|
||||
let
|
||||
cmd = "pg_dump ${cfg.pgdumpOptions} ${db}";
|
||||
in
|
||||
{
|
||||
name = "postgresqlBackup-${db}";
|
||||
value = postgresqlBackupService db cmd;
|
||||
}
|
||||
) cfg.databases
|
||||
);
|
||||
})
|
||||
];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue