diff --git a/flake.lock b/flake.lock index 152a62e..4c3eae3 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1625601352, - "narHash": "sha256-yCvbAC+gadcmW94KvXbTLWC5erkcKClQWX3G8k5O7u0=", + "lastModified": 1625919529, + "narHash": "sha256-Epn7JRegnKN81hQh4hGx1FOwfp3fBxDCIuSZDgqaBQ4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9d1350d9d56411b685ff3de5839ed6728b1bf808", + "rev": "cf59fbd539681f5ec2f4a82cf77aae7ab827a03f", "type": "github" }, "original": { @@ -23,11 +23,11 @@ }, "unstable": { "locked": { - "lastModified": 1625533413, - "narHash": "sha256-D4Dp2qDmY3Y9/Mqxsha/18F0RsH3hPiHafG4bvTz2V4=", + "lastModified": 1625874246, + "narHash": "sha256-7cGgcysIXz/j/lRpJn7cNJjf0+k7sQ5EuGn62252Svw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "036dc0c709650e0c833822307af801f576d67273", + "rev": "45fc7d4a35c5343e58541a7847f6415654ccbb37", "type": "github" }, "original": { diff --git a/modules/phpipam.nix b/modules/phpipam.nix index 8e0b5fb..2b17a54 100644 --- a/modules/phpipam.nix +++ b/modules/phpipam.nix @@ -21,6 +21,12 @@ let ''; }; + cronScripts = { + phpipam_ping = "exec ${pkgs.php}/bin/php ${phpipamHtdocs}/functions/scripts/pingCheck.php"; + phpipam_remove_offline = "exec ${pkgs.php}/bin/php ${phpipamHtdocs}/functions/scripts/remove_offline_addresses.php"; + phpipam_discovery = "exec ${pkgs.php}/bin/php ${phpipamHtdocs}/functions/scripts/discoveryCheck.php"; + }; + in { options.sconfig.phpipam = { @@ -51,20 +57,18 @@ in config = lib.mkIf cfg.enable { - systemd.services = { - phpipam_ping = { - script = "exec ${pkgs.php}/bin/php ${phpipamHtdocs}/functions/scripts/pingCheck.php"; + systemd.services = builtins.mapAttrs + (_: script: { + inherit script; environment.IPAM_DATABASE_USER = "nginx"; serviceConfig.User = "nginx"; startAt = "*:0/15"; - }; - phpipam_discovery = { - script = "exec ${pkgs.php}/bin/php ${phpipamHtdocs}/functions/scripts/discoveryCheck.php"; - environment.IPAM_DATABASE_USER = "nginx"; - serviceConfig.User = "nginx"; - startAt = "*:0/15"; - }; - }; + }) + cronScripts; + + systemd.timers = builtins.mapAttrs + (_: _: { timerConfig.RandomizedDelaySec = 600; }) + cronScripts; services = {