at 24.11-pre 3.4 kB view raw
1{config, lib, pkgs, ...}: 2 3with lib; 4 5let 6 cfg = config.services.boinc; 7 allowRemoteGuiRpcFlag = optionalString cfg.allowRemoteGuiRpc "--allow_remote_gui_rpc"; 8 9 fhsEnv = pkgs.buildFHSEnv { 10 name = "boinc-fhs-env"; 11 targetPkgs = pkgs': [ cfg.package ] ++ cfg.extraEnvPackages; 12 runScript = "/bin/boinc_client"; 13 }; 14 fhsEnvExecutable = "${fhsEnv}/bin/${fhsEnv.name}"; 15 16in 17 { 18 options.services.boinc = { 19 enable = mkOption { 20 type = types.bool; 21 default = false; 22 description = '' 23 Whether to enable the BOINC distributed computing client. If this 24 option is set to true, the boinc_client daemon will be run as a 25 background service. The boinccmd command can be used to control the 26 daemon. 27 ''; 28 }; 29 30 package = mkPackageOption pkgs "boinc" { 31 example = "boinc-headless"; 32 }; 33 34 dataDir = mkOption { 35 type = types.path; 36 default = "/var/lib/boinc"; 37 description = '' 38 The directory in which to store BOINC's configuration and data files. 39 ''; 40 }; 41 42 allowRemoteGuiRpc = mkOption { 43 type = types.bool; 44 default = false; 45 description = '' 46 If set to true, any remote host can connect to and control this BOINC 47 client (subject to password authentication). If instead set to false, 48 only the hosts listed in {var}`dataDir`/remote_hosts.cfg will be allowed to 49 connect. 50 51 See also: <https://boinc.berkeley.edu/wiki/Controlling_BOINC_remotely#Remote_access> 52 ''; 53 }; 54 55 extraEnvPackages = mkOption { 56 type = types.listOf types.package; 57 default = []; 58 example = literalExpression "[ pkgs.virtualbox ]"; 59 description = '' 60 Additional packages to make available in the environment in which 61 BOINC will run. Common choices are: 62 63 - {var}`pkgs.virtualbox`: 64 The VirtualBox virtual machine framework. Required by some BOINC 65 projects, such as ATLAS@home. 66 - {var}`pkgs.ocl-icd`: 67 OpenCL infrastructure library. Required by BOINC projects that 68 use OpenCL, in addition to a device-specific OpenCL driver. 69 - {var}`pkgs.linuxPackages.nvidia_x11`: 70 Provides CUDA libraries. Required by BOINC projects that use 71 CUDA. Note that this requires an NVIDIA graphics device to be 72 present on the system. 73 74 Also provides OpenCL drivers for NVIDIA GPUs; 75 {var}`pkgs.ocl-icd` is also needed in this case. 76 ''; 77 }; 78 }; 79 80 config = mkIf cfg.enable { 81 environment.systemPackages = [cfg.package]; 82 83 users.users.boinc = { 84 group = "boinc"; 85 createHome = false; 86 description = "BOINC Client"; 87 home = cfg.dataDir; 88 isSystemUser = true; 89 }; 90 users.groups.boinc = {}; 91 92 systemd.tmpfiles.rules = [ 93 "d '${cfg.dataDir}' - boinc boinc - -" 94 ]; 95 96 systemd.services.boinc = { 97 description = "BOINC Client"; 98 after = ["network.target"]; 99 wantedBy = ["multi-user.target"]; 100 script = '' 101 ${fhsEnvExecutable} --dir ${cfg.dataDir} ${allowRemoteGuiRpcFlag} 102 ''; 103 serviceConfig = { 104 User = "boinc"; 105 Nice = 10; 106 }; 107 }; 108 }; 109 110 meta = { 111 maintainers = with lib.maintainers; [kierdavis]; 112 }; 113 }