NixOS configuration for HPC cluster https://docs.hpc.informatik.hs-fulda.de/
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.

108 lines
2.6 KiB

  1. # TFTP boot with shared image
  2. # Requests store path to install from master
  3. # Runs disko and nixos-install
  4. { pkgs, lib, config, nodes, ... }@args:
  5. with lib;
  6. let
  7. targets = {
  8. "50:46:5d:da:0b:d6" = "node-00";
  9. "50:46:5d:da:0c:56" = "node-01";
  10. "10:bf:48:1f:a6:8f" = "node-02";
  11. "10:bf:48:1b:57:47" = "node-03";
  12. "10:bf:48:19:a2:4d" = "node-04";
  13. "10:bf:48:1b:56:df" = "node-05";
  14. "50:46:5d:da:0c:52" = "node-06";
  15. };
  16. installer = pkgs.nixos [
  17. ./installer.nix
  18. {
  19. _module.args = {
  20. nodes = getAttrs [ "manager" ] nodes;
  21. };
  22. }
  23. ];
  24. apiEntry = name:
  25. let
  26. node = nodes.${name}.config.system.build;
  27. boot = installer.config.system.build;
  28. install = pkgs.writeScript "install-${name}" ''
  29. #!/usr/bin/env bash
  30. set -xeuo pipefail
  31. "${node.diskoScript}"
  32. "${node.nixos-install}/bin/nixos-install" \
  33. --root /mnt \
  34. --system "${node.toplevel}" \
  35. --no-channel-copy \
  36. --no-root-password \
  37. --verbose
  38. reboot
  39. '';
  40. in
  41. pkgs.writeText "pixieboot-api-${name}" (builtins.toJSON {
  42. kernel = "file://${boot.kernel}/bzImage";
  43. initrd = [ "file://${boot.netbootRamdisk}/initrd" ];
  44. cmdline = concatStringsSep " " [
  45. "init=${boot.toplevel}/init"
  46. "loglevel=4"
  47. "nixos.install=${install}"
  48. ];
  49. message = "NixOS Automatic Installer for ${name}";
  50. });
  51. api = pkgs.linkFarm "pixiecore-api" (mapAttrs'
  52. (mac: name: nameValuePair "pixiecore/v1/boot/${mac}" (apiEntry name))
  53. targets);
  54. in
  55. {
  56. services.pixiecore = {
  57. enable = true;
  58. mode = "api";
  59. dhcpNoBind = true;
  60. debug = true;
  61. openFirewall = true;
  62. port = 5080;
  63. statusPort = 6080;
  64. apiServer = "http://boot.${config.networking.domain}/pixiecore";
  65. };
  66. services.nginx = {
  67. virtualHosts = {
  68. "boot.${config.networking.domain}" = {
  69. locations."/".proxyPass = "http://localhost:${toString config.services.pixiecore.port}";
  70. locations."/status".proxyPass = "http://localhost:${toString config.services.pixiecore.statusPort}";
  71. locations."/pixiecore".root = api;
  72. };
  73. };
  74. };
  75. services.dhcpd4 = {
  76. enable = true;
  77. interfaces = [ "enp11s0f0" ];
  78. extraConfig = ''
  79. option domain-name-servers 10.0.0.53, 10.1.1.10;
  80. option domain-name "${config.networking.domain}";
  81. subnet 10.32.47.0 netmask 255.255.255.0 {
  82. interface enp11s0f0;
  83. range 10.32.47.200 10.32.47.230;
  84. option routers 10.32.47.1;
  85. }
  86. '';
  87. };
  88. hpc.hostFile.aliases = [
  89. "boot.${config.networking.domain}"
  90. ];
  91. }