NixOS deployment for LinuxLab
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.

85 lines
1.7 KiB

  1. { pkgs, lib, config, nodes, ... }:
  2. with lib;
  3. let
  4. installer = pkgs.nixos [
  5. ../../installer
  6. {
  7. _module.args = {
  8. target = nodes."client";
  9. };
  10. }
  11. ];
  12. ipxe-script = pkgs.writeText "boot-local.ipxe" ''
  13. #!ipxe
  14. sleep 2
  15. prompt --key 0x18 --timeout 5000 Press Ctrl-X to re-deploy system... || goto local
  16. echo "Starting installer..."
  17. sleep 2
  18. kernel --name kernel http://''${next-server:ipv4}/bzImage || goto err
  19. initrd --name initrd http://''${next-server:ipv4}/initrd || goto err
  20. boot kernel initrd=initrd init=${installer.config.system.build.toplevel}/init loglevel=4 || goto err
  21. :err
  22. shell
  23. :local
  24. echo "Booting local disk..."
  25. sleep 2
  26. sanboot -n -d 0x80
  27. '';
  28. in
  29. {
  30. services.nginx = {
  31. enable = true;
  32. virtualHosts."boot.${config.networking.domain}" = {
  33. locations."/" = {
  34. root = pkgs.linkFarm "root" {
  35. "bzImage" = installer.config.system.build.kernel + "/bzImage";
  36. "initrd" = installer.config.system.build.netbootRamdisk + "/initrd";
  37. };
  38. };
  39. };
  40. };
  41. services.pixiecore =
  42. {
  43. enable = true;
  44. debug = true;
  45. dhcpNoBind = true;
  46. port = 5080;
  47. mode = "boot";
  48. kernel = toString ipxe-script;
  49. openFirewall = true;
  50. };
  51. # Ensure the intaller script and therefore the client system is part of the
  52. # store so it can be fetched by the installer.
  53. boot.postBootCommands = ''
  54. ${config.nix.package.out}/bin/nix-env -p /nix/var/nix/profiles/installer --set "${installer.installer}"
  55. '';
  56. networking.extraHosts = ''
  57. 127.0.0.1 boot.${config.networking.domain}
  58. '';
  59. networking.firewall.allowedTCPPorts = [
  60. 80 # HTTP
  61. ];
  62. }