diff --git a/garlic/report.nix b/garlic/report.nix index e48b63d..fe580a9 100644 --- a/garlic/report.nix +++ b/garlic/report.nix @@ -5,6 +5,7 @@ , busybox , jq , texlive +, sedReport }: let # TODO: We can select only which elements we need from fig by using: @@ -13,15 +14,15 @@ let # By now, we require all plots figJSON = writeText "fig.json" (builtins.toJSON fig); + sedCmd = (import sedReport) fig; in stdenv.mkDerivation { name = "report"; src = ./.; buildInputs = [ jq texlive.combined.scheme-basic ]; buildPhase = '' - ls -l - sed -i -e "s:@fig\.nbody\.test@:$(jq -r .nbody.test ${figJSON}):g" report.tex - jq . ${figJSON} + ${sedCmd} + cat report.tex pdflatex report.tex -o report.pdf # Run again to fix figure references pdflatex report.tex -o report.pdf diff --git a/garlic/report.tex b/garlic/report.tex index 5e6759f..a24cedd 100644 --- a/garlic/report.tex +++ b/garlic/report.tex @@ -14,8 +14,8 @@ time $t$ is measured, as shown in the figure \ref{fig:nbody.test}. % \begin{figure}[h] \centering - \includegraphics[width=0.45\textwidth]{@fig.nbody.test@/scatter.png} - \includegraphics[width=0.45\textwidth]{@fig.nbody.test@/box.png} + \includegraphics[width=0.45\textwidth]{@fig.nbody.baseline@/scatter.png} + \includegraphics[width=0.45\textwidth]{@fig.nbody.baseline@/box.png} \caption{Nbody times with varying block size} \label{fig:nbody.test} \end{figure} diff --git a/garlic/sedReport.nix b/garlic/sedReport.nix new file mode 100644 index 0000000..37dd1d9 --- /dev/null +++ b/garlic/sedReport.nix @@ -0,0 +1,19 @@ +{ + stdenv +, fig +}: + stdenv.mkDerivation { + name = "report"; + src = ./.; + buildPhase = '' + grep -o '@[^ @]*@' report.tex | sed 's/@//g' | sort -u > list + + echo "fig:" > fun.nix + echo "'''" >> fun.nix + sed 's:\(^.*\)$:sed -i "s;@\1@;''${\1};g" report.tex:g' list >> fun.nix + echo "'''" >> fun.nix + ''; + installPhase = '' + cp fun.nix $out + ''; + } diff --git a/overlay.nix b/overlay.nix index e5ec0a2..f7eac52 100644 --- a/overlay.nix +++ b/overlay.nix @@ -181,6 +181,9 @@ let report = callPackage ./garlic/report.nix { fig = self.bsc.garlic.fig; }; + sedReport = callPackage ./garlic/sedReport.nix { + fig = self.bsc.garlic.fig; + }; # Use the configuration for the following target machine targetMachine = self.garlic.machines.mn4;