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
|
, busybox
|
||||||
, jq
|
, jq
|
||||||
, texlive
|
, texlive
|
||||||
|
, sedReport
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
# TODO: We can select only which elements we need from fig by using:
|
# TODO: We can select only which elements we need from fig by using:
|
||||||
@ -13,15 +14,15 @@ let
|
|||||||
|
|
||||||
# By now, we require all plots
|
# By now, we require all plots
|
||||||
figJSON = writeText "fig.json" (builtins.toJSON fig);
|
figJSON = writeText "fig.json" (builtins.toJSON fig);
|
||||||
|
sedCmd = (import sedReport) fig;
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "report";
|
name = "report";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
buildInputs = [ jq texlive.combined.scheme-basic ];
|
buildInputs = [ jq texlive.combined.scheme-basic ];
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
ls -l
|
${sedCmd}
|
||||||
sed -i -e "s:@fig\.nbody\.test@:$(jq -r .nbody.test ${figJSON}):g" report.tex
|
cat report.tex
|
||||||
jq . ${figJSON}
|
|
||||||
pdflatex report.tex -o report.pdf
|
pdflatex report.tex -o report.pdf
|
||||||
# Run again to fix figure references
|
# Run again to fix figure references
|
||||||
pdflatex report.tex -o report.pdf
|
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]
|
\begin{figure}[h]
|
||||||
\centering
|
\centering
|
||||||
\includegraphics[width=0.45\textwidth]{@fig.nbody.test@/scatter.png}
|
\includegraphics[width=0.45\textwidth]{@fig.nbody.baseline@/scatter.png}
|
||||||
\includegraphics[width=0.45\textwidth]{@fig.nbody.test@/box.png}
|
\includegraphics[width=0.45\textwidth]{@fig.nbody.baseline@/box.png}
|
||||||
\caption{Nbody times with varying block size}
|
\caption{Nbody times with varying block size}
|
||||||
\label{fig:nbody.test}
|
\label{fig:nbody.test}
|
||||||
\end{figure}
|
\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 {
|
report = callPackage ./garlic/report.nix {
|
||||||
fig = self.bsc.garlic.fig;
|
fig = self.bsc.garlic.fig;
|
||||||
};
|
};
|
||||||
|
sedReport = callPackage ./garlic/sedReport.nix {
|
||||||
|
fig = self.bsc.garlic.fig;
|
||||||
|
};
|
||||||
|
|
||||||
# Use the configuration for the following target machine
|
# Use the configuration for the following target machine
|
||||||
targetMachine = self.garlic.machines.mn4;
|
targetMachine = self.garlic.machines.mn4;
|
||||||
|
Loading…
Reference in New Issue
Block a user