8 cfg = config.services.orangefs.server;
10 aliases = lib.mapAttrsToList (alias: url: alias) cfg.servers;
12 # Maximum handle number is 2^63
13 maxHandle = 9223372036854775806;
15 # One range of handles for each meta/data instance
16 handleStep = maxHandle / (lib.length aliases) / 2;
18 fileSystems = lib.mapAttrsToList (name: fs: ''
22 RootHandle ${toString fs.rootHandle}
27 ${lib.concatStringsSep "\n" (
31 begin = i * handleStep + 3;
32 end = begin + handleStep - 1;
34 "Range ${alias} ${toString begin}-${toString end}"
40 ${lib.concatStringsSep "\n" (
44 begin = i * handleStep + 3 + (lib.length aliases) * handleStep;
45 end = begin + handleStep - 1;
47 "Range ${alias} ${toString begin}-${toString end}"
53 TroveSyncMeta ${if fs.troveSyncMeta then "yes" else "no"}
54 TroveSyncData ${if fs.troveSyncData then "yes" else "no"}
55 ${fs.extraStorageHints}
63 LogType ${cfg.logType}
64 DataStorageSpace ${cfg.dataStorageSpace}
65 MetaDataStorageSpace ${cfg.metadataStorageSpace}
67 BMIModules ${lib.concatStringsSep "," cfg.BMIModules}
74 ${lib.concatStringsSep "\n" (lib.mapAttrsToList (alias: url: "Alias ${alias} ${url}") cfg.servers)}
77 ${lib.concatStringsSep "\n" fileSystems}
85 services.orangefs.server = {
86 enable = lib.mkEnableOption "OrangeFS server";
88 logType = lib.mkOption {
96 description = "Destination for log messages.";
99 dataStorageSpace = lib.mkOption {
100 type = lib.types.nullOr lib.types.str;
102 example = "/data/storage";
103 description = "Directory for data storage.";
106 metadataStorageSpace = lib.mkOption {
107 type = lib.types.nullOr lib.types.str;
109 example = "/data/meta";
110 description = "Directory for meta data storage.";
113 BMIModules = lib.mkOption {
114 type = with lib.types; listOf str;
115 default = [ "bmi_tcp" ];
120 description = "List of BMI modules to load.";
123 extraDefaults = lib.mkOption {
124 type = lib.types.lines;
126 description = "Extra config for `<Defaults>` section.";
129 extraConfig = lib.mkOption {
130 type = lib.types.lines;
132 description = "Extra config for the global section.";
135 servers = lib.mkOption {
136 type = with lib.types; attrsOf lib.types.str;
139 node1 = "tcp://node1:3334";
140 node2 = "tcp://node2:3334";
142 description = "URLs for storage server including port. The attribute names define the server alias.";
145 fileSystems = lib.mkOption {
147 These options will create the `<FileSystem>` sections of config file.
152 example = lib.literalExpression ''
171 type = lib.types.int;
173 description = "File system ID (must be unique within configuration).";
176 rootHandle = lib.mkOption {
177 type = lib.types.int;
179 description = "File system root ID.";
182 extraConfig = lib.mkOption {
183 type = lib.types.lines;
185 description = "Extra config for `<FileSystem>` section.";
188 troveSyncMeta = lib.mkOption {
189 type = lib.types.bool;
191 description = "Sync meta data.";
194 troveSyncData = lib.mkOption {
195 type = lib.types.bool;
197 description = "Sync data.";
200 extraStorageHints = lib.mkOption {
201 type = lib.types.lines;
203 description = "Extra config for `<StorageHints>` section.";
213 ###### implementation
215 config = lib.mkIf cfg.enable {
216 environment.systemPackages = [ pkgs.orangefs ];
218 # orangefs daemon will run as user
219 users.users.orangefs = {
223 users.groups.orangefs = { };
225 # To format the file system the config file is needed.
226 environment.etc."orangefs/server.conf" = {
232 systemd.services.orangefs-server = {
233 wantedBy = [ "multi-user.target" ];
234 requires = [ "network-online.target" ];
235 after = [ "network-online.target" ];
238 # Run as "simple" in foreground mode.
239 # This is more reliable
241 ${pkgs.orangefs}/bin/pvfs2-server -d \
242 /etc/orangefs/server.conf
244 TimeoutStopSec = "120";