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 "Folding@home client"; 22 23 package = mkPackageOption pkgs "fahclient" { }; 24 25 user = mkOption { 26 type = types.nullOr types.str; 27 default = null; 28 description = '' 29 The user associated with the reported computation results. This will 30 be used in the ranking statistics. 31 ''; 32 }; 33 34 team = mkOption { 35 type = types.int; 36 default = 236565; 37 description = '' 38 The team ID associated with the reported computation results. This 39 will be used in the ranking statistics. 40 41 By default, use the NixOS folding@home team ID is being used. 42 ''; 43 }; 44 45 daemonNiceLevel = mkOption { 46 type = types.ints.between (-20) 19; 47 default = 0; 48 description = '' 49 Daemon process priority for FAHClient. 50 0 is the default Unix process priority, 19 is the lowest. 51 ''; 52 }; 53 54 extraArgs = mkOption { 55 type = types.listOf types.str; 56 default = []; 57 description = '' 58 Extra startup options for the FAHClient. Run 59 `fah-client --help` to find all the available options. 60 ''; 61 }; 62 }; 63 64 config = mkIf cfg.enable { 65 systemd.services.foldingathome = { 66 description = "Folding@home client"; 67 after = [ "network.target" ]; 68 wantedBy = [ "multi-user.target" ]; 69 script = '' 70 exec ${lib.getExe cfg.package} ${lib.escapeShellArgs args} 71 ''; 72 serviceConfig = { 73 DynamicUser = true; 74 StateDirectory = "foldingathome"; 75 Nice = cfg.daemonNiceLevel; 76 WorkingDirectory = "%S/foldingathome"; 77 }; 78 }; 79 }; 80 81 meta = { 82 maintainers = with lib.maintainers; [ zimbatm ]; 83 }; 84}