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 (lib.mdDoc "OrangeFS client daemon"); 14 15 extraOptions = mkOption { 16 type = with types; listOf str; 17 default = []; 18 description = lib.mdDoc "Extra command line options for pvfs2-client."; 19 }; 20 21 fileSystems = mkOption { 22 description = lib.mdDoc '' 23 The orangefs file systems to be mounted. 24 This option is preferred over using {option}`fileSystems` 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 = lib.mdDoc "Mount point."; 40 }; 41 42 options = mkOption { 43 type = with types; listOf str; 44 default = []; 45 description = lib.mdDoc "Mount options"; 46 }; 47 48 target = mkOption { 49 type = types.str; 50 example = "tcp://server:3334/orangefs"; 51 description = lib.mdDoc "Target URL"; 52 }; 53 }; 54 })); 55 }; 56 }; 57 }; 58 59 60 ###### implementation 61 62 config = mkIf cfg.enable { 63 environment.systemPackages = [ pkgs.orangefs ]; 64 65 boot.supportedFilesystems = [ "pvfs2" ]; 66 boot.kernelModules = [ "orangefs" ]; 67 68 systemd.services.orangefs-client = { 69 requires = [ "network-online.target" ]; 70 after = [ "network-online.target" ]; 71 72 serviceConfig = { 73 Type = "simple"; 74 75 ExecStart = '' 76 ${pkgs.orangefs}/bin/pvfs2-client-core \ 77 --logtype=syslog ${concatStringsSep " " cfg.extraOptions} 78 ''; 79 80 TimeoutStopSec = "120"; 81 }; 82 }; 83 84 systemd.mounts = map (fs: { 85 requires = [ "orangefs-client.service" ]; 86 after = [ "orangefs-client.service" ]; 87 bindsTo = [ "orangefs-client.service" ]; 88 wantedBy = [ "remote-fs.target" ]; 89 type = "pvfs2"; 90 options = concatStringsSep "," fs.options; 91 what = fs.target; 92 where = fs.mountPoint; 93 }) cfg.fileSystems; 94 }; 95} 96