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
|
|
@ -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 ];
|
||||
}
|
||||
)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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}"}
|
||||
'';
|
||||
}
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue