forked from kudrykv/latex-yearly-planner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kudrykv#78 from charlesbaynham/nix
Define environment as nix flake and build in GitHub workflow
- Loading branch information
Showing
6 changed files
with
171 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: "Build 2023" | ||
on: | ||
pull_request: | ||
push: | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: cachix/install-nix-action@v19 | ||
- name: Build PDFs | ||
run: nix build | ||
- name: Copy PDFs | ||
run: cp result/*.pdf . | ||
- name: Output PDFs | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: result | ||
path: ./*.pdf | ||
if-no-files-found: error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.vscode | ||
result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
{ | ||
description = "Install latex reqs"; | ||
|
||
inputs.flake-utils.url = "github:numtide/flake-utils"; | ||
|
||
outputs = { self, nixpkgs, flake-utils }: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
|
||
# Build the plannergen as a binary using fixed input versions | ||
# This means that the subsequent pdf generation does not need internet access | ||
# and is therefore a "pure" nix output | ||
plannergen = pkgs.buildGoModule { | ||
src = self; | ||
name = "plannergen"; | ||
vendorSha256 = "sha256:F3cln/CPSAonLTCvjSCMHhrzEQgWIOWw0vWwb6BG+pI="; | ||
}; | ||
|
||
# Go is packaged into the devShell for developing the package, | ||
# but is not used for the "nix build" outputs - these use the pre-built | ||
# binary instead | ||
goDeps = [ | ||
pkgs.go | ||
]; | ||
|
||
# Dependencies for building the latex files | ||
texDeps = with pkgs; [ | ||
libuuid # for the "rev" utility | ||
ps # Used by build.sh | ||
python3 # used in the build scripts | ||
(texlive.combine { | ||
inherit (texlive) | ||
metafont | ||
scheme-basic | ||
xcolor | ||
pgf | ||
wrapfig | ||
makecell | ||
multirow | ||
leading | ||
marginnote | ||
adjustbox | ||
multido | ||
varwidth | ||
blindtext | ||
setspace | ||
ifmtarg | ||
extsizes | ||
dashrule | ||
; | ||
}) | ||
]; | ||
in | ||
rec | ||
{ | ||
devShell = pkgs.mkShell { | ||
shellHook = '' | ||
unset GOPATH | ||
unset GOROOT | ||
unset GO_VERSION | ||
''; | ||
buildInputs = [ | ||
pkgs.nixpkgs-fmt # utility for pretty formatting of .nix files | ||
] ++ goDeps ++ texDeps; | ||
}; | ||
|
||
defaultPackage = pdfs; | ||
|
||
pdfs = pkgs.stdenv.mkDerivation | ||
{ | ||
name = "pdfs"; | ||
# Minimal set of dependencies to build the pdfs | ||
# Latex, "rev" and the built plannergen binary | ||
buildInputs = texDeps ++ [ plannergen ]; | ||
PLANNER_YEAR = 2023; | ||
src = "${self}"; | ||
buildCommand = '' | ||
cp -r $src/* . | ||
patchShebangs . | ||
chmod -R 770 * | ||
chmod +x *.sh | ||
PLANNERGEN_BINARY=plannergen eval $PWD/build.sh | ||
mkdir $out | ||
cp *.pdf $out/. | ||
''; | ||
}; | ||
|
||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters