forked from kitmatheinfo/latexfogel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
91 lines (85 loc) · 2.89 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# IMPORTANT:
#
# When using the flake as input, include `?submodules=1` at the end of the flake
# URL. This also applies when building the flake, meaning you have to use the
# following command:
#
# $ nix build '.?submodules=1'
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
naersk.url = "github:nix-community/naersk";
naersk.inputs.nixpkgs.follows = "nixpkgs";
typst-packages.url = "github:typst/packages";
typst-packages.flake = false;
};
outputs = { self, nixpkgs, naersk, typst-packages }:
let forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
in rec {
packages = exported-packages;
# We need a unique name for this that does not clash with anything in the
# devShells declaration
exported-packages = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
naersk' = pkgs.callPackage naersk { };
texliveCombined = (pkgs.texlive.combine {
inherit (pkgs.texlive)
babel-german
bussproofs
unicode-math
fontspec
latexmk
preview
lm
lm-math
scheme-basic
standalone
xcolor
xetex
braket
;
});
in
rec {
latexfogel = naersk'.buildPackage { src = ./.; };
default = latexfogel;
docker = pkgs.dockerTools.buildLayeredImage {
name = "ghcr.io/kitmatheinfo/latexfogel";
tag = latexfogel.version;
contents = with pkgs; [
latexfogel
cacert # or reqwest is very unhappy
fontconfig # or tectonic fails
bash # or magick can not spawn `gs`
imagemagick # to convert, imagemagick_light has no adapter
ghostscript_headless # to convert
docker-client # to communicate with docker
texliveCombined
];
config = {
Entrypoint = [ "/bin/latexfogel" ];
WorkingDir = "/";
Env = [
"FONTCONFIG_FILE=${pkgs.makeFontsConf { fontDirectories = [ texliveCombined.fonts pkgs.noto-fonts pkgs.noto-fonts-color-emoji ]; }}"
"TYPST_PACKAGES=${typst-packages}/packages"
"HOME=/tmp"
];
};
};
}
);
devShells = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
docker-image = exported-packages."${system}".docker;
in rec {
docker = pkgs.mkShell rec {
publish = pkgs.writeScriptBin "publish" ''
chore/publish.sh "${docker-image}" "${docker-image.imageName}" "${docker-image.imageTag}" "$1"
'';
packages = [ publish ];
};
});
};
}