diff --git a/nixos/modules/services/networking/pihole-ftl-setup-script.nix b/nixos/modules/services/networking/pihole-ftl-setup-script.nix index 96c0c224aeb1..692d9fc2b050 100644 --- a/nixos/modules/services/networking/pihole-ftl-setup-script.nix +++ b/nixos/modules/services/networking/pihole-ftl-setup-script.nix @@ -15,6 +15,7 @@ let comment = list.description; }; payloads = map makePayload cfg.lists; + macvendorURL = lib.strings.escapeShellArg cfg.macvendorURL; in '' # Can't use -u (unset) because api.sh uses API_URL before it is set @@ -22,8 +23,10 @@ in pihole="${lib.getExe pihole}" jq="${lib.getExe pkgs.jq}" + ${lib.getExe pkgs.curl} --retry 3 --retry-delay 5 "${macvendorURL}" -o "${cfg.settings.files.macvendor}" || echo "Failed to download MAC database from ${macvendorURL}" + # If the database doesn't exist, it needs to be created with gravity.sh - if [ ! -f '${cfg.stateDirectory}'/gravity.db ]; then + if [ ! -f '${cfg.settings.files.gravity}' ]; then $pihole -g # Send SIGRTMIN to FTL, which makes it reload the database, opening the newly created one ${lib.getExe' pkgs.procps "kill"} -s SIGRTMIN $(systemctl show --property MainPID --value ${config.systemd.services.pihole-ftl.name}) diff --git a/nixos/modules/services/networking/pihole-ftl.nix b/nixos/modules/services/networking/pihole-ftl.nix index afc8ad4507f7..25c3634d145e 100644 --- a/nixos/modules/services/networking/pihole-ftl.nix +++ b/nixos/modules/services/networking/pihole-ftl.nix @@ -118,6 +118,14 @@ in ''; }; + macvendorURL = mkOption { + type = types.str; + default = "https://ftl.pi-hole.net/macvendor.db"; + description = '' + URL from which to download the macvendor.db file. + ''; + }; + pihole = mkOption { type = types.package; default = piholeScript;