diff --git a/README.md b/README.md index ae75ecd..737245d 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ through (standard) environment variables. ``` custom.restic-alarm = { enable = true; - env_file = "/path/to/secret/env"; + environmentFile = "/path/to/secret/env"; }; ``` where `/path/to/secret/env` points to a file containing the environment diff --git a/flake.nix b/flake.nix index 1512e58..ecd6a5d 100644 --- a/flake.nix +++ b/flake.nix @@ -49,7 +49,16 @@ options.custom.restic-alarm = { enable = mkEnableOption (lib.mdDoc "restic-alarm: send alarms for inactive backups"); - env_file = mkOption { + extraEnvironment = mkOption { + type = types.attrsOf types.str; + description = "Extra environment variables to pass to restic-alarm"; + default = { }; + example = { + AWS_ENDPOINT_URL = "https://mygarage.net"; + }; + }; + + environmentFile = mkOption { type = types.path; description = lib.mdDoc "The file containing the environment variables to pass to restic-alarm, for e.g. S3 access keys"; @@ -65,18 +74,20 @@ after = [ "network.target" "network-online.target" ]; wants = [ "network.target" "network-online.target" ]; wantedBy = [ "multi-user.target" ]; - restartTriggers = [ cfg.env_file ]; + restartTriggers = [ cfg.environmentFile ]; serviceConfig = { ExecStart = "${pkg}/bin/restic-alarm"; DynamicUser = true; - EnvironmentFile = "${cfg.env_file}"; + EnvironmentFile = "${cfg.environmentFile}"; }; + environment = cfg.extraEnvironment; }; systemd.timers.restic-alarm = { partOf = [ "restic-alarm.service" ]; wantedBy = [ "timers.target" ]; after = [ "network-online.target" ]; + wants = [ "network-online.target" ]; timerConfig = { Unit = "restic-alarm.service"; Persistent = true;