# TFTP boot with shared image # Requests store path to install from master # Runs disko and nixos-install { pkgs, lib, config, nodes, ... }@args: with lib; let targets = { "50:46:5d:da:0b:d6" = "node-00"; "50:46:5d:da:0c:56" = "node-01"; "10:bf:48:1f:a6:8f" = "node-02"; "10:bf:48:1b:57:47" = "node-03"; "10:bf:48:19:a2:4d" = "node-04"; "10:bf:48:1b:56:df" = "node-05"; "50:46:5d:da:0c:52" = "node-06"; }; installer = pkgs.nixos [ ./installer.nix { _module.args = { nodes = getAttrs [ "manager" ] nodes; }; } ]; apiEntry = name: let node = nodes.${name}.config.system.build; boot = installer.config.system.build; install = pkgs.writeScript "install-${name}" '' #!/usr/bin/env bash set -xeuo pipefail "${node.diskoScript}" "${node.nixos-install}/bin/nixos-install" \ --root /mnt \ --system "${node.toplevel}" \ --no-channel-copy \ --no-root-password \ --verbose reboot ''; in pkgs.writeText "pixieboot-api-${name}" (builtins.toJSON { kernel = "file://${boot.kernel}/bzImage"; initrd = [ "file://${boot.netbootRamdisk}/initrd" ]; cmdline = concatStringsSep " " [ "init=${boot.toplevel}/init" "loglevel=4" "nixos.install=${install}" ]; message = "NixOS Automatic Installer for ${name}"; }); api = pkgs.linkFarm "pixiecore-api" (mapAttrs' (mac: name: nameValuePair "pixiecore/v1/boot/${mac}" (apiEntry name)) targets); in { services.pixiecore = { enable = true; mode = "api"; dhcpNoBind = true; debug = true; openFirewall = true; port = 5080; statusPort = 6080; apiServer = "http://boot.${config.networking.domain}/pixiecore"; }; services.nginx = { virtualHosts = { "boot.${config.networking.domain}" = { locations."/".proxyPass = "http://localhost:${toString config.services.pixiecore.port}"; locations."/status".proxyPass = "http://localhost:${toString config.services.pixiecore.statusPort}"; locations."/pixiecore".root = api; }; }; }; services.dhcpd4 = { enable = true; interfaces = [ "enp11s0f0" ]; extraConfig = '' option domain-name-servers 10.0.0.53, 10.1.1.10; option domain-name "${config.networking.domain}"; subnet 10.32.47.0 netmask 255.255.255.0 { interface enp11s0f0; range 10.32.47.200 10.32.47.230; option routers 10.32.47.1; } ''; }; hpc.hostFile.aliases = [ "boot.${config.networking.domain}" ]; }