Moved build script out into its own file
Now I can run shellcheck on the bash :)
This commit is contained in:
parent
a21b68bb23
commit
a73239d2cf
62
build.sh
Normal file
62
build.sh
Normal file
|
@ -0,0 +1,62 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Following variables are set via sed in the buildPhase step
|
||||
PREFIX=""
|
||||
# Intentionally overriding PATH so supressing shellcheck
|
||||
# shellcheck disable=SC2123
|
||||
PATH=""
|
||||
NERDFONTS=""
|
||||
|
||||
DEBUG=false
|
||||
DIR=$(mktemp -d)
|
||||
RES=$(pwd)/alejandro_resume.pdf
|
||||
LOG=$(pwd)/alejandro_resume.log
|
||||
|
||||
function usage {
|
||||
echo "Usage: $(basename "$0") [-h] [-d] [-e EMAIL] [-p PHONENUMBER]"
|
||||
echo ' -h Prints this usage message.'
|
||||
echo ""
|
||||
echo ' -d Saves latexmk log file (will be named alejandro_resume.log)'
|
||||
echo ""
|
||||
echo ' -e EMAIL Sets email address used when building document.'
|
||||
echo ' Can also be set with EMAIL environment variable.'
|
||||
echo ""
|
||||
echo ' -p PHONENUMBER Sets phone number used when building the document.'
|
||||
echo ' Can also be set with PHONENUMBER environment variable.'
|
||||
}
|
||||
|
||||
while getopts ':de:p:h' flag; do
|
||||
case $flag in
|
||||
'd') DEBUG=true;;
|
||||
# Overrides EMAIL and PHONENUMBER envvars if set
|
||||
'e') EMAIL="$OPTARG";;
|
||||
'p') PHONENUMBER="$OPTARG";;
|
||||
'h') usage && exit;;
|
||||
?) usage && exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
cd "$PREFIX"/share || exit 1
|
||||
mkdir -p "$DIR/.texcache/texmf-var"
|
||||
|
||||
export EMAIL
|
||||
export PHONENUMBER
|
||||
|
||||
# Set via sed in buildPhase (needs to be set after we have input values (e.g.
|
||||
# EMAIL and PHONENUMBER)
|
||||
TEXVARS=""
|
||||
|
||||
env TEXFMHOME="$DIR/.texcache" TEXMFVAR="$DIR/.texcache/texmf-var" \
|
||||
OSFONTDIR="$NERDFONTS"/share/fonts \
|
||||
latexmk -interaction=nonstopmode -pdf -lualatex \
|
||||
-output-directory="$DIR" \
|
||||
-pretex="$TEXVARS" \
|
||||
-usepretex alejandro_resume.tex
|
||||
|
||||
mv "$DIR/alejandro_resume.pdf" "$RES"
|
||||
|
||||
if $DEBUG; then
|
||||
mv "$DIR/alejandro_resume.log" "$LOG"
|
||||
fi
|
||||
|
||||
rm -rf "$DIR"
|
61
flake.nix
61
flake.nix
|
@ -25,7 +25,7 @@
|
|||
# Create definitions like \def\email{$EMAIL}
|
||||
# Each \email command in the tex document will be populated by an EMAIL
|
||||
# variable (can be set as an environment variable)
|
||||
texvars = toString (lib.concatMapStrings (x: ''\def\${x}{${"$" + lib.toUpper x}}'') vars);
|
||||
texvars = toString (lib.concatMapStrings (x: ''\\def\\${x}{${"$" + lib.toUpper x}}'') vars);
|
||||
in {
|
||||
packages.${system} = {
|
||||
# inherit system;
|
||||
|
@ -34,60 +34,12 @@
|
|||
src = self;
|
||||
propogatedBuildInputs = [pkgs.coreutils nerdfonts-hack tex];
|
||||
phases = ["unpackPhase" "buildPhase" "installPhase"];
|
||||
SCRIPT = ''
|
||||
#!/usr/bin/env bash
|
||||
|
||||
prefix=${builtins.placeholder "out"}
|
||||
export PATH="${lib.makeBinPath propogatedBuildInputs}";
|
||||
DEBUG=false
|
||||
DIR=$(mktemp -d)
|
||||
RES=$(pwd)/alejandro_resume.pdf
|
||||
LOG=$(pwd)/alejandro_resume.log
|
||||
|
||||
function usage {
|
||||
echo "Usage: $(basename $0) [-h] [-d] [-e EMAIL] [-p PHONENUMBER]"
|
||||
echo ' -h Prints this usage message.'
|
||||
echo ""
|
||||
echo ' -d Saves latexmk log file (will be named alejandro_resume.log)'
|
||||
echo ""
|
||||
echo ' -e EMAIL Sets email address used when building document.'
|
||||
echo ' Can also be set with EMAIL environment variable.'
|
||||
echo ""
|
||||
echo ' -p PHONENUMBER Sets phone number used when building the document.'
|
||||
echo ' Can also be set with PHONENUMBER environment variable.'
|
||||
}
|
||||
|
||||
while getopts ':de:p:h' flag; do
|
||||
case $flag in
|
||||
'd') DEBUG=true;;
|
||||
# Overrides EMAIL and PHONENUMBER envvars if set
|
||||
'e') EMAIL="$OPTARG";;
|
||||
'p') PHONENUMBER="$OPTARG";;
|
||||
'h') usage && exit;;
|
||||
?) usage && exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
cd $prefix/share
|
||||
mkdir -p "$DIR/.texcache/texmf-var"
|
||||
|
||||
env TEXFMHOME="$DIR/.texcache" TEXMFVAR="$DIR/.texcache/texmf-var" \
|
||||
OSFONTDIR=${nerdfonts-hack}/share/fonts \
|
||||
latexmk -interaction=nonstopmode -pdf -lualatex \
|
||||
-output-directory="$DIR" \
|
||||
-pretex="${texvars}"\
|
||||
-usepretex alejandro_resume.tex
|
||||
|
||||
mv "$DIR/alejandro_resume.pdf" "$RES"
|
||||
|
||||
if $DEBUG; then
|
||||
mv "$DIR/alejandro_resume.log" "$LOG"
|
||||
fi
|
||||
|
||||
rm -rf $DIR
|
||||
'';
|
||||
buildPhase = ''
|
||||
printenv SCRIPT > alejandro-resume
|
||||
cp build.sh alejandro-resume
|
||||
sed -i 's!PREFIX=""!PREFIX="${builtins.placeholder "out"}"!g' alejandro-resume
|
||||
sed -i 's!PATH=""!PATH="${lib.makeBinPath propogatedBuildInputs}"!g' alejandro-resume
|
||||
sed -i 's!TEXVARS=""!TEXVARS="${texvars}"!g' alejandro-resume
|
||||
sed -i 's!NERDFONTS=""!NERDFONTS="${nerdfonts-hack}"!g' alejandro-resume
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out/{bin,share}
|
||||
|
@ -109,6 +61,7 @@
|
|||
pre-commit
|
||||
tex #TODO: Is this necessary?
|
||||
zathura # PDF Viewer
|
||||
shellcheck
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
|
|
Loading…
Reference in a new issue