mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 17:31:34 +01:00
Rename dependentService to conflictingService
This commit is contained in:
parent
73e0441fd4
commit
bf87931934
7 changed files with 15 additions and 18 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
config = lib.mkIf config.custom.services.actualbudget.backups.enable {
|
config = lib.mkIf config.custom.services.actualbudget.backups.enable {
|
||||||
custom.services.resticBackups.actual = {
|
custom.services.resticBackups.actual = {
|
||||||
dependentService = "actual.service";
|
conflictingService = "actual.service";
|
||||||
extraConfig.paths = [ config.services.actual.settings.dataDir ];
|
extraConfig.paths = [ config.services.actual.settings.dataDir ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
config = lib.mkIf config.custom.services.forgejo.backups.enable {
|
config = lib.mkIf config.custom.services.forgejo.backups.enable {
|
||||||
custom.services.resticBackups.forgejo = {
|
custom.services.resticBackups.forgejo = {
|
||||||
dependentService = "forgejo.service";
|
conflictingService = "forgejo.service";
|
||||||
extraConfig.paths = [ config.services.forgejo.stateDir ];
|
extraConfig.paths = [ config.services.forgejo.stateDir ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
config = lib.mkIf config.custom.services.hedgedoc.backups.enable {
|
config = lib.mkIf config.custom.services.hedgedoc.backups.enable {
|
||||||
custom.services.resticBackups.hedgedoc = {
|
custom.services.resticBackups.hedgedoc = {
|
||||||
dependentService = "hedgedoc.service";
|
conflictingService = "hedgedoc.service";
|
||||||
extraConfig.paths = with config.services.hedgedoc.settings; [
|
extraConfig.paths = with config.services.hedgedoc.settings; [
|
||||||
uploadsPath
|
uploadsPath
|
||||||
db.storage
|
db.storage
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
let
|
let
|
||||||
resticBackups = lib.filterAttrs (_: value: value.enable) config.custom.services.resticBackups;
|
resticBackups = lib.filterAttrs (_: value: value.enable) config.custom.services.resticBackups;
|
||||||
|
|
||||||
# user = config.users.users.restic.name;
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.custom.services.resticBackups = lib.mkOption {
|
options.custom.services.resticBackups = lib.mkOption {
|
||||||
|
|
@ -12,7 +10,7 @@ in
|
||||||
enable = lib.mkEnableOption "" // {
|
enable = lib.mkEnableOption "" // {
|
||||||
default = true;
|
default = true;
|
||||||
};
|
};
|
||||||
dependentService = lib.mkOption {
|
conflictingService = lib.mkOption {
|
||||||
type = lib.types.nullOr lib.types.nonEmptyStr;
|
type = lib.types.nullOr lib.types.nonEmptyStr;
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
|
|
@ -38,7 +36,6 @@ in
|
||||||
name: value:
|
name: value:
|
||||||
lib.mkMerge [
|
lib.mkMerge [
|
||||||
{
|
{
|
||||||
#inherit user;
|
|
||||||
initialize = true;
|
initialize = true;
|
||||||
repository = "s3:https://s3.eu-central-003.backblazeb2.com/stork-atlas/${name}";
|
repository = "s3:https://s3.eu-central-003.backblazeb2.com/stork-atlas/${name}";
|
||||||
environmentFile = config.sops.secrets."restic/environment".path;
|
environmentFile = config.sops.secrets."restic/environment".path;
|
||||||
|
|
@ -63,11 +60,11 @@ in
|
||||||
|> lib.mapAttrs' (
|
|> lib.mapAttrs' (
|
||||||
name: value:
|
name: value:
|
||||||
lib.nameValuePair "restic-backups-${name}" (
|
lib.nameValuePair "restic-backups-${name}" (
|
||||||
lib.mkIf (value.dependentService != null) {
|
lib.mkIf (value.conflictingService != null) {
|
||||||
unitConfig.Conflicts = [ value.dependentService ];
|
unitConfig.Conflicts = [ value.conflictingService ];
|
||||||
after = [ value.dependentService ];
|
after = [ value.conflictingService ];
|
||||||
onSuccess = [ value.dependentService ];
|
onSuccess = [ value.conflictingService ];
|
||||||
onFailure = [ value.dependentService ];
|
onFailure = [ value.conflictingService ];
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -40,15 +40,15 @@ in
|
||||||
name = "restic-restore-${name}";
|
name = "restic-restore-${name}";
|
||||||
text =
|
text =
|
||||||
let
|
let
|
||||||
inherit (value) dependentService;
|
inherit (value) conflictingService;
|
||||||
hasDependentService = dependentService != null;
|
hasconflictingService = conflictingService != null;
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
${lib.optionalString hasDependentService "systemctl stop ${dependentService}"}
|
${lib.optionalString hasconflictingService "systemctl stop ${conflictingService}"}
|
||||||
${value.restoreCommand.preRestore}
|
${value.restoreCommand.preRestore}
|
||||||
restic-${name} restore latest --target /
|
restic-${name} restore latest --target /
|
||||||
${value.restoreCommand.postRestore}
|
${value.restoreCommand.postRestore}
|
||||||
${lib.optionalString hasDependentService "systemctl start ${dependentService}"}
|
${lib.optionalString hasconflictingService "systemctl start ${conflictingService}"}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ in
|
||||||
];
|
];
|
||||||
|
|
||||||
custom.services.resticBackups.syncthing = {
|
custom.services.resticBackups.syncthing = {
|
||||||
dependentService = "syncthing.service";
|
conflictingService = "syncthing.service";
|
||||||
extraConfig.paths = [ config.services.syncthing.dataDir ];
|
extraConfig.paths = [ config.services.syncthing.dataDir ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
config = lib.mkIf config.custom.services.uptimeKuma.backups.enable {
|
config = lib.mkIf config.custom.services.uptimeKuma.backups.enable {
|
||||||
custom.services.resticBackups.uptime-kuma = {
|
custom.services.resticBackups.uptime-kuma = {
|
||||||
healthchecks.enable = false;
|
healthchecks.enable = false;
|
||||||
dependentService = "uptime-kuma.service";
|
conflictingService = "uptime-kuma.service";
|
||||||
extraConfig.paths = [ "/var/lib/private/uptime-kuma" ];
|
extraConfig.paths = [ "/var/lib/private/uptime-kuma" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue