bscpkgs/garlic/pp/rplot.nix

47 lines
843 B
Nix
Raw Normal View History

{
stdenv
, rWrapper
, rPackages
2021-03-12 19:53:24 +01:00
, fontconfig
2021-03-30 15:49:40 +02:00
, jq
}:
{
# The two results to be compared
dataset
, script
, extraRPackages ? []
}:
with stdenv.lib;
let
customR = rWrapper.override {
packages = with rPackages; [ tidyverse viridis egg ] ++ extraRPackages;
};
in stdenv.mkDerivation {
name = "plot";
2021-03-30 15:49:40 +02:00
buildInputs = [ customR jq ];
preferLocalBuild = true;
dontPatchShebangs = true;
phases = [ "installPhase" ];
installPhase = ''
2021-03-12 19:53:24 +01:00
export FONTCONFIG_PATH=${fontconfig.out}/etc/fonts
mkdir -p $out
cd $out
2021-03-30 16:35:47 +02:00
dataset="${dataset}"
ln -s $dataset input
Rscript --vanilla ${script} ${dataset}
2021-03-30 16:35:47 +02:00
if [ "''${dataset##*.}" == gz ]; then
gunzip --stdout $dataset
else
cat $dataset
fi | jq -c .total_time |\
2021-03-30 15:49:40 +02:00
awk '{s+=$1} END {printf "%f\n", s/60}' > total_job_time_minutes
'';
}