From c417b44d8339ad20451e72f4e8daa12369c9572f Mon Sep 17 00:00:00 2001 From: Thomas Churchman Date: Mon, 11 Oct 2021 09:23:42 +0200 Subject: [PATCH] rPackages: introduce packagesRequiringHome override Some R packages require access to a home directory to pass install tests. Extend r-modules to allow creating a temporary home directory for packages with such requirements. --- pkgs/development/r-modules/default.nix | 52 ++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/pkgs/development/r-modules/default.nix b/pkgs/development/r-modules/default.nix index 5a5b9fc13488..65082832ce39 100644 --- a/pkgs/development/r-modules/default.nix +++ b/pkgs/development/r-modules/default.nix @@ -158,6 +158,38 @@ let in builtins.listToAttrs nameValuePairs; + # Overrides package definition requiring a home directory to install or to + # run tests. + # For example, + # + # overrideRequireHome [ + # "foo" + # ] old + # + # results in + # + # { + # foo = old.foo.overrideAttrs (oldAttrs: { + # preInstall = '' + # ${oldAttrs.preInstall or ""} + # export HOME=$(mktemp -d) + # ''; + # }); + # } + overrideRequireHome = packageNames: old: + let + nameValuePairs = map (name: { + inherit name; + value = (builtins.getAttr name old).overrideAttrs (oldAttrs: { + preInstall = '' + ${oldAttrs.preInstall or ""} + export HOME=$(mktemp -d) + ''; + }); + }) packageNames; + in + builtins.listToAttrs nameValuePairs; + # Overrides package definition to skip check. # For example, # @@ -211,13 +243,14 @@ let defaultOverrides = old: new: let old0 = old; in let - old1 = old0 // (overrideRequireX packagesRequireingX old0); - old2 = old1 // (overrideSkipCheck packagesToSkipCheck old1); - old3 = old2 // (overrideRDepends packagesWithRDepends old2); - old4 = old3 // (overrideNativeBuildInputs packagesWithNativeBuildInputs old3); - old5 = old4 // (overrideBuildInputs packagesWithBuildInputs old4); - old6 = old5 // (overrideBroken brokenPackages old5); - old = old6; + old1 = old0 // (overrideRequireX packagesRequiringX old0); + old2 = old1 // (overrideRequireHome packagesRequiringHome old1); + old3 = old2 // (overrideSkipCheck packagesToSkipCheck old2); + old4 = old3 // (overrideRDepends packagesWithRDepends old3); + old5 = old4 // (overrideNativeBuildInputs packagesWithNativeBuildInputs old4); + old6 = old5 // (overrideBuildInputs packagesWithBuildInputs old5); + old7 = old6 // (overrideBroken brokenPackages old6); + old = old7; in old // (otherOverrides old new); # Recursive override pattern. @@ -480,7 +513,7 @@ let csaw = with pkgs; [ zlib.dev curl ]; }; - packagesRequireingX = [ + packagesRequiringX = [ "accrual" "ade4TkGUI" "analogue" @@ -670,6 +703,9 @@ let "x12GUI" ]; + packagesRequiringHome = [ + ]; + packagesToSkipCheck = [ "Rmpi" # tries to run MPI processes "pbdMPI" # tries to run MPI processes