2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.foldingathome;
|
|
|
|
|
|
|
|
args =
|
|
|
|
["--team" "${toString cfg.team}"]
|
|
|
|
++ lib.optionals (cfg.user != null) ["--user" cfg.user]
|
|
|
|
++ cfg.extraArgs
|
|
|
|
;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
(mkRenamedOptionModule [ "services" "foldingAtHome" ] [ "services" "foldingathome" ])
|
|
|
|
(mkRenamedOptionModule [ "services" "foldingathome" "nickname" ] [ "services" "foldingathome" "user" ])
|
|
|
|
(mkRemovedOptionModule [ "services" "foldingathome" "config" ] ''
|
|
|
|
Use <literal>services.foldingathome.extraArgs instead<literal>
|
|
|
|
'')
|
|
|
|
];
|
|
|
|
options.services.foldingathome = {
|
2024-04-21 15:54:59 +00:00
|
|
|
enable = mkEnableOption "Folding@home client";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
package = mkPackageOption pkgs "fahclient" { };
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
The user associated with the reported computation results. This will
|
|
|
|
be used in the ranking statistics.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
team = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 236565;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
The team ID associated with the reported computation results. This
|
|
|
|
will be used in the ranking statistics.
|
|
|
|
|
|
|
|
By default, use the NixOS folding@home team ID is being used.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
daemonNiceLevel = mkOption {
|
|
|
|
type = types.ints.between (-20) 19;
|
|
|
|
default = 0;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2021-05-20 23:08:51 +00:00
|
|
|
Daemon process priority for FAHClient.
|
|
|
|
0 is the default Unix process priority, 19 is the lowest.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
extraArgs = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [];
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Extra startup options for the FAHClient. Run
|
2024-01-02 11:29:13 +00:00
|
|
|
`fah-client --help` to find all the available options.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.foldingathome = {
|
|
|
|
description = "Folding@home client";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
script = ''
|
2024-01-02 11:29:13 +00:00
|
|
|
exec ${lib.getExe cfg.package} ${lib.escapeShellArgs args}
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
serviceConfig = {
|
|
|
|
DynamicUser = true;
|
|
|
|
StateDirectory = "foldingathome";
|
2021-05-20 23:08:51 +00:00
|
|
|
Nice = cfg.daemonNiceLevel;
|
2020-04-24 23:36:52 +00:00
|
|
|
WorkingDirectory = "%S/foldingathome";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
maintainers = with lib.maintainers; [ zimbatm ];
|
|
|
|
};
|
|
|
|
}
|