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