nixos module: add the ability to pass environment variables from the config
This commit is contained in:
parent
7ca272b612
commit
0139f6bac5
2 changed files with 15 additions and 4 deletions
|
@ -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
|
||||
|
|
17
flake.nix
17
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;
|
||||
|
|
Loading…
Add table
Reference in a new issue