2020-10-21 18:18:43 +02:00
|
|
|
{
|
|
|
|
stdenv
|
|
|
|
, rWrapper
|
|
|
|
, rPackages
|
2021-03-12 19:53:24 +01:00
|
|
|
, fontconfig
|
2021-04-09 16:01:42 +02:00
|
|
|
, dejavu_fonts
|
|
|
|
, liberation_ttf
|
|
|
|
, noto-fonts
|
|
|
|
, makeFontsConf
|
|
|
|
, makeFontsCache
|
2021-03-30 15:49:40 +02:00
|
|
|
, jq
|
2021-04-09 16:01:42 +02:00
|
|
|
, fetchFromGitHub
|
|
|
|
, writeText
|
|
|
|
, runCommand
|
|
|
|
, glibcLocales
|
2020-10-21 18:18:43 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
{
|
|
|
|
# The two results to be compared
|
|
|
|
dataset
|
|
|
|
, script
|
|
|
|
, extraRPackages ? []
|
|
|
|
}:
|
|
|
|
|
|
|
|
with stdenv.lib;
|
|
|
|
|
|
|
|
let
|
2021-04-09 16:01:42 +02:00
|
|
|
scalesPatched = with rPackages; buildRPackage {
|
|
|
|
name = "scales";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "mikmart";
|
|
|
|
repo = "scales";
|
|
|
|
#ref = "label-bytes";
|
|
|
|
rev = "fa7d91c765b6b5d2f682c7c22e0478d96c2ea76c";
|
|
|
|
sha256 = "10dsyxp9pxzdmg04xpnrxqhc4qfhbkr3jhx8whfr7z27wgfrr1n3";
|
|
|
|
};
|
|
|
|
propagatedBuildInputs = [ farver labeling lifecycle munsell R6 RColorBrewer viridisLite ];
|
|
|
|
nativeBuildInputs = [ farver labeling lifecycle munsell R6 RColorBrewer viridisLite ];
|
|
|
|
};
|
|
|
|
|
2020-10-21 18:18:43 +02:00
|
|
|
customR = rWrapper.override {
|
2021-04-09 16:01:42 +02:00
|
|
|
packages = with rPackages; [ scalesPatched tidyverse viridis egg
|
|
|
|
Cairo extrafont ] ++ extraRPackages;
|
2020-10-21 18:18:43 +02:00
|
|
|
};
|
|
|
|
|
2021-04-09 16:01:42 +02:00
|
|
|
myFonts = [
|
|
|
|
dejavu_fonts
|
|
|
|
#noto-fonts
|
|
|
|
#liberation_ttf
|
|
|
|
];
|
|
|
|
|
|
|
|
cacheConf =
|
|
|
|
let
|
|
|
|
cache = makeFontsCache { fontDirectories = myFonts; };
|
|
|
|
in
|
|
|
|
writeText "fc-00-nixos-cache.conf" ''
|
|
|
|
<?xml version='1.0'?>
|
|
|
|
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
|
|
|
|
<fontconfig>
|
|
|
|
<!-- Font directories -->
|
|
|
|
${concatStringsSep "\n" (map (font: "<dir>${font}</dir>") myFonts)}
|
|
|
|
${optionalString (stdenv.hostPlatform == stdenv.buildPlatform) ''
|
|
|
|
<!-- Pre-generated font caches -->
|
|
|
|
<cachedir>${cache}</cachedir>
|
|
|
|
''}
|
|
|
|
</fontconfig>
|
|
|
|
'';
|
|
|
|
|
|
|
|
# default fonts configuration file
|
|
|
|
# priority 52
|
|
|
|
defaultFontsConf =
|
|
|
|
let genDefault = fonts: name:
|
|
|
|
optionalString (fonts != []) ''
|
|
|
|
<alias binding="same">
|
|
|
|
<family>${name}</family>
|
|
|
|
<prefer>
|
|
|
|
${concatStringsSep ""
|
|
|
|
(map (font: ''
|
|
|
|
<family>${font}</family>
|
|
|
|
'') fonts)}
|
|
|
|
</prefer>
|
|
|
|
</alias>
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
writeText "fc-52-nixos-default-fonts.conf" ''
|
|
|
|
<?xml version='1.0'?>
|
|
|
|
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
|
|
|
|
<fontconfig>
|
|
|
|
<!-- Default fonts -->
|
|
|
|
${genDefault [ "DejaVu Sans" ] "sans-serif"}
|
|
|
|
${genDefault [ "DejaVu Serif" ] "serif"}
|
|
|
|
${genDefault [ "DejaVu Sans Mono" ] "monospace"}
|
|
|
|
${genDefault [ "Noto Color Emoji"] "emoji"}
|
|
|
|
</fontconfig>
|
|
|
|
'';
|
|
|
|
|
|
|
|
fontConfPath =
|
|
|
|
let
|
|
|
|
fixedConf = runCommand "fonts-fixed.conf" {
|
|
|
|
preferLocalBuild = true;
|
|
|
|
} ''
|
|
|
|
head --lines=-2 ${fontconfig.out}/etc/fonts/fonts.conf >> $out
|
|
|
|
|
|
|
|
cat >> $out << 'EOF'
|
|
|
|
<!--
|
|
|
|
Load local customization files, but don't complain
|
|
|
|
if there aren't any
|
|
|
|
-->
|
|
|
|
<include ignore_missing="yes">conf.d</include>
|
|
|
|
EOF
|
|
|
|
|
|
|
|
tail -2 ${fontconfig.out}/etc/fonts/fonts.conf >> $out
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
runCommand "fontconfig-conf" {
|
|
|
|
preferLocalBuild = true;
|
|
|
|
} ''
|
|
|
|
dst=$out/etc/fonts/conf.d
|
|
|
|
mkdir -p $dst
|
|
|
|
# fonts.conf
|
|
|
|
ln -s ${fixedConf} $dst/../fonts.conf
|
|
|
|
|
|
|
|
# fontconfig default config files
|
|
|
|
ln -s ${fontconfig.out}/etc/fonts/conf.d/*.conf \
|
|
|
|
$dst/
|
|
|
|
|
|
|
|
# 00-nixos-cache.conf
|
|
|
|
ln -s ${cacheConf} $dst/00-nixos-cache.conf
|
|
|
|
|
|
|
|
# 52-nixos-default-fonts.conf
|
|
|
|
ln -s ${defaultFontsConf} $dst/52-nixos-default-fonts.conf
|
|
|
|
'';
|
|
|
|
|
2020-10-21 18:18:43 +02:00
|
|
|
in stdenv.mkDerivation {
|
|
|
|
name = "plot";
|
2021-04-09 16:01:42 +02:00
|
|
|
buildInputs = [ customR jq fontconfig glibcLocales ];
|
2020-10-21 18:18:43 +02:00
|
|
|
preferLocalBuild = true;
|
|
|
|
dontPatchShebangs = true;
|
|
|
|
phases = [ "installPhase" ];
|
|
|
|
|
|
|
|
installPhase = ''
|
2021-04-09 16:01:42 +02:00
|
|
|
export FONTCONFIG_PATH=${fontConfPath}/etc/fonts/
|
|
|
|
export LANG=en_US.UTF-8
|
|
|
|
|
2020-10-21 18:18:43 +02:00
|
|
|
mkdir -p $out
|
|
|
|
cd $out
|
2021-03-30 16:35:47 +02:00
|
|
|
dataset="${dataset}"
|
|
|
|
|
|
|
|
ln -s $dataset input
|
2021-04-21 13:40:25 +02:00
|
|
|
Rscript --vanilla ${script} ${dataset} "$out"
|
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
|
2020-10-21 18:18:43 +02:00
|
|
|
'';
|
|
|
|
}
|