report: build only required figures
Introduces a intermediate derivation that can be imported into the report derivation, which contains a string cmd that expands the fig variable as needed.
This commit is contained in:
parent
9a7e59a076
commit
5333058741
@ -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
|
||||
|
@ -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}
|
||||
|
19
garlic/sedReport.nix
Normal file
19
garlic/sedReport.nix
Normal file
@ -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
|
||||
'';
|
||||
}
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user