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.

86 lines
2.1 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 = attrNames
  8. (filterAttrs
  9. (_: node: node.config.hpc.netinstall.enable)
  10. nodes);
  11. installer = pkgs.nixos [
  12. ./installer.nix
  13. {
  14. _module.args = {
  15. nodes = getAttrs [ "manager" ] nodes;
  16. };
  17. }
  18. ];
  19. apiEntry = name:
  20. let
  21. node = nodes.${name}.config.system.build;
  22. boot = installer.config.system.build;
  23. install = pkgs.writeScript "install-${name}" ''
  24. #!/usr/bin/env bash
  25. set -xeuo pipefail
  26. "${node.diskoScript}"
  27. "${node.nixos-install}/bin/nixos-install" \
  28. --root /mnt \
  29. --system "${node.toplevel}" \
  30. --no-channel-copy \
  31. --no-root-password \
  32. --verbose
  33. reboot
  34. '';
  35. in
  36. pkgs.writeText "pixieboot-api-${name}" (builtins.toJSON {
  37. kernel = "file://${boot.kernel}/bzImage";
  38. initrd = [ "file://${boot.netbootRamdisk}/initrd" ];
  39. cmdline = concatStringsSep " " [
  40. "init=${boot.toplevel}/init"
  41. "loglevel=4"
  42. "nixos.install=${install}"
  43. ];
  44. message = "NixOS Automatic Installer for ${name}";
  45. });
  46. api = pkgs.linkFarm "pixiecore-api" (listToAttrs (map
  47. (name: nameValuePair "pixiecore/v1/boot/${nodes."${name}".config.hpc.dhcp.reservations."data".hwAddress}" (apiEntry name))
  48. targets));
  49. in
  50. {
  51. services.pixiecore = {
  52. enable = true;
  53. mode = "api";
  54. dhcpNoBind = true;
  55. debug = true;
  56. openFirewall = true;
  57. port = 5080;
  58. statusPort = 6080;
  59. apiServer = "http://boot.${config.networking.domain}/pixiecore";
  60. };
  61. services.nginx = {
  62. virtualHosts = {
  63. "boot.${config.networking.domain}" = {
  64. locations."/".proxyPass = "http://localhost:${toString config.services.pixiecore.port}";
  65. locations."/status".proxyPass = "http://localhost:${toString config.services.pixiecore.statusPort}";
  66. locations."/pixiecore".root = api;
  67. };
  68. };
  69. };
  70. hpc.hostFile.aliases = [
  71. "boot.${config.networking.domain}"
  72. ];
  73. }