Rename dependentService to conflictingService

This commit is contained in:
SebastianStork 2025-06-14 15:38:03 +02:00
parent 73e0441fd4
commit bf87931934
7 changed files with 15 additions and 18 deletions

View file

@ -1,8 +1,6 @@
{ config, lib, ... }:
let
resticBackups = lib.filterAttrs (_: value: value.enable) config.custom.services.resticBackups;
# user = config.users.users.restic.name;
in
{
options.custom.services.resticBackups = lib.mkOption {
@ -12,7 +10,7 @@ in
enable = lib.mkEnableOption "" // {
default = true;
};
dependentService = lib.mkOption {
conflictingService = lib.mkOption {
type = lib.types.nullOr lib.types.nonEmptyStr;
default = null;
};
@ -38,7 +36,6 @@ in
name: value:
lib.mkMerge [
{
#inherit user;
initialize = true;
repository = "s3:https://s3.eu-central-003.backblazeb2.com/stork-atlas/${name}";
environmentFile = config.sops.secrets."restic/environment".path;
@ -63,11 +60,11 @@ in
|> lib.mapAttrs' (
name: value:
lib.nameValuePair "restic-backups-${name}" (
lib.mkIf (value.dependentService != null) {
unitConfig.Conflicts = [ value.dependentService ];
after = [ value.dependentService ];
onSuccess = [ value.dependentService ];
onFailure = [ value.dependentService ];
lib.mkIf (value.conflictingService != null) {
unitConfig.Conflicts = [ value.conflictingService ];
after = [ value.conflictingService ];
onSuccess = [ value.conflictingService ];
onFailure = [ value.conflictingService ];
}
)
);

View file

@ -40,15 +40,15 @@ in
name = "restic-restore-${name}";
text =
let
inherit (value) dependentService;
hasDependentService = dependentService != null;
inherit (value) conflictingService;
hasconflictingService = conflictingService != null;
in
''
${lib.optionalString hasDependentService "systemctl stop ${dependentService}"}
${lib.optionalString hasconflictingService "systemctl stop ${conflictingService}"}
${value.restoreCommand.preRestore}
restic-${name} restore latest --target /
${value.restoreCommand.postRestore}
${lib.optionalString hasDependentService "systemctl start ${dependentService}"}
${lib.optionalString hasconflictingService "systemctl start ${conflictingService}"}
'';
}
);