1{ config, lib, pkgs, ...} :
2
3with lib;
4
5let
6 cfg = config.services.orangefs.client;
7
8in {
9 ###### interface
10
11 options = {
12 services.orangefs.client = {
13 enable = mkEnableOption "OrangeFS client daemon";
14
15 extraOptions = mkOption {
16 type = with types; listOf str;
17 default = [];
18 description = "Extra command line options for pvfs2-client.";
19 };
20
21 fileSystems = mkOption {
22 description = ''
23 The orangefs file systems to be mounted.
24 This option is prefered over using <option>fileSystems</option> directly since
25 the pvfs client service needs to be running for it to be mounted.
26 '';
27
28 example = [{
29 mountPoint = "/orangefs";
30 target = "tcp://server:3334/orangefs";
31 }];
32
33 type = with types; listOf (submodule ({ ... } : {
34 options = {
35
36 mountPoint = mkOption {
37 type = types.str;
38 default = "/orangefs";
39 description = "Mount point.";
40 };
41
42 options = mkOption {
43 type = with types; listOf str;
44 default = [];
45 description = "Mount options";
46 };
47
48 target = mkOption {
49 type = types.str;
50 default = null;
51 example = "tcp://server:3334/orangefs";
52 description = "Target URL";
53 };
54 };
55 }));
56 };
57 };
58 };
59
60
61 ###### implementation
62
63 config = mkIf cfg.enable {
64 environment.systemPackages = [ pkgs.orangefs ];
65
66 boot.supportedFilesystems = [ "pvfs2" ];
67 boot.kernelModules = [ "orangefs" ];
68
69 systemd.services.orangefs-client = {
70 requires = [ "network-online.target" ];
71 after = [ "network-online.target" ];
72
73 serviceConfig = {
74 Type = "simple";
75
76 ExecStart = ''
77 ${pkgs.orangefs}/bin/pvfs2-client-core \
78 --logtype=syslog ${concatStringsSep " " cfg.extraOptions}
79 '';
80
81 TimeoutStopSec = "120";
82 };
83 };
84
85 systemd.mounts = map (fs: {
86 requires = [ "orangefs-client.service" ];
87 after = [ "orangefs-client.service" ];
88 bindsTo = [ "orangefs-client.service" ];
89 wantedBy = [ "remote-fs.target" ];
90 type = "pvfs2";
91 options = concatStringsSep "," fs.options;
92 what = fs.target;
93 where = fs.mountPoint;
94 }) cfg.fileSystems;
95 };
96}
97