1 { config, lib, pkgs, ...} :
6 cfg = config.services.orangefs.server;
8 aliases = mapAttrsToList (alias: url: alias) cfg.servers;
10 # Maximum handle number is 2^63
11 maxHandle = 9223372036854775806;
13 # One range of handles for each meta/data instance
14 handleStep = maxHandle / (length aliases) / 2;
16 fileSystems = mapAttrsToList (name: fs: ''
20 RootHandle ${toString fs.rootHandle}
25 ${concatStringsSep "\n" (
28 begin = i * handleStep + 3;
29 end = begin + handleStep - 1;
30 in "Range ${alias} ${toString begin}-${toString end}") aliases
35 ${concatStringsSep "\n" (
38 begin = i * handleStep + 3 + (length aliases) * handleStep;
39 end = begin + handleStep - 1;
40 in "Range ${alias} ${toString begin}-${toString end}") aliases
45 TroveSyncMeta ${if fs.troveSyncMeta then "yes" else "no"}
46 TroveSyncData ${if fs.troveSyncData then "yes" else "no"}
47 ${fs.extraStorageHints}
55 LogType ${cfg.logType}
56 DataStorageSpace ${cfg.dataStorageSpace}
57 MetaDataStorageSpace ${cfg.metadataStorageSpace}
59 BMIModules ${concatStringsSep "," cfg.BMIModules}
66 ${concatStringsSep "\n" (mapAttrsToList (alias: url: "Alias ${alias} ${url}") cfg.servers)}
69 ${concatStringsSep "\n" fileSystems}
76 services.orangefs.server = {
77 enable = mkEnableOption (lib.mdDoc "OrangeFS server");
80 type = with types; enum [ "file" "syslog" ];
82 description = lib.mdDoc "Destination for log messages.";
85 dataStorageSpace = mkOption {
86 type = types.nullOr types.str;
88 example = "/data/storage";
89 description = lib.mdDoc "Directory for data storage.";
92 metadataStorageSpace = mkOption {
93 type = types.nullOr types.str;
95 example = "/data/meta";
96 description = lib.mdDoc "Directory for meta data storage.";
99 BMIModules = mkOption {
100 type = with types; listOf str;
101 default = [ "bmi_tcp" ];
102 example = [ "bmi_tcp" "bmi_ib"];
103 description = lib.mdDoc "List of BMI modules to load.";
106 extraDefaults = mkOption {
109 description = lib.mdDoc "Extra config for `<Defaults>` section.";
112 extraConfig = mkOption {
115 description = lib.mdDoc "Extra config for the global section.";
119 type = with types; attrsOf types.str;
122 node1 = "tcp://node1:3334";
123 node2 = "tcp://node2:3334";
125 description = lib.mdDoc "URLs for storage server including port. The attribute names define the server alias.";
128 fileSystems = mkOption {
129 description = lib.mdDoc ''
130 These options will create the `<FileSystem>` sections of config file.
132 default = { orangefs = {}; };
133 example = literalExpression ''
144 type = with types; attrsOf (submodule ({ ... } : {
149 description = lib.mdDoc "File system ID (must be unique within configuration).";
152 rootHandle = mkOption {
155 description = lib.mdDoc "File system root ID.";
158 extraConfig = mkOption {
161 description = lib.mdDoc "Extra config for `<FileSystem>` section.";
164 troveSyncMeta = mkOption {
167 description = lib.mdDoc "Sync meta data.";
170 troveSyncData = mkOption {
173 description = lib.mdDoc "Sync data.";
176 extraStorageHints = mkOption {
179 description = lib.mdDoc "Extra config for `<StorageHints>` section.";
187 ###### implementation
189 config = mkIf cfg.enable {
190 environment.systemPackages = [ pkgs.orangefs ];
192 # orangefs daemon will run as user
193 users.users.orangefs = {
197 users.groups.orangefs = {};
199 # To format the file system the config file is needed.
200 environment.etc."orangefs/server.conf" = {
206 systemd.services.orangefs-server = {
207 wantedBy = [ "multi-user.target" ];
208 requires = [ "network-online.target" ];
209 after = [ "network-online.target" ];
212 # Run as "simple" in foreground mode.
213 # This is more reliable
215 ${pkgs.orangefs}/bin/pvfs2-server -d \
216 /etc/orangefs/server.conf
218 TimeoutStopSec = "120";