git.iko.soy/typeable/nixpkgs
on master help sign in
boinc service: use an FHS environment

While BOINC itself is open source, many of the project applications it runs are not. Additionally, these project applications are checksummed before they are run, so they can't be patched. This means we can't make the project applications find required binaries/libraries on a NixOS system. The solution is therefore to make said binaries and libraries appear in the expected locations, by wrapping BOINC in an FHS-compatible environment [1]. An `extraEnvPackages` is also added to allow more packages to be added into this environment. The documentation for this option describes some practical use cases for it. [1] https://nixos.org/nixpkgs/manual/#sec-fhs-environments Version 2: fixed Docbook list formatting, minor rewording Version 3: rebase onto master (9c048f4fb66adc33c6b379f2edefcb615fd53de6) Version 4: fix usage of targetPkgs argument to buildFHSUserEnv

commit9fad70f1de9918ad6a280fe8ac243173b0329789 authorKier Davis <kierdavis@gmail.com> dateSat 28 Oct 2017, 22:29 (9 years ago) parent9c048f4
1 file changed+45−1
nixos/modules/services/computing/boinc/client.nix+45−1
nixos/modules/services/computing/boinc/client.nix+45−1
@@ -6,6 +6,13 @@ let
66 cfg = config.services.boinc;
77 allowRemoteGuiRpcFlag = optionalString cfg.allowRemoteGuiRpc "--allow_remote_gui_rpc";
88
9+ fhsEnv = pkgs.buildFHSUserEnv {
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+
916in
1017 {
1118 options.services.boinc = {
@@ -49,6 +56,43 @@ in
4956 See also: <link xlink:href="http://boinc.berkeley.edu/wiki/Controlling_BOINC_remotely#Remote_access"/>
5057 '';
5158 };
59+
60+ extraEnvPackages = mkOption {
61+ type = types.listOf types.package;
62+ default = [];
63+ example = "[ pkgs.virtualbox ]";
64+ description = ''
65+ Additional packages to make available in the environment in which
66+ BOINC will run. Common choices are:
67+ <variablelist>
68+ <varlistentry>
69+ <term><varname>pkgs.virtualbox</varname></term>
70+ <listitem><para>
71+ The VirtualBox virtual machine framework. Required by some BOINC
72+ projects, such as ATLAS@home.
73+ </para></listitem>
74+ </varlistentry>
75+ <varlistentry>
76+ <term><varname>pkgs.ocl-icd</varname></term>
77+ <listitem><para>
78+ OpenCL infrastructure library. Required by BOINC projects that
79+ use OpenCL, in addition to a device-specific OpenCL driver.
80+ </para></listitem>
81+ </varlistentry>
82+ <varlistentry>
83+ <term><varname>pkgs.linuxPackages.nvidia_x11</varname></term>
84+ <listitem><para>
85+ Provides CUDA libraries. Required by BOINC projects that use
86+ CUDA. Note that this requires an NVIDIA graphics device to be
87+ present on the system.
88+ </para><para>
89+ Also provides OpenCL drivers for NVIDIA GPUs;
90+ <varname>pkgs.ocl-icd</varname> is also needed in this case.
91+ </para></listitem>
92+ </varlistentry>
93+ </variablelist>
94+ '';
95+ };
5296 };
5397
5498 config = mkIf cfg.enable {
@@ -70,7 +114,7 @@ in
70114 chown boinc ${cfg.dataDir}
71115 '';
72116 script = ''
73− ${cfg.package}/bin/boinc_client --dir ${cfg.dataDir} --redirectio ${allowRemoteGuiRpcFlag}
117+ ${fhsEnvExecutable} --dir ${cfg.dataDir} --redirectio ${allowRemoteGuiRpcFlag}
74118 '';
75119 serviceConfig = {
76120 PermissionsStartOnly = true; # preStart must be run as root