-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
147 lines (126 loc) · 4.59 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
{
description = "Easy dev shells for multiple 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-24.05";
nixos-2311.url = "github:NixOS/nixpkgs/release-23.11";
tl2023.follows = "unstable";
tl2022.url # latest nixpkgs commit with texlive 2022 that is prebuilt by hydra
= "github:NixOS/nixpkgs/62b78e643ce4f7c8d2c62bec040686ba311eb76c";
tl2021.url # latest nixpkgs commit with texlive 2021
= "github:NixOS/nixpkgs/cb2f60a2d13a9da2510fa172c0e69ccbf14f18b7";
tl2012.url # latest nixpkgs commit with texlive 2012 (nearest to ScholarOne's 2013)
= "github:NixOS/nixpkgs/4dee7de246e6037d494d798efd2a383d9fccc8cc";
tl2012.flake = false;
## defaults
arxiv.follows = "tl2023";
nixpkgs.follows = "tl2023";
default.follows = "nixpkgs";
};
outputs =
{ self
, utils
, devshell
, nixlib
, ...
}@inputs:
utils.lib.mkFlake {
inherit self inputs;
overlays = utils.lib.exportOverlays { inherit (self) pkgs inputs; };
channels = with nixlib.lib; {
tl2012.input = inputs.default;
tl2012.overlaysBuilder = channels: [
(final: prev: {
texlive =
{
# back then, the TeX infrastructure in Nixpkgs was very different.
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; });
};
})
];
};
sharedOverlays = [
devshell.overlays.default
(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;
in
recursiveUpdate tl {
combined.scheme-full = tl.combine {
inherit (final.texlive) scheme-full;
pkgFilter = p:
p.tlType != "source"
# add documentation to texlive
# texdoc doesn't work in texlive <= 2020 from nixpkgs.
# prevent double doc packages
&& p.pname == "core" -> p.tlType != "doc";
};
};
})
];
outputsBuilder = channels:
let
inherit (channels.default) system;
projName = "texshell";
in {
packages = with nixlib.lib;
utils.lib.exportPackages self.overlays channels
// flip mapAttrs' channels
(name: channel: {
inherit name;
value = channel.texlive.mkShell {
name = "${projName}/${name}";
packages = with channel; [ gnumake ]; # make is often needed
};
});
overlay = self.overlays."default/texlive";
};
templates.default = {
path = ./template;
description = "minimal default template";
};
};
}