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.

226 lines
6.8 KiB

1 year ago
  1. { pkgs, config, lib, ... }:
  2. with lib;
  3. {
  4. options.hpc.beegfs = {
  5. package = mkOption {
  6. description = ''
  7. BeeGFS package.
  8. '';
  9. type = types.package;
  10. default = config.boot.kernelPackages.callPackage ../packages/beegfs/default.nix { };
  11. };
  12. mgmtdHost = mkOption {
  13. description = ''
  14. Hostname of the management host.
  15. '';
  16. type = types.str;
  17. };
  18. connAuthFile = mkOption {
  19. description = ''
  20. File containing shared secret authentication.
  21. '';
  22. type = types.str;
  23. };
  24. client = {
  25. enable = mkEnableOption "BeeGFS client";
  26. mountPoint = mkOption {
  27. description = ''
  28. Mount point under which the BeeGFS filesystem is mounted.
  29. '';
  30. type = types.nullOr types.str;
  31. default = null;
  32. };
  33. };
  34. mgmtd = {
  35. enable = mkEnableOption "BeeGFS management server daemon";
  36. };
  37. meta = {
  38. enable = mkEnableOption "BeeGFS meta-data server daemon";
  39. };
  40. storage = {
  41. enable = mkEnableOption "BeeGFS storage server daemon";
  42. };
  43. };
  44. config = mkMerge [
  45. (mkIf config.hpc.beegfs.client.enable {
  46. boot.kernelModules = [ "beegfs" ];
  47. boot.extraModulePackages = [ config.hpc.beegfs.package.module ];
  48. environment.etc."beegfs-client" = {
  49. enable = true;
  50. target = "beegfs/client.conf";
  51. text = ''
  52. sysMgmtdHost = ${config.hpc.beegfs.mgmtdHost}
  53. connAuthFile = ${config.hpc.beegfs.connAuthFile}
  54. '';
  55. };
  56. systemd.mounts = mkIf (config.hpc.beegfs.client.mountPoint != null) [ {
  57. where = config.hpc.beegfs.client.mountPoint;
  58. what = "beegfs_nodev";
  59. type = "beegfs";
  60. options = "cfgFile=/etc/beegfs/client.conf,_netdev";
  61. requires = [ "beegfs-helperd.service" ];
  62. after = [ "beegfs-helperd.service" ];
  63. } ];
  64. systemd.services."beegfs-helperd" = let
  65. cfgFile = pkgs.writeText "beegfs-helperd.conf" ''
  66. connAuthFile = ${config.hpc.beegfs.connAuthFile}
  67. logType = syslog
  68. '';
  69. in {
  70. wantedBy = [ "multi-user.target" ];
  71. requires = [ "network-online.target" ];
  72. after = [ "network-online.target" ];
  73. serviceConfig = rec {
  74. ExecStart = ''
  75. ${config.hpc.beegfs.package}/bin/beegfs-helperd \
  76. cfgFile=${cfgFile} \
  77. pidFile=${PIDFile} \
  78. runDaemonized=false
  79. '';
  80. PIDFile = "/run/beegfs-helperd.pid";
  81. TimeoutStopSec = "300";
  82. };
  83. };
  84. environment.systemPackages = [ (pkgs.runCommandLocal "beegfs-utils" {
  85. nativeBuildInputs = [ pkgs.makeWrapper ];
  86. } ''
  87. mkdir -p $out/bin
  88. makeWrapper ${config.hpc.beegfs.package}/bin/beegfs-check-servers \
  89. $out/bin/beegfs-check-servers \
  90. --add-flags "-c /etc/beegfs/client.conf" \
  91. --prefix PATH : ${lib.makeBinPath [ config.hpc.beegfs.package ]}
  92. makeWrapper ${config.hpc.beegfs.package}/bin/beegfs-ctl \
  93. $out/bin/beegfs-ctl \
  94. --add-flags "--cfgFile=/etc/beegfs/client.conf"
  95. makeWrapper ${config.hpc.beegfs.package}/bin/beegfs-ctl \
  96. $out/bin/beegfs-df \
  97. --add-flags "--cfgFile=/etc/beegfs/client.conf" \
  98. --add-flags --listtargets \
  99. --add-flags --hidenodeid \
  100. --add-flags --pools \
  101. --add-flags --spaceinfo
  102. makeWrapper ${config.hpc.beegfs.package}/bin/fsck.beegfs \
  103. $out/bin/beegfs-fsck \
  104. --add-flags "--cfgFile=/etc/beegfs/client.conf"
  105. '') ];
  106. })
  107. (mkIf config.hpc.beegfs.mgmtd.enable (let
  108. cfgFile = pkgs.writeText "beegfs-mgmtd.conf" ''
  109. storeMgmtdDirectory = /var/lib/beegs/mgmtd
  110. storeAllowFirstRunInit = false
  111. connAuthFile = ${config.hpc.beegfs.connAuthFile}
  112. logType = syslog
  113. '';
  114. in {
  115. systemd.services."beegfs-mgmtd" = {
  116. wantedBy = [ "multi-user.target" ];
  117. requires = [ "network-online.target" ];
  118. after = [ "network-online.target" "rdma.service" "opensmd.service" "opensm.service" ];
  119. preStart = ''
  120. if ! test -e /var/lib/beegs/mgmtd; then
  121. ${config.hpc.beegfs.package}/bin/beegfs-setup-mgmtd -C -p /var/lib/beegs/mgmtd
  122. fi
  123. '';
  124. serviceConfig = rec {
  125. ExecStart = ''
  126. ${config.hpc.beegfs.package}/bin/beegfs-mgmtd \
  127. cfgFile=${cfgFile} \
  128. pidFile=${PIDFile} \
  129. runDaemonized=false
  130. '';
  131. PIDFile = "/run/beegfs-mgmtd.pid";
  132. TimeoutStopSec = "300";
  133. };
  134. };
  135. }))
  136. (mkIf config.hpc.beegfs.meta.enable (let
  137. cfgFile = pkgs.writeText "beegfs-meta.conf" ''
  138. storeMetaDirectory = /var/lib/beegs/meta
  139. storeAllowFirstRunInit = false
  140. sysMgmtdHost = ${config.hpc.beegfs.mgmtdHost}
  141. connAuthFile = ${config.hpc.beegfs.connAuthFile}
  142. logType = syslog
  143. '';
  144. in {
  145. systemd.services."beegfs-meta" = {
  146. wantedBy = [ "multi-user.target" ];
  147. requires = [ "network-online.target" ];
  148. after = [ "network-online.target" "beegfs-mgmt.service" "beegfs-storage.service" "rdma.service" "opensmd.service" "opensm.service" ];
  149. preStart = ''
  150. if ! test -e /var/lib/beegs/meta; then
  151. ${config.hpc.beegfs.package}/bin/beegfs-setup-meta -C -p /var/lib/beegs/meta
  152. fi
  153. '';
  154. serviceConfig = rec {
  155. ExecStart = ''
  156. ${config.hpc.beegfs.package}/bin/beegfs-meta \
  157. cfgFile=${cfgFile} \
  158. pidFile=${PIDFile} \
  159. runDaemonized=false
  160. '';
  161. PIDFile = "/run/beegfs-meta.pid";
  162. TimeoutStopSec = "300";
  163. };
  164. };
  165. }))
  166. (mkIf config.hpc.beegfs.storage.enable (let
  167. cfgFile = pkgs.writeText "beegfs-storage.conf" ''
  168. storeStorageDirectory = /var/lib/beegs/storage
  169. storeAllowFirstRunInit = false
  170. sysMgmtdHost = ${config.hpc.beegfs.mgmtdHost}
  171. connAuthFile = ${config.hpc.beegfs.connAuthFile}
  172. logType = syslog
  173. '';
  174. in {
  175. systemd.services."beegfs-storage" = {
  176. wantedBy = [ "multi-user.target" ];
  177. requires = [ "network-online.target" ];
  178. after = [ "network-online.target" "beegfs-mgmt.service" "rdma.service" "opensmd.service" "opensm.service" ];
  179. preStart = ''
  180. if ! test -e /var/lib/beegs/storage; then
  181. ${config.hpc.beegfs.package}/bin/beegfs-setup-storage -C -p /var/lib/beegs/storage
  182. fi
  183. '';
  184. serviceConfig = rec {
  185. ExecStart = ''
  186. ${config.hpc.beegfs.package}/bin/beegfs-storage \
  187. cfgFile=${cfgFile} \
  188. pidFile=${PIDFile} \
  189. runDaemonized=false
  190. '';
  191. PIDFile = "/run/beegfs-storage.pid";
  192. TimeoutStopSec = "300";
  193. };
  194. };
  195. }))
  196. ];
  197. }