Stop using instanced service
This commit is contained in:
parent
012f28eb1e
commit
72a5468cb1
21
backup.nix
21
backup.nix
@ -1,7 +1,6 @@
|
||||
{ lib, config, pkgs, utils, ... }:
|
||||
let
|
||||
cfg = config.backup-helper;
|
||||
escaped-path = "/etc/machine-id";
|
||||
restic-wrapper = pkgs.writeShellApplication {
|
||||
name = "restic-wrapper";
|
||||
runtimeInputs = [
|
||||
@ -9,13 +8,13 @@ let
|
||||
pkgs.systemd
|
||||
];
|
||||
text = ''
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Need exactly one argument, the path to backup.";
|
||||
if [ -z "$BACKUP_HELPER_DIRS" ]; then
|
||||
echo "BACKUP_HELPER_DIRS is not set";
|
||||
exit 1;
|
||||
fi
|
||||
path="$1";
|
||||
echo "Starting backup of $path";
|
||||
# restic backup ${escaped-path};
|
||||
for i in ''${BACKUP_HELPER_DIRS//,/ }; do
|
||||
echo "Starting backup of $i";
|
||||
done
|
||||
'';
|
||||
};
|
||||
in
|
||||
@ -49,28 +48,26 @@ in
|
||||
};
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.services."backup-helper@" = {
|
||||
systemd.services."backup-helper" = {
|
||||
after = [ "network-online.target" ];
|
||||
environment = {
|
||||
RESTIC_REPOSITORY = cfg.restic-repository;
|
||||
BACKUP_HELPER_DIRS = lib.strings.concatStringsSep "," cfg.backup-dirs;
|
||||
} // lib.attrsets.optionalAttrs (builtins.hasAttr "password-file" cfg) {
|
||||
RESTIC_PASSWORD_FILE = cfg.password-file;
|
||||
};
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${restic-wrapper}/bin/restic-wrapper %f";
|
||||
ExecStart = "${restic-wrapper}/bin/restic-wrapper";
|
||||
};
|
||||
};
|
||||
systemd.timers."backup-helper@" = {
|
||||
systemd.timers."backup-helper" = {
|
||||
timerConfig = {
|
||||
OnCalendar = cfg.schedule;
|
||||
Persistent = true;
|
||||
RandomizedDelaySec = cfg.randomized-delay;
|
||||
};
|
||||
};
|
||||
systemd.timers.${escaped-path} = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
overrideStrategy = "asDropin";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user