-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds flake.nix and a Dockerfile using it to either build locally using [nix](https://nixos.org) or using docker, which essentially downloads nixos and runs the same build process. The download size is much smaller than the full texlive as only needed packages are downloaded. They are defined in nix/texlive.nix and should be enough to install even outside of nix environment. This also adds a devshell that you can enter using `nix develop` to get an environment with texlive with needed packages
- Loading branch information
Showing
4 changed files
with
267 additions
and
0 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,11 @@ | ||
FROM nixos/nix:latest | ||
|
||
WORKDIR /build | ||
COPY . . | ||
|
||
RUN echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf | ||
|
||
RUN nix build .#astro-notebook | ||
|
||
FROM scratch | ||
COPY --from=0 /buildresult/astro-notebook.pdf / |
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,71 @@ | ||
{ | ||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs"; | ||
flake-parts.url = "github:hercules-ci/flake-parts"; | ||
devshell = { | ||
url = "github:numtide/devshell"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
}; | ||
|
||
outputs = | ||
inputs@{ | ||
flake-parts, | ||
... | ||
}: | ||
flake-parts.lib.mkFlake { inherit inputs; } { | ||
systems = [ | ||
"aarch64-darwin" | ||
"aarch64-linux" | ||
"x86_64-darwin" | ||
"x86_64-linux" | ||
]; | ||
imports = [ | ||
inputs.devshell.flakeModule | ||
]; | ||
perSystem = | ||
{ config, pkgs, ... }: | ||
let | ||
texlive = pkgs.callPackage ./nix/texlive.nix { }; | ||
in | ||
{ | ||
devshells.default = { | ||
packages = [ | ||
texlive | ||
]; | ||
commands = [ | ||
{ | ||
help = "Build the notebook PDF using LaTeX"; | ||
name = "build-notebook"; | ||
command = '' | ||
mkdir -p tikz/resource | ||
latexmk -pdf -xelatex -shell-escape astro-notebook.tex; | ||
''; | ||
} | ||
]; | ||
}; | ||
|
||
packages = { | ||
default = config.packages.astro-notebook; | ||
astro-notebook = pkgs.stdenv.mkDerivation { | ||
name = "astro-notebook"; | ||
src = inputs.self; | ||
buildInputs = [ | ||
texlive | ||
]; | ||
|
||
buildPhase = '' | ||
export XDG_CACHE_HOME="$(mktemp -d)" | ||
mkdir -p tikz/resource | ||
latexmk -pdf -xelatex -shell-escape astro-notebook.tex | ||
''; | ||
|
||
installPhase = '' | ||
mkdir -p $out | ||
cp astro-notebook.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
{ texlive }: | ||
let | ||
# Basic scheme | ||
texliveBasic = { | ||
inherit (texlive) scheme-basic; | ||
}; | ||
|
||
# Language support | ||
texliveLanguageSupport = { | ||
inherit (texlive) babel babel-russian hyphen-russian; | ||
}; | ||
|
||
# Fonts | ||
texliveFonts = { | ||
inherit (texlive) | ||
cm-unicode | ||
fontspec | ||
mathspec | ||
jknapltx | ||
was | ||
wasy | ||
starfont | ||
wasysym | ||
wrapfig | ||
textcase | ||
rsfs | ||
collection-fontsrecommended | ||
collection-fontutils | ||
; | ||
}; | ||
|
||
# Maths | ||
texliveMaths = { | ||
inherit (texlive) | ||
siunitx | ||
amsmath | ||
amsfonts | ||
cancel | ||
mathtools | ||
units | ||
xfrac | ||
; | ||
}; | ||
|
||
# Graphics and figures | ||
texliveGraphics = { | ||
inherit (texlive) | ||
pdflscape | ||
graphics | ||
pgf | ||
tkz-euclide | ||
tikz-3dplot | ||
spath3 | ||
pgfplots | ||
qrcode | ||
; | ||
}; | ||
|
||
# Document layout | ||
texliveLayout = { | ||
inherit (texlive) | ||
geometry | ||
titlesec | ||
adjustbox | ||
caption | ||
pdfpages | ||
xpatch | ||
enumitem | ||
tocloft | ||
; | ||
}; | ||
|
||
# Utilities | ||
texliveUtilities = { | ||
inherit (texlive) | ||
xetex | ||
xcolor | ||
xifthen | ||
xurl | ||
hyperref | ||
lipsum | ||
latexmk | ||
ifmtarg | ||
; | ||
}; | ||
|
||
# Bibliography and units | ||
texliveBib = { | ||
inherit (texlive) | ||
biblatex | ||
biblatex-ext | ||
siunitx | ||
; | ||
}; | ||
|
||
# Combine all package groups | ||
texlivePackages = | ||
texliveBasic | ||
// texliveLanguageSupport | ||
// texliveFonts | ||
// texliveMaths | ||
// texliveGraphics | ||
// texliveLayout | ||
// texliveUtilities | ||
// texliveBib; | ||
in | ||
texlive.combine texlivePackages |