Skip to content

Commit

Permalink
nix-based montage logic
Browse files Browse the repository at this point in the history
  • Loading branch information
kai-tub committed Jul 1, 2024
1 parent 552618f commit 483b30e
Show file tree
Hide file tree
Showing 13 changed files with 258 additions and 122 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake .#
3 changes: 3 additions & 0 deletions .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ on:
- "**.tex"
- "**.yml"
- "**.sty"
- "**.nix"
branches: [ master ]
pull_request:
paths:
- "**.tex"
- "**.yml"
- "**.sty"
- "**.nix"
branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
Expand Down Expand Up @@ -67,6 +69,7 @@ jobs:
with:
args: fish ./.github/workflows/convert_pdf_to_png.fish
if: github.event_name == 'push'
# HERE: Use simple cli logic, maybe script, to push documentation artifacts to external repo with access token
- name: Sync docs
uses: kai-tub/external-repo-sync-action@v1
with:
Expand Down
52 changes: 0 additions & 52 deletions .github/workflows/convert_pdf_to_png.fish

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# cannot link to sty for windows support
result
.direnv
minimal_examples/*.sty
minimal_examples/*.pdf
minimal_examples/logos
Expand Down
4 changes: 2 additions & 2 deletions compare_examples/defaultbeamer_example.tex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
\input{common_header_input.tex}
\input{inputs/common_header_input.tex}

\begin{document}
\input{common_slides_input.tex}
\input{inputs/common_slides_input.tex}
\end{document}
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions compare_examples/pureminimalistic_example_dark.tex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
\input{common_header_input.tex}
\input{inputs/common_header_input.tex}
\usetheme[darkmode]{pureminimalistic}

\begin{document}
\input{common_slides_input.tex}
\input{inputs/common_slides_input.tex}
\end{document}
4 changes: 2 additions & 2 deletions compare_examples/pureminimalistic_example_light.tex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
\input{common_header_input.tex}
\input{inputs/common_header_input.tex}
\usetheme{pureminimalistic}

\begin{document}
\input{common_slides_input.tex}
\input{inputs/common_slides_input.tex}
\end{document}
104 changes: 99 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
} @ inputs: let
eachSystem = nixpkgs.lib.genAttrs (import systems);
pkgsFor = eachSystem (system: (nixpkgs.legacyPackages.${system}.extend inputs.devshell.overlays.default));
tex-minimal-deps-builder = texlive-pkg: (texlive-pkg.combine {
tex-deps-builder = texlive-pkg: (texlive-pkg.combine {
inherit
(texlive-pkg)
scheme-small
Expand All @@ -32,6 +32,16 @@
fontspec
infwarerr
kvoptions
# only for demo

biblatex
biber
# only for language examples

haranoaji
haranoaji-extra
babel
luatexja
# without \RequirePackage{lmodern} and without cm-super

# Otherwise I was getting errors: 3/bin/pdflatex (file ecss0800): Font ecss0800 at 600 not found
Expand All @@ -47,10 +57,92 @@
# should probably be call package
packages = eachSystem (system: let
pkgs = pkgsFor.${system};
in {
default = pkgs.callPackage nix/minimal_examples.nix {
in rec {
demo-pdflatex = pkgs.callPackage nix/default.nix {
inherit self;
nix-filter = inputs.nix-filter;
tex-deps = tex-deps-builder pkgs.texlive;
tex-directory = ".";
};
demo-pdflatex-montage =
pkgs.runCommand "demo-pdflatex-pdf" {
src = ./scripts;
buildInputs = [demo-pdflatex pkgs.nushell pkgs.imagemagickBig];
} ''
mkdir $out
nu --no-history --no-config-file \
$src/create_pngs.nu create-montage demo \
--src-dir ${demo-pdflatex} --target-dir $out
'';
minimal-examples-pdflatex = pkgs.callPackage nix/default.nix {
inherit self;
nix-filter = inputs.nix-filter;
tex-deps = tex-deps-builder pkgs.texlive;
tex-directory = "minimal_examples";
};
minimal-examples-lualatex = pkgs.callPackage nix/default.nix {
inherit self;
nix-filter = inputs.nix-filter;
tex-deps = tex-minimal-deps-builder pkgs.texlive;
tex-deps = tex-deps-builder pkgs.texlive;
use-lualatex = true;
tex-directory = "minimal_examples";
};
minimal-examples-pngs =
pkgs.runCommand "minimal-examples-pngs" {
src = ./scripts;
buildInputs = [minimal-examples-lualatex pkgs.nushell pkgs.imagemagickBig];
} ''
mkdir $out
nu --no-history --no-config-file \
$src/create_pngs.nu convert-pdfs-to-pngs \
--src-dir ${minimal-examples-lualatex} --target-dir $out --density 600
'';
compare-examples = pkgs.callPackage nix/default.nix {
inherit self;
nix-filter = inputs.nix-filter;
tex-deps = tex-deps-builder pkgs.texlive;
use-lualatex = true;
tex-directory = "compare_examples";
};
# what is runCommand ?
# just need to call command and provide the given input and output dir!
compare-examples-montage =
pkgs.runCommand "compare-examples-pdf" {
src = ./scripts;
buildInputs = [compare-examples pkgs.nushell pkgs.imagemagickBig];
} ''
mkdir $out
nu --no-history --no-config-file \
$src/create_pngs.nu create-montage compare_examples \
--src-dir ${compare-examples} --target-dir $out
'';
multi-lang-examples = pkgs.callPackage nix/default.nix {
inherit self;
nix-filter = inputs.nix-filter;
tex-deps = tex-deps-builder pkgs.texlive;
use-lualatex = true;
tex-directory = "multi_lang_examples";
};
multi-lang-examples-montage =
pkgs.runCommand "multi-lang-examples-pdf" {
src = ./scripts;
buildInputs = [multi-lang-examples pkgs.nushell pkgs.imagemagickBig];
} ''
mkdir $out
nu --no-history --no-config-file \
$src/create_pngs.nu create-montage multi_lang_examples \
--src-dir ${multi-lang-examples} --target-dir $out
'';
documentation-artifacts = pkgs.symlinkJoin {
name = "documentation-artifacts";
paths = [
multi-lang-examples-montage
compare-examples-montage
demo-pdflatex-montage
minimal-examples-pngs
minimal-examples-lualatex
];
};
});
devShells = eachSystem (
Expand All @@ -59,7 +151,9 @@
in {
default = pkgs.devshell.mkShell {
packages = [
(tex-minimal-deps-builder pkgs.texlive)
(tex-deps-builder pkgs.texlive)
pkgs.imagemagickBig
pkgs.fd
];
};
}
Expand Down
76 changes: 76 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
self,
lib,
stdenvNoCC,
nix-filter,
coreutils,
findutils,
version ? "git",
tex-deps,
use-lualatex ? false,
use-pdflatex ? true,
tex-directory ? "minimal_examples",
}:
# https://nixos.wiki/wiki/TexLive
# https://flyx.org/nix-flakes-latex/
stdenvNoCC.mkDerivation rec {
pname = "pure-minimalistic-${tex-directory}";
inherit version;

src = nix-filter {
root = ./..;
include = [
# Include the "src" path relative to the root
(nix-filter.lib.matchExt "sty")
(nix-filter.lib.matchExt "bib")
"logos/"
"${tex-directory}/"
];
};

# phases = ["unpackPhase" "buildPhase" "installPhase"];

buildInputs = [
tex-deps
coreutils
findutils
# cntr is kinda broken. Requires these utils to be available
# in buildinputs
# cntr
# breakpointHook
# bash
];

# TODO: Figure out how to wrap this in a shellchecker and with correct flags
# -pretex="\pdfvariable suppressoptionalinfo 512\relax" \ # lualatex
buildPhase =
''
export PATH="${lib.makeBinPath buildInputs}";
mkdir -p .cache/texmf-var
''
+ lib.optionalString (tex-directory != ".") ''
mv ${tex-directory}/* .
''
+ ''
env TEXMFHOME=.cache TEXMFVAR=.cache/texmf-var \
SOURCE_DATE_EPOCH=${builtins.toString self.lastModified or 0} \
latexmk \
-file-line-error -interaction=nonstopmode \
-pdf \
''
+ lib.optionalString use-pdflatex ''
-usepretex='\pdftrailerid{}' \
''
+ lib.optionalString use-lualatex ''
-lualatex \
-usepretex='\pdfvariable suppressoptionalinfo 512\relax' \
''
+ ''
*.tex
'';

installPhase = ''
mkdir -p $out
cp *.pdf $out/
'';
}
59 changes: 0 additions & 59 deletions nix/minimal_examples.nix

This file was deleted.

Loading

0 comments on commit 483b30e

Please sign in to comment.