at 17.09-beta 2.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 9in 10 { 11 options.services.boinc = { 12 enable = mkOption { 13 type = types.bool; 14 default = false; 15 description = '' 16 Whether to enable the BOINC distributed computing client. If this 17 option is set to true, the boinc_client daemon will be run as a 18 background service. The boinccmd command can be used to control the 19 daemon. 20 ''; 21 }; 22 23 package = mkOption { 24 type = types.package; 25 default = pkgs.boinc; 26 defaultText = "pkgs.boinc"; 27 description = '' 28 Which BOINC package to use. 29 ''; 30 }; 31 32 dataDir = mkOption { 33 type = types.path; 34 default = "/var/lib/boinc"; 35 description = '' 36 The directory in which to store BOINC's configuration and data files. 37 ''; 38 }; 39 40 allowRemoteGuiRpc = mkOption { 41 type = types.bool; 42 default = false; 43 description = '' 44 If set to true, any remote host can connect to and control this BOINC 45 client (subject to password authentication). If instead set to false, 46 only the hosts listed in <varname>dataDir</varname>/remote_hosts.cfg will be allowed to 47 connect. 48 49 See also: <link xlink:href="http://boinc.berkeley.edu/wiki/Controlling_BOINC_remotely#Remote_access"/> 50 ''; 51 }; 52 }; 53 54 config = mkIf cfg.enable { 55 environment.systemPackages = [cfg.package]; 56 57 users.users.boinc = { 58 createHome = false; 59 description = "BOINC Client"; 60 home = cfg.dataDir; 61 isSystemUser = true; 62 }; 63 64 systemd.services.boinc = { 65 description = "BOINC Client"; 66 after = ["network.target" "local-fs.target"]; 67 wantedBy = ["multi-user.target"]; 68 preStart = '' 69 mkdir -p ${cfg.dataDir} 70 chown boinc ${cfg.dataDir} 71 ''; 72 script = '' 73 ${cfg.package}/bin/boinc_client --dir ${cfg.dataDir} --redirectio ${allowRemoteGuiRpcFlag} 74 ''; 75 serviceConfig = { 76 PermissionsStartOnly = true; # preStart must be run as root 77 User = "boinc"; 78 Nice = 10; 79 }; 80 }; 81 }; 82 83 meta = { 84 maintainers = with lib.maintainers; [kierdavis]; 85 }; 86 }