-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
169 lines (148 loc) · 5.33 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
{
description = "Use old TeXlive versions";
nixConfig.extra-experimental-features = "nix-command flakes";
inputs = {
# flake utils
utils.url = "github:gytis-ivaskevicius/flake-utils-plus/v1.3.0";
devshell.url = "github:numtide/devshell";
devshell.inputs.nixpkgs.follows = "default";
## only nixpkgs nix-library, without whole nixpkgs
nixlib.url = "github:nix-community/nixpkgs.lib";
# nixpkgs
unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixos.url = "github:NixOS/nixpkgs/release-22.11";
tl2021.url # latest nixpkgs commit with texlive 2021
= "github:NixOS/nixpkgs/cb2f60a2d13a9da2510fa172c0e69ccbf14f18b7";
tl2020.url # latest nixpkgs commit with texlive 2020
= "github:NixOS/nixpkgs/ca44268569be4eb348b24bc0705e0482b9ea87a1";
tl2012.url # latest nixpkgs commit with texlive 2012 (nearest to ScholarOne's 2013)
= "github:NixOS/nixpkgs/4dee7de246e6037d494d798efd2a383d9fccc8cc";
tl2012.flake = false;
## defaults
tl2022.follows = "unstable";
arxiv.follows = "tl2020"; # see https://arxiv.org/help/faq/texlive
nixpkgs.follows = "nixos";
default.follows = "nixpkgs";
};
outputs =
{ self
, utils
, devshell
, nixlib
, ...
}@inputs:
utils.lib.mkFlake {
inherit self inputs;
#overlays = utils.lib.exportOverlays { inherit (self) pkgs inputs; };
overlays =
utils.lib.exportOverlays { inherit (self) pkgs inputs; }
#//
#{
#default = self.overlays.default
;
channels = with nixlib.lib; {
tl2012.input = inputs.default;
tl2012.overlaysBuilder = channels: [
(final: prev: {
texlive =
{
combined.scheme-full =
with prev; with import inputs.tl2012 { inherit (prev) system; };
lib.setName "texlive-full" (texLiveAggregationFun {
paths = [
texLive texLiveExtra lmodern texLiveCMSuper texLiveLatexXColor
texLivePGF texLiveBeamer tipa tex4ht texinfo5
];
});
mkShell =
{ name
, texlivePkg ? final.texlive.combined.scheme-full
, texdocCmd ? "LC_ALL=C ${texlivePkg}/bin/texlua ${texlivePkg}/libexec/x86_64/texdoc"
, ...
}@args:
prev.texlive.mkShell (args // { inherit texdocCmd; });
};
})
];
}
// genAttrs [ "tl2020" "arxiv" ] (_: {
overlaysBuilder = channels: [ (final: prev: {
texlive =
prev.texlive
// {
mkShell =
{ name
, texdocCmd ? "${channels.default.texlive.combined.scheme-full}/bin/texdoc"
, ...
}@args:
prev.texlive.mkShell (args // { inherit texdocCmd; });
};
}) ];
});
sharedOverlays = [
devshell.overlay
(final: prev: with nixlib.lib; {
texlive = optionalAttrs (prev ? texlive) prev.texlive
// {
mkShell =
{ name
, texlivePkg ? final.texlive.combined.scheme-full
, texdocCmd ? "${texlivePkg}/bin/texdoc"
, packages ? []
}:
final.devshell.mkShell {
inherit name;
commands = [
{ name = "texdoc"; category = "documentation"; help = "TeX documentation";
command = ''${texdocCmd} "$@"'';
}
];
packages = packages ++ [ (lowPrio texlivePkg) ];
};
};
})
(final: prev: with nixlib.lib; {
texlive =
let
tl = prev.texlive;
tlDoc = recursiveUpdate tl {
combined.scheme-full = tl.combine {
inherit (tl) scheme-full;
pkgFilter = pkg:
pkg.tlType != "source"
# add documentation to texlive
# texdoc doesn't work in texlive <= 2020 from nixpkgs.
# prevent double doc packages
&& pkg.pname == "core" -> pkg.tlType != "doc";
};
};
in if tl ? bin && toInt tl.bin.core.version >= 2021 then tlDoc else tl;
})
];
outputsBuilder = channels:
let
inherit (channels.default) system;
projName = "ancienTeX";
in {
packages = with nixlib.lib;
utils.lib.exportPackages self.overlays channels
// flip mapAttrs' channels
(name': channel: rec {
name = "devshell/${name'}";
value = channel.texlive.mkShell { name = "${projName}/${name}"; };
})
// { default = self.packages.${system}."devshell/default"; };
overlay = self.overlays."default/texlive";
apps = {
texdoc = utils.lib.mkApp { # use this when using texlive <= 2020. Since 2021, texdoc works natively
drv = self.devShells.${system}.nixos;
exePath = "/bin/texdoc";
};
};
};
templates.default = {
path = ./template;
description = "minimal default template";
};
};
}