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