{ pkgs, scrapers, ... }: let freifunkNodes = { "1139" = "10.200.4.120"; "1884" = "10.200.7.100"; "1891" = "10.200.7.107"; "1099" = "10.200.4.80"; "1864" = "10.200.7.80"; }; luftqualitaetStations = [ "1672" "1649" "1680" "1639" ]; in { c3d2.isInHq = false; networking.hostName = "scrape"; networking.interfaces.eth0.ipv4.addresses = [{ address = "172.20.73.32"; prefixLength = 26; }]; networking.defaultGateway = "172.20.73.1"; # Required for krops services.openssh.enable = true; environment.systemPackages = [ pkgs.git ]; systemd.services = let scraperPkgs = import scrapers { inherit pkgs; }; makeService = { script, host ? "", user ? "", password ? "" }: { script = "${scraperPkgs.${script}}/bin/${script} ${host} ${user} ${password}"; }; makeNodeScraper = nodeId: { name = "scrape-node${nodeId}"; value = makeService { script = "freifunk_node"; host = freifunkNodes.${nodeId}; }; }; makeLuftScraper = station: { name = "scrape-luftqualitaet${station}"; value = makeService { script = "luftqualitaet"; host = station; }; }; in { scrape-xeri = makeService { script = "xerox"; host = "xeri.hq.c3d2.de"; inherit (pkgs.scrape-xeri-login) user password; }; scrape-roxi = makeService { script = "xerox"; host = "roxi.hq.c3d2.de"; }; scrape-fhem = makeService { script = "fhem"; host = "fhem.hq.c3d2.de"; inherit (pkgs.scrape-fhem-login) user password; }; scrape-matemat = makeService { script = "matemat"; host = "matemat.hq.c3d2.de"; inherit (pkgs.scrape-matemat-login) user password; }; scrape-impfee = makeService { script = "impfee"; }; } // builtins.listToAttrs (map makeNodeScraper (builtins.attrNames freifunkNodes) ++ map makeLuftScraper luftqualitaetStations ); systemd.timers = let makeTimer = service: interval: { partOf = [ "${service}.service" ]; wantedBy = [ "timers.target" ]; timerConfig.OnCalendar = interval; }; makeNodeScraperTimer = nodeId: let name = "scrape-node${nodeId}"; in { inherit name; value = makeTimer name "minutely"; }; makeLuftScraperTimer = station: let name = "scrape-luftqualitaet${station}"; in { inherit name; value = makeTimer name "hourly"; }; in { scrape-xeri = makeTimer "scrape-xeri.service" "minutely"; scrape-roxi = makeTimer "scrape-roxi.service" "minutely"; scrape-fhem = makeTimer "scrape-fhem.service" "minutely"; scrape-matemat = makeTimer "scrape-matemat.service" "minutely"; scrape-impfee = makeTimer "scrape-impfee.service" "minutely"; } // builtins.listToAttrs (map makeNodeScraperTimer (builtins.attrNames freifunkNodes) ++ (map makeLuftScraperTimer luftqualitaetStations) ); # This value determines the NixOS release with which your system is to be # compatible, in order to avoid breaking some software such as database # servers. You should change this only after NixOS release notes say you # should. system.stateVersion = "20.03"; # Did you read the comment? }