diff --git a/backup.nix b/backup.nix index 3c6d5bb..93a1a29 100644 --- a/backup.nix +++ b/backup.nix @@ -1,4 +1,9 @@ -{ lib, config, pkgs, utils, ... }: +{ + lib, + config, + pkgs, + ... +}: let cfg = config.backup-helper; restic-wrapper = pkgs.writeShellApplication { @@ -58,13 +63,16 @@ in }; config = lib.mkIf cfg.enable { systemd.services."backup-helper" = { + wants = [ "network-online.target" ]; 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; - }; + 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"; @@ -80,4 +88,3 @@ in }; }; } -