1 {config, lib, pkgs, ...}:
3 cfg = config.services.boinc;
4 allowRemoteGuiRpcFlag = lib.optionalString cfg.allowRemoteGuiRpc "--allow_remote_gui_rpc";
6 fhsEnv = pkgs.buildFHSEnv {
7 name = "boinc-fhs-env";
8 targetPkgs = pkgs': [ cfg.package ] ++ cfg.extraEnvPackages;
9 runScript = "/bin/boinc_client";
11 fhsEnvExecutable = "${fhsEnv}/bin/${fhsEnv.name}";
15 options.services.boinc = {
16 enable = lib.mkOption {
17 type = lib.types.bool;
20 Whether to enable the BOINC distributed computing client. If this
21 option is set to true, the boinc_client daemon will be run as a
22 background service. The boinccmd command can be used to control the
27 package = lib.mkPackageOption pkgs "boinc" {
28 example = "boinc-headless";
31 dataDir = lib.mkOption {
32 type = lib.types.path;
33 default = "/var/lib/boinc";
35 The directory in which to store BOINC's configuration and data files.
39 allowRemoteGuiRpc = lib.mkOption {
40 type = lib.types.bool;
43 If set to true, any remote host can connect to and control this BOINC
44 client (subject to password authentication). If instead set to false,
45 only the hosts listed in {var}`dataDir`/remote_hosts.cfg will be allowed to
48 See also: <https://boinc.berkeley.edu/wiki/Controlling_BOINC_remotely#Remote_access>
52 extraEnvPackages = lib.mkOption {
53 type = lib.types.listOf lib.types.package;
55 example = lib.literalExpression "[ pkgs.virtualbox ]";
57 Additional packages to make available in the environment in which
58 BOINC will run. Common choices are:
60 - {var}`pkgs.virtualbox`:
61 The VirtualBox virtual machine framework. Required by some BOINC
62 projects, such as ATLAS@home.
63 - {var}`pkgs.ocl-icd`:
64 OpenCL infrastructure library. Required by BOINC projects that
65 use OpenCL, in addition to a device-specific OpenCL driver.
66 - {var}`pkgs.linuxPackages.nvidia_x11`:
67 Provides CUDA libraries. Required by BOINC projects that use
68 CUDA. Note that this requires an NVIDIA graphics device to be
69 present on the system.
71 Also provides OpenCL drivers for NVIDIA GPUs;
72 {var}`pkgs.ocl-icd` is also needed in this case.
77 config = lib.mkIf cfg.enable {
78 environment.systemPackages = [cfg.package];
83 description = "BOINC Client";
87 users.groups.boinc = {};
89 systemd.tmpfiles.rules = [
90 "d '${cfg.dataDir}' - boinc boinc - -"
93 systemd.services.boinc = {
94 description = "BOINC Client";
95 after = ["network.target"];
96 wantedBy = ["multi-user.target"];
98 ${fhsEnvExecutable} --dir ${cfg.dataDir} ${allowRemoteGuiRpcFlag}
108 maintainers = with lib.maintainers; [ ];