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.

47 lines
1.1 KiB

  1. { pkgs, lib, config, nodes, ... }:
  2. with lib;
  3. {
  4. options.hpc.hostFile = {
  5. addresses = mkOption {
  6. description = ''
  7. IP addresses of this host
  8. '';
  9. type = types.listOf types.str;
  10. default =
  11. let
  12. interface = config.networking.interfaces.${config.networking.defaultGateway.interface};
  13. in
  14. concatLists [
  15. (map (e: e.address) interface.ipv4.addresses)
  16. (map (e: e.address) interface.ipv6.addresses)
  17. ];
  18. };
  19. aliases = mkOption {
  20. description = ''
  21. Aliases for this host
  22. '';
  23. type = types.listOf types.str;
  24. default = [ ];
  25. };
  26. entries = mkOption {
  27. description = ''
  28. Host name entries for this host
  29. '';
  30. type = types.listOf types.str;
  31. readOnly = true;
  32. default = [ config.networking.fqdn config.networking.hostName ] ++ config.hpc.hostFile.aliases;
  33. };
  34. };
  35. config = {
  36. networking.hosts = listToAttrs (concatMap
  37. (node: map
  38. (address: nameValuePair address node.config.hpc.hostFile.entries)
  39. node.config.hpc.hostFile.addresses)
  40. (attrValues nodes));
  41. };
  42. }