Fixed flake check errors

Also constrained support to just x86_64-linux, I ran into issues with
aarch64-linux but I don't have a usecase for that anyway.
This commit is contained in:
Alejandro Angulo 2023-02-12 10:01:09 -08:00
parent c9beaf1501
commit d92ebe37a8
Signed by: alejandro-angulo
GPG key ID: 75579581C74554B6
2 changed files with 105 additions and 104 deletions

View file

@ -10,9 +10,8 @@
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "numtide", "id": "flake-utils",
"repo": "flake-utils", "type": "indirect"
"type": "github"
} }
}, },
"nixpkgs": { "nixpkgs": {

204
flake.nix
View file

@ -3,122 +3,124 @@
inputs = { inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable; nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
flake-utils.url = github:numtide/flake-utils;
}; };
outputs = { outputs = {
self, self,
nixpkgs, nixpkgs,
flake-utils, flake-utils,
}: }: let
with flake-utils.lib; pkgs = import nixpkgs {
eachSystem allSystems (system: let inherit system;
pkgs = nixpkgs.legacyPackages.${system}; };
nerdfonts-hack = pkgs.nerdfonts.override { lib = pkgs.lib;
fonts = ["Hack"]; system = "x86_64-linux";
}; nerdfonts-hack = pkgs.nerdfonts.override {
tex = pkgs.texlive.combine { fonts = ["Hack"];
inherit (pkgs.texlive) scheme-basic latex-bin latexmk enumitem multirow titlesec xcolor fontspec chktex latexindent; };
}; tex = pkgs.texlive.combine {
vars = ["email" "phonenumber"]; inherit (pkgs.texlive) scheme-basic latex-bin latexmk enumitem multirow titlesec xcolor fontspec chktex latexindent;
# Create definitions like \def\email{$EMAIL} };
# Each \email command in the tex document will be populated by an EMAIL vars = ["email" "phonenumber"];
# variable (can be set as an environment variable) # Create definitions like \def\email{$EMAIL}
texvars = toString (pkgs.lib.concatMapStrings (x: ''\def\${x}{${"$" + pkgs.lib.toUpper x}}'') vars); # Each \email command in the tex document will be populated by an EMAIL
in rec { # variable (can be set as an environment variable)
packages = { texvars = toString (lib.concatMapStrings (x: ''\def\${x}{${"$" + lib.toUpper x}}'') vars);
alejandro-resume = pkgs.stdenvNoCC.mkDerivation rec { in {
name = "alejandro-resume"; packages.${system} = {
src = self; # inherit system;
propogatedBuildInputs = [pkgs.coreutils nerdfonts-hack tex]; alejandro-resume = pkgs.stdenvNoCC.mkDerivation rec {
phases = ["unpackPhase" "buildPhase" "installPhase"]; name = "alejandro-resume";
SCRIPT = '' src = self;
#!/usr/bin/env bash propogatedBuildInputs = [pkgs.coreutils nerdfonts-hack tex];
phases = ["unpackPhase" "buildPhase" "installPhase"];
SCRIPT = ''
#!/usr/bin/env bash
prefix=${builtins.placeholder "out"} prefix=${builtins.placeholder "out"}
export PATH="${pkgs.lib.makeBinPath propogatedBuildInputs}"; export PATH="${lib.makeBinPath propogatedBuildInputs}";
DEBUG=false DEBUG=false
DIR=$(mktemp -d) DIR=$(mktemp -d)
RES=$(pwd)/alejandro_resume.pdf RES=$(pwd)/alejandro_resume.pdf
LOG=$(pwd)/alejandro_resume.log LOG=$(pwd)/alejandro_resume.log
function usage { function usage {
echo "Usage: $(basename $0) [-h] [-d] [-e EMAIL] [-p PHONENUMBER]" echo "Usage: $(basename $0) [-h] [-d] [-e EMAIL] [-p PHONENUMBER]"
echo ' -h Prints this usage message.' echo ' -h Prints this usage message.'
echo "" echo ""
echo ' -d Saves latexmk log file (will be named alejandro_resume.log)' echo ' -d Saves latexmk log file (will be named alejandro_resume.log)'
echo "" echo ""
echo ' -e EMAIL Sets email address used when building document.' echo ' -e EMAIL Sets email address used when building document.'
echo ' Can also be set with EMAIL environment variable.' echo ' Can also be set with EMAIL environment variable.'
echo "" echo ""
echo ' -p PHONENUMBER Sets phone number used when building the document.' echo ' -p PHONENUMBER Sets phone number used when building the document.'
echo ' Can also be set with PHONENUMBER environment variable.' echo ' Can also be set with PHONENUMBER environment variable.'
} }
while getopts ':de:p:h' flag; do while getopts ':de:p:h' flag; do
case $flag in case $flag in
'd') DEBUG=true;; 'd') DEBUG=true;;
# Overrides EMAIL and PHONENUMBER envvars if set # Overrides EMAIL and PHONENUMBER envvars if set
'e') EMAIL="$OPTARG";; 'e') EMAIL="$OPTARG";;
'p') PHONENUMBER="$OPTARG";; 'p') PHONENUMBER="$OPTARG";;
'h') usage && exit;; 'h') usage && exit;;
?) usage && exit 1;; ?) usage && exit 1;;
esac esac
done done
cd $prefix/share cd $prefix/share
mkdir -p "$DIR/.texcache/texmf-var" mkdir -p "$DIR/.texcache/texmf-var"
env TEXFMHOME="$DIR/.texcache" TEXMFVAR="$DIR/.texcache/texmf-var" \ env TEXFMHOME="$DIR/.texcache" TEXMFVAR="$DIR/.texcache/texmf-var" \
OSFONTDIR=${nerdfonts-hack}/share/fonts \ OSFONTDIR=${nerdfonts-hack}/share/fonts \
latexmk -interaction=nonstopmode -pdf -lualatex \ latexmk -interaction=nonstopmode -pdf -lualatex \
-output-directory="$DIR" \ -output-directory="$DIR" \
-pretex="${texvars}"\ -pretex="${texvars}"\
-usepretex alejandro_resume.tex -usepretex alejandro_resume.tex
mv "$DIR/alejandro_resume.pdf" "$RES" mv "$DIR/alejandro_resume.pdf" "$RES"
if $DEBUG; then if $DEBUG; then
mv "$DIR/alejandro_resume.log" "$LOG" mv "$DIR/alejandro_resume.log" "$LOG"
fi fi
rm -rf $DIR rm -rf $DIR
''; '';
buildPhase = '' buildPhase = ''
printenv SCRIPT > alejandro-resume printenv SCRIPT > alejandro-resume
''; '';
installPhase = '' installPhase = ''
mkdir -p $out/{bin,share} mkdir -p $out/{bin,share}
cp alejandro_resume.tex $out/share/alejandro_resume.tex cp alejandro_resume.tex $out/share/alejandro_resume.tex
cp alejandro-resume $out/bin/alejandro-resume cp alejandro-resume $out/bin/alejandro-resume
chmod u+x $out/bin/alejandro-resume chmod u+x $out/bin/alejandro-resume
''; '';
}; };
}; default = self.packages.${system}.alejandro-resume;
defaultPackage = packages.alejandro-resume; };
devShells = { devShells.${system} = {
default = pkgs.mkShell { default = pkgs.mkShell {
name = "default"; name = "default";
buildInputs = with pkgs; [ buildInputs = with pkgs; [
alejandra alejandra
direnv direnv
git git
pre-commit pre-commit
tex #TODO: Is this necessary? tex #TODO: Is this necessary?
zathura # PDF Viewer zathura # PDF Viewer
]; ];
shellHook = '' shellHook = ''
PATH=${pkgs.writeShellScriptBin "nix" '' PATH=${pkgs.writeShellScriptBin "nix" ''
${pkgs.nixVersions.stable}/bin/nix --experimental-features "nix-command flakes" "$@" ${pkgs.nixVersions.stable}/bin/nix --experimental-features "nix-command flakes" "$@"
''}/bin:$PATH ''}/bin:$PATH
if [ ! -f ".git/hooks/pre-commit" ]; then if [ ! -f ".git/hooks/pre-commit" ]; then
pre-commit install &> /dev/null pre-commit install &> /dev/null
fi fi
''; '';
}; };
}; };
}); };
} }