Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build using nix #232

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Dockerfile
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 /
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ sh build.sh

Прогресс первой сборки (очень долгой) можно смотреть по увеливению количества файлов в папке [tikz/resource](tikz/resource). Там будет храниться локальный кэш картинок, сгенерированных с помощью TikZ.

### Nix
Альтернативно, вы можете поставить [nix](https://nixos.org) и открыть окружение для разработки командой `nix develop`. Из него вам будет доступна команда `build-notebook`, которая собирает астрадь. Если вы просто хотите собрать итоговую астрадь (с `useLightPlotVersion`), можно также вызвать `nix build`, который соберет астрадь в изолированном окружении и положит результат в папку `result`.

## Соавторство
### Список TODO
Актуальный список TODO можно посмотреть [тут](https://github.com/AShepelevv/astro.notebook/labels/todo). Добавить свою идею, правку или предложение можно, [создав issue](https://github.com/AShepelevv/astro.notebook/issues/new). После обсуждения issue попадет в список TODO.
Expand Down
78 changes: 78 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 71 additions & 0 deletions flake.nix
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/
'';
};
};
};
};
}
98 changes: 98 additions & 0 deletions nix/texlive.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{ texlive }:
let
texliveBasic = {
inherit (texlive) scheme-basic;
};

texliveLanguageSupport = {
inherit (texlive) babel babel-russian hyphen-russian;
};

texliveFonts = {
inherit (texlive)
cm-unicode
fontspec
mathspec
jknapltx
was
wasy
starfont
wasysym
textcase
rsfs
collection-fontsrecommended
collection-fontutils
;
};

texliveMaths = {
inherit (texlive)
siunitx
amsmath
amsfonts
cancel
mathtools
units
xfrac
;
};

texliveGraphics = {
inherit (texlive)
pdflscape
graphics
pgf
tkz-euclide
tikz-3dplot
spath3
pgfplots
qrcode
;
};

texliveLayout = {
inherit (texlive)
geometry
titlesec
adjustbox
caption
pdfpages
xpatch
enumitem
tocloft
wrapfig
;
};

texliveUtilities = {
inherit (texlive)
xetex
xcolor
xifthen
xurl
hyperref
lipsum
latexmk
ifmtarg
;
};

texliveBib = {
inherit (texlive)
biblatex
biblatex-ext
siunitx
;
};

texlivePackages =
texliveBasic
// texliveLanguageSupport
// texliveFonts
// texliveMaths
// texliveGraphics
// texliveLayout
// texliveUtilities
// texliveBib;
in
texlive.combine texlivePackages