-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
81 lines (75 loc) · 2.06 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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
systems.url = "github:nix-systems/default";
};
outputs = {
self,
systems,
nixpkgs,
}: let
eachSystem = f:
nixpkgs.lib.genAttrs
(import systems)
(system: f nixpkgs.legacyPackages.${system});
in rec {
packages = eachSystem (pkgs: rec {
# Tex package
default = theme;
theme = let
texDeps = ps: with ps; [
scheme-basic
fancyvrb
beamer
xkeyval
fira
fontaxes
];
in pkgs.stdenvNoCC.mkDerivation {
pname = "gelos-beamer";
version = self.shortRev or "unstable";
src = ./.;
outputs = ["tex" "out"];
passthru.tlDeps = texDeps pkgs.texlive;
nativeBuildInputs = [(pkgs.texlive.withPackages texDeps)];
installPhase = ''
install -D beamerthemegelos.sty gelos-dark.png gelos-light.png -t $out/tex/latex/gelosbeamer
ln -s $out $tex
'';
};
# Texlive environment containing the theme
texlive-env = pkgs.texlive.withPackages (_: [default]);
# A function to easen usage
mkGelosSlides = {
pname ? "slides",
version ? "unstable",
src,
ignore ? ["README.md"],
texlive ? texlive-env,
pandoc ? pkgs.pandoc,
stdenv ? pkgs.stdenvNoCC,
...
}@args:
stdenv.mkDerivation {
inherit pname version src;
nativeBuildInputs = [pandoc texlive];
buildPhase = ''
rm -f ${builtins.concatStringsSep " " ignore}
pandoc -t beamer -V theme=gelos *.md -o ${pname}.pdf
'';
installPhase = "install -D ${pname}.pdf -t $out";
} // args;
# A sample pdf using the theme
sample = mkGelosSlides {
pname = "sample";
src = ./.;
};
});
devShells = eachSystem (pkgs: {
default = pkgs.mkShell {
packages = [packages.${pkgs.system}.texlive-env pkgs.pandoc];
};
});
formatter = eachSystem (pkgs: pkgs.alejandra);
};
}