2020-10-21 18:18:43 +02:00
|
|
|
{
|
|
|
|
stdenv
|
2022-09-01 16:27:29 +02:00
|
|
|
, lib
|
2020-10-21 18:18:43 +02:00
|
|
|
, 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 ? []
|
|
|
|
}:
|
|
|
|
|
2022-09-01 16:27:29 +02:00
|
|
|
with lib;
|
2020-10-21 18:18:43 +02:00
|
|
|
|
|
|
|
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-05-03 12:48:49 +02:00
|
|
|
dataset=$(readlink -f ${dataset}/dataset)
|
2021-03-30 16:35:47 +02:00
|
|
|
|
|
|
|
ln -s $dataset input
|
2021-05-03 12:48:49 +02:00
|
|
|
Rscript --vanilla ${script} "$dataset" "$out"
|
2021-03-30 16:35:47 +02:00
|
|
|
|
2021-04-21 17:42:40 +02:00
|
|
|
# HACK: replace the \minus for a \hyphen to keep the file paths intact, so
|
|
|
|
# they can be copied to the terminal directly. The StandardEncoding is not
|
|
|
|
# working (AdobeStd.enc).
|
|
|
|
find "$out" -name '*.pdf' | xargs -l1 sed -i 's.45/minus.45/hyphen.g'
|
|
|
|
|
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
|
|
|
'';
|
|
|
|
}
|