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