configurations of hq services
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

configuration.nix 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. { config, pkgs, lib, modulesPath, ... }:
  2. let
  3. freifunkNodes = {
  4. "1139" = "10.200.4.120";
  5. "1487" = "10.200.5.213";
  6. "1884" = "10.200.7.100";
  7. "1891" = "10.200.7.107";
  8. "1768" = "10.200.6.239";
  9. "1176" = "10.200.7.80";
  10. "1099" = "10.200.4.80";
  11. };
  12. in {
  13. imports = [
  14. (modulesPath + "/profiles/minimal.nix")
  15. ../../../lib
  16. ../../../lib/lxc-container.nix
  17. ../../../lib/shared.nix
  18. ];
  19. c3d2 = {
  20. isInHq = false;
  21. hq.interface = "eth0";
  22. enableHail = false;
  23. };
  24. networking.hostName = "scrape";
  25. networking.interfaces.eth0.ipv4.addresses = [ { address = "172.20.73.32"; prefixLength = 26; } ];
  26. networking.defaultGateway = "172.20.73.1";
  27. # Required for krops
  28. services.openssh.enable = true;
  29. environment.systemPackages = [ pkgs.git ];
  30. systemd.services =
  31. let
  32. scrapers = import (
  33. builtins.fetchGit { url = "https://gitea.c3d2.de/astro/scrapers.git"; }
  34. ) {
  35. inherit pkgs;
  36. };
  37. makeService = { script, host, user ? "", password ? "" }: {
  38. script = "${scrapers.${script}}/bin/${script} ${host} ${user} ${password}";
  39. };
  40. xeriLogin = import <secrets/hosts/scrape/xeri.nix>;
  41. fhemLogin = import <secrets/hosts/scrape/fhem.nix>;
  42. matematLogin = import <secrets/hosts/scrape/matemat.nix>;
  43. makeNodeScraper = nodeId: {
  44. name = "scrape-node${nodeId}";
  45. value = makeService {
  46. script = "freifunk_node";
  47. host = freifunkNodes.${nodeId};
  48. };
  49. };
  50. in {
  51. scrape-xeri = makeService {
  52. script = "xerox";
  53. host = "xeri.hq.c3d2.de";
  54. inherit (xeriLogin) user password;
  55. };
  56. scrape-roxi = makeService {
  57. script = "xerox";
  58. host = "roxi.hq.c3d2.de";
  59. };
  60. scrape-fhem = makeService {
  61. script = "fhem";
  62. host = "fhem.hq.c3d2.de";
  63. inherit (fhemLogin) user password;
  64. };
  65. scrape-matemat = makeService {
  66. script = "matemat";
  67. host = "matemat.hq.c3d2.de";
  68. inherit (matematLogin) user password;
  69. };
  70. } // builtins.listToAttrs (map makeNodeScraper (builtins.attrNames freifunkNodes));
  71. systemd.timers =
  72. let
  73. makeTimer = service: interval: {
  74. partOf = [ "${service}.service" ];
  75. wantedBy = [ "timers.target" ];
  76. timerConfig.OnCalendar = interval;
  77. };
  78. makeNodeScraperTimer = nodeId:
  79. let
  80. name = "scrape-node${nodeId}";
  81. in {
  82. inherit name;
  83. value = makeTimer name "minutely";
  84. };
  85. in {
  86. scrape-xeri = makeTimer "scrape-xeri.service" "minutely";
  87. scrape-roxi = makeTimer "scrape-roxi.service" "minutely";
  88. scrape-fhem = makeTimer "scrape-fhem.service" "minutely";
  89. scrape-matemat = makeTimer "scrape-matemat.service" "minutely";
  90. } // builtins.listToAttrs (map makeNodeScraperTimer (builtins.attrNames freifunkNodes));
  91. # This value determines the NixOS release with which your system is to be
  92. # compatible, in order to avoid breaking some software such as database
  93. # servers. You should change this only after NixOS release notes say you
  94. # should.
  95. system.stateVersion = "20.03"; # Did you read the comment?
  96. }