forked from kudrykv/latex-yearly-planner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
91 lines (83 loc) · 2.47 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
{
description = "Install latex reqs";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
# Build the plannergen as a binary using fixed input versions
# This means that the subsequent pdf generation does not need internet access
# and is therefore a "pure" nix output
plannergen = pkgs.buildGoModule {
src = self;
name = "plannergen";
vendorHash = "sha256-T3x9Mtum87xEYz886P2YpchmrsGKWYwOLWxOrpErlA0=";
};
# Go is packaged into the devShell for developing the package,
# but is not used for the "nix build" outputs - these use the pre-built
# binary instead
goDeps = [
pkgs.go
];
# Dependencies for building the latex files
texDeps = with pkgs; [
libuuid # for the "rev" utility
ps # Used by build.sh
python3 # used in the build scripts
(texlive.combine {
inherit (texlive)
metafont
scheme-small
xcolor
pgf
wrapfig
makecell
multirow
leading
marginnote
adjustbox
multido
varwidth
blindtext
setspace
ifmtarg
extsizes
dashrule
;
})
];
in
rec
{
devShell = pkgs.mkShell {
shellHook = ''
unset GOPATH
unset GOROOT
unset GO_VERSION
'';
buildInputs = [
pkgs.nixpkgs-fmt # utility for pretty formatting of .nix files
] ++ goDeps ++ texDeps;
};
defaultPackage = pdfs;
pdfs = pkgs.stdenv.mkDerivation
{
name = "pdfs";
# Minimal set of dependencies to build the pdfs
# Latex, "rev" and the built plannergen binary
buildInputs = texDeps ++ [ plannergen ];
PLANNER_YEAR = 2024;
src = "${self}";
buildCommand = ''
cp -r $src/* .
patchShebangs .
chmod -R 770 *
chmod +x *.sh
PLANNERGEN_BINARY=plannergen eval $PWD/build.sh
mkdir $out
cp *.pdf $out/.
'';
};
}
);
}