1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7let 8 cfg = config.services.foldingathome; 9 10 args = 11 [ 12 "--team" 13 "${toString cfg.team}" 14 ] 15 ++ lib.optionals (cfg.user != null) [ 16 "--user" 17 cfg.user 18 ] 19 ++ cfg.extraArgs; 20in 21{ 22 imports = [ 23 (lib.mkRenamedOptionModule [ "services" "foldingAtHome" ] [ "services" "foldingathome" ]) 24 (lib.mkRenamedOptionModule 25 [ "services" "foldingathome" "nickname" ] 26 [ "services" "foldingathome" "user" ] 27 ) 28 (lib.mkRemovedOptionModule [ "services" "foldingathome" "config" ] '' 29 Use <literal>services.foldingathome.extraArgs instead<literal> 30 '') 31 ]; 32 options.services.foldingathome = { 33 enable = lib.mkEnableOption "Folding@home client"; 34 35 package = lib.mkPackageOption pkgs "fahclient" { }; 36 37 user = lib.mkOption { 38 type = lib.types.nullOr lib.types.str; 39 default = null; 40 description = '' 41 The user associated with the reported computation results. This will 42 be used in the ranking statistics. 43 ''; 44 }; 45 46 team = lib.mkOption { 47 type = lib.types.int; 48 default = 236565; 49 description = '' 50 The team ID associated with the reported computation results. This 51 will be used in the ranking statistics. 52 53 By default, use the NixOS folding@home team ID is being used. 54 ''; 55 }; 56 57 daemonNiceLevel = lib.mkOption { 58 type = lib.types.ints.between (-20) 19; 59 default = 0; 60 description = '' 61 Daemon process priority for FAHClient. 62 0 is the default Unix process priority, 19 is the lowest. 63 ''; 64 }; 65 66 extraArgs = lib.mkOption { 67 type = lib.types.listOf lib.types.str; 68 default = [ ]; 69 description = '' 70 Extra startup options for the FAHClient. Run 71 `fah-client --help` to find all the available options. 72 ''; 73 }; 74 }; 75 76 config = lib.mkIf cfg.enable { 77 systemd.services.foldingathome = { 78 description = "Folding@home client"; 79 after = [ "network.target" ]; 80 wantedBy = [ "multi-user.target" ]; 81 script = '' 82 exec ${lib.getExe cfg.package} ${lib.escapeShellArgs args} 83 ''; 84 serviceConfig = { 85 DynamicUser = true; 86 StateDirectory = "foldingathome"; 87 Nice = cfg.daemonNiceLevel; 88 WorkingDirectory = "%S/foldingathome"; 89 }; 90 }; 91 }; 92 93 meta = { 94 maintainers = with lib.maintainers; [ zimbatm ]; 95 }; 96}