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

# 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 = attrNames
(filterAttrs
(_: node: node.config.hpc.netinstall.enable)
nodes);
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" (listToAttrs (map
(name: nameValuePair "pixiecore/v1/boot/${nodes."${name}".config.hpc.dhcp.reservations."data".hwAddress}" (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;
};
};
};
hpc.hostFile.aliases = [
"boot.${config.networking.domain}"
];
}