From fc58bcf8f1110ea359bb128406aa7ed18220f5bb Mon Sep 17 00:00:00 2001 From: czertyaka Date: Sat, 13 Sep 2025 13:02:02 +0500 Subject: [PATCH] Build with nix --- .github/workflows/compile.yml | 4 ++- Homeworks/homeworktemplate.sty | 6 ++-- Makefile | 32 +++++-------------- .../3-Fundamental-types/fundamental_types.tex | 2 +- Presentations/presentationtemplate.sty | 4 +-- Projects/projectstemplate.sty | 6 ++-- README.md | 11 +++++-- shell.nix | 16 ++++++++++ 8 files changed, 44 insertions(+), 37 deletions(-) create mode 100644 shell.nix diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index f8d0524..3b3c0aa 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -14,8 +14,10 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v31 + - name: Compile PDF files - run: PREFIX=install make install + run: nix-shell --run "PREFIX=install make install" - name: Upload PDF files uses: actions/upload-artifact@v4 diff --git a/Homeworks/homeworktemplate.sty b/Homeworks/homeworktemplate.sty index ab75cf6..6574360 100644 --- a/Homeworks/homeworktemplate.sty +++ b/Homeworks/homeworktemplate.sty @@ -9,18 +9,18 @@ % fonts \setmainfont[ - Path=/workdir/Fonts/computer-modern/, + Path=Fonts/computer-modern/, BoldFont=cmunbx.ttf, ItalicFont=cmunti.ttf, BoldItalicFont=cmunbi.ttf, ]{cmunrm.ttf} \setsansfont[ - Path=/workdir/Fonts/computer-modern/, + Path=Fonts/computer-modern/, BoldFont=cmunsx.ttf, ItalicFont=cmunsi.ttf, ]{cmunss.ttf} \setmonofont[ - Path=/workdir/Fonts/Fira-Mono/, + Path=Fonts/Fira-Mono/, Scale=0.8 ]{FiraMono-Regular.ttf} diff --git a/Makefile b/Makefile index 46e12c9..5721b12 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,6 @@ ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) all \ build \ clean \ - dockerimage \ help \ hw-1 \ hw-2 \ @@ -126,30 +125,15 @@ hw-3: hw-3.pdf prj-auth-lib: prj-auth-lib.pdf prj-enc-exch: prj-enc-exch.pdf -dockerimage: - docker build \ - --build-arg UID=$(shell id -u) \ - --build-arg GID=$(shell id -g) \ - -t cppdevcourse/texlive:latest \ - $(ROOT_DIR) - -%.pdf: Dockerfile - define generate_pdf - $(MAKE) dockerimage - docker run \ - --rm \ - -u $(shell id -u):$(shell id -g) \ - -v $(ROOT_DIR):/workdir/ \ - -e TEXINPUTS='/workdir//:' \ - cppdevcourse/texlive:latest \ - latexmk \ - -halt-on-error \ - -shell-escape \ - -verbose \ - -lualatex \ - -jobname=$(subst .pdf,,$2) \ - $1 + TEXINPUTS='$(shell pwd)//:' \ + latexmk \ + -halt-on-error \ + -shell-escape \ + -verbose \ + -lualatex \ + -jobname=$(subst .pdf,,$2) \ + $1 endef pr-1.pdf: \ diff --git a/Presentations/3-Fundamental-types/fundamental_types.tex b/Presentations/3-Fundamental-types/fundamental_types.tex index 66060e0..e4427ee 100644 --- a/Presentations/3-Fundamental-types/fundamental_types.tex +++ b/Presentations/3-Fundamental-types/fundamental_types.tex @@ -13,7 +13,7 @@ \usepackage[flushleft]{threeparttable} \usepackage{emoji} -\setemojifont{AppleColorEmoji.ttf}[Path=/workdir/Fonts/] +\setemojifont{AppleColorEmoji.ttf}[Path=Fonts/] \renewcommand{\arraystretch}{1.2} diff --git a/Presentations/presentationtemplate.sty b/Presentations/presentationtemplate.sty index f6090bf..c8d2149 100644 --- a/Presentations/presentationtemplate.sty +++ b/Presentations/presentationtemplate.sty @@ -9,13 +9,13 @@ % fonts \setsansfont[ - Path=/workdir/Fonts/dejavu-sans/, + Path=Fonts/dejavu-sans/, BoldFont=DejaVuSans-Bold.ttf, ItalicFont=DejaVuSans-Oblique.ttf, BoldItalicFont=DejaVuSans-BoldOblique.ttf, ]{DejaVuSans.ttf} \setmonofont[ - Path=/workdir/Fonts/Fira-Mono/, + Path=Fonts/Fira-Mono/, BoldFont=FiraMono-Medium.ttf, ]{FiraMono-Regular.ttf} diff --git a/Projects/projectstemplate.sty b/Projects/projectstemplate.sty index 40654cf..425c157 100644 --- a/Projects/projectstemplate.sty +++ b/Projects/projectstemplate.sty @@ -9,18 +9,18 @@ % fonts \setmainfont[ - Path=/workdir/Fonts/computer-modern/, + Path=Fonts/computer-modern/, BoldFont=cmunbx.ttf, ItalicFont=cmunti.ttf, BoldItalicFont=cmunbi.ttf, ]{cmunrm.ttf} \setsansfont[ - Path=/workdir/Fonts/computer-modern/, + Path=Fonts/computer-modern/, BoldFont=cmunsx.ttf, ItalicFont=cmunsi.ttf, ]{cmunss.ttf} \setmonofont[ - Path=/workdir/Fonts/Fira-Mono/, + Path=Fonts/Fira-Mono/, Scale=0.8 ]{FiraMono-Regular.ttf} diff --git a/README.md b/README.md index 8bdf682..7a713e5 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,18 @@ ## Зависимости -- Docker +- Пакетный менеджер [Nix](https://nix.dev/install-nix.html) -Все необходимые для генерации документов пакеты и система компьютерной верстки LuaTeX устанавливаются в docker-образ -автоматически при выполнении команд `make`. + Все остальные зависимости (texlive, GNU Make) устанавливаются при помощи Nix. ## Генерация документов +Для создания ad-hoc окружения с зависимостями проекта: + +```sh +nix-shell +``` + Для генерации всех pdf-файлов проекта в корневой директории проекта выполнить команду: ```sh diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..bdd1eca --- /dev/null +++ b/shell.nix @@ -0,0 +1,16 @@ +let + pkgsTarball = fetchTarball { + url = "https://github.com/NixOS/nixpkgs/tarball/nixos-25.05"; + sha256 = "0555pg9zcr3aazyxqb6g6q8vq3lc5zz3rnqx8ga1i3bs2q04yb4q"; + }; + pkgs = import pkgsTarball { + config = {}; overlays = []; + }; +in + +pkgs.mkShellNoCC { + packages = with pkgs; [ + texliveFull + gnumake + ]; +}