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.

55 lines
1.3 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. canonical = mkOption {
  20. description = ''
  21. Canonical host name
  22. '';
  23. type = types.str;
  24. default = config.networking.fqdn;
  25. };
  26. aliases = mkOption {
  27. description = ''
  28. Aliases for this host
  29. '';
  30. type = types.listOf types.str;
  31. default = [ ];
  32. };
  33. entries = mkOption {
  34. description = ''
  35. Host name entries for this host
  36. '';
  37. type = types.listOf types.str;
  38. readOnly = true;
  39. default = (singleton config.hpc.hostFile.canonical) ++ config.hpc.hostFile.aliases;
  40. };
  41. };
  42. config = {
  43. networking.hosts = listToAttrs (concatMap
  44. (node: map
  45. (address: nameValuePair address node.config.hpc.hostFile.entries)
  46. node.config.hpc.hostFile.addresses)
  47. (attrValues nodes));
  48. };
  49. }