feat: added the two scripts to systemd
This commit is contained in:
parent
83aee45d7b
commit
1300b7f6ec
1 changed files with 42 additions and 0 deletions
42
flake.nix
42
flake.nix
|
@ -57,6 +57,48 @@
|
||||||
HOME = cfg.home;
|
HOME = cfg.home;
|
||||||
DATABASE = "database.db";
|
DATABASE = "database.db";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# oneshot scripts to run
|
||||||
|
serviceGenerator = mapAttrs' (script: time: nameValuePair (service_name script) {
|
||||||
|
description = "Service for ${desc} ${script}";
|
||||||
|
wantedBy = [ ];
|
||||||
|
after = [ "network-online.target" ];
|
||||||
|
environment = environment_config;
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
User = "${cfg.user}";
|
||||||
|
Group = "${cfg.user}";
|
||||||
|
ExecStart = "${self.defaultPackage."${system}"}/bin/${script}";
|
||||||
|
EnvironmentFile = [
|
||||||
|
"${cfg.env.ldap}"
|
||||||
|
"${cfg.env.discord}"
|
||||||
|
"${cfg.env.mail}"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
# each timer will run the above service
|
||||||
|
timerGenerator = mapAttrs' (script: time: nameValuePair (service_name script) {
|
||||||
|
description = "Timer for ${desc} ${script}";
|
||||||
|
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
partOf = [ "${service_name script}.service" ];
|
||||||
|
timerConfig = {
|
||||||
|
OnCalendar = time;
|
||||||
|
Unit = "${service_name script}.service";
|
||||||
|
Persistent = true;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
# modify these
|
||||||
|
scripts = {
|
||||||
|
# every 20 min
|
||||||
|
"update_data" = "*:0,20,40";
|
||||||
|
# groups are updated every 8 hours, offset from teh ldap
|
||||||
|
"update_users" = "01,09,17:00:00";
|
||||||
|
};
|
||||||
|
|
||||||
in {
|
in {
|
||||||
options.services."${package_name}" = {
|
options.services."${package_name}" = {
|
||||||
enable = mkEnableOption "enable ${package_name}";
|
enable = mkEnableOption "enable ${package_name}";
|
||||||
|
|
Loading…
Reference in a new issue