-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
218 lines (203 loc) · 6.44 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
{
description = "devenv editor";
inputs = {
nixpkgs.url =
"github:NixOS/nixpkgs/acb77d2bf9a902fe0d3f27c47ab39aa93afb4c2a";
emacs-overlay.url =
"github:nix-community/emacs-overlay/e61547b1c4cdf6e6ed72862748397e49df9129ca";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
purescript-overlay.url = "github:thomashoneyman/purescript-overlay";
purescript-overlay.inputs.nixpkgs.follows = "nixpkgs";
lean4.url = "github:leanprover/lean4";
lean4-mode.url = "github:leanprover/lean4-mode";
lean4-mode.flake = false;
};
outputs = { self, nixpkgs, emacs-overlay, rust-overlay, purescript-overlay
, lean4, lean4-mode }:
let
pkgs = import nixpkgs {
localSystem = "x86_64-linux";
overlays = [
emacs-overlay.overlay
rust-overlay.overlays.default
purescript-overlay.overlays.default
];
# allowUnfree for nvidia
config.allowUnfree = true;
};
devenNix = import ./default.nix;
devent = args: p:
devenNix (args // {
pkgs = p;
lean4 = lean4.packages.x86_64-linux;
lean4-mode = lean4-mode;
});
mkToolchains = args: (devent args pkgs).toolchains;
mkSet = setName: args:
let
mkEditor = editor: name: command: {
packages."x86_64-linux"."${name}${setName}" = editor;
apps."x86_64-linux"."${name}${setName}" = {
type = "app";
program = let
wrapper = pkgs.writeScriptBin "${command}-wrapper" ''
#!/bin/sh
export NIX_PATH=nixpkgs=${nixpkgs}
${devenv.profile}
exec ${editor}/bin/${command} $*
'';
in "${wrapper}/bin/${command}-wrapper";
};
};
pkgsNonFree = import nixpkgs {
localSystem = "x86_64-linux";
config.allowUnfree = true;
};
vscode = (devent args pkgsNonFree).vscode;
devenv = devent args pkgs;
nox = devent (args // { withX = false; }) pkgs;
in pkgs.lib.foldr pkgs.lib.recursiveUpdate { } [
(mkEditor devenv.emacs "emacs" "emacs")
(mkEditor nox.emacs "emacs-nox" "emacs")
(mkEditor devenv.vim "vim" "vim")
(mkEditor vscode "vscode" "code")
{
apps."x86_64-linux"."emacsclient${setName}" = {
type = "app";
program = let
wrapper = pkgs.writeScriptBin "emacsclient-wrapper" ''
#!/bin/sh
exec ${devenv.emacs}/bin/emacsclient $*
'';
in "${wrapper}/bin/emacsclient-wrapper";
};
}
];
get_runtime = name: runtime:
let
# It seems like flakes does not enable exporting a list of derivation.
# Thus instead, we generate the list of store path, so that they can be installed with
# nix profile install $(nix run .#toolchains)
wrapper = pkgs.writeScriptBin "print-runtime" ''
#!/bin/sh
echo ${builtins.toString (mkToolchains runtime)}
'';
in {
packages."x86_64-linux"."toolchains${name}" = wrapper;
apps."x86_64-linux"."toolchains${name}" = {
type = "app";
program = "${wrapper}/bin/print-runtime";
};
};
get_lang_runtime = name: runtime:
get_runtime name (runtime // { withLsp = true; });
base = {
withTools = true;
withGit = true;
withX = true;
};
essentials = base // {
withLsp = true;
withGerrit = true;
withOrg = true;
withC = true;
withSolarized = true;
withPython = true;
withNix = true;
withHaskell = true;
withGo = true;
withRust = true;
withLean = true;
withDhall = true;
withJson = true;
withYaml = true;
withRest = true;
withRpm = true;
withCss = true;
withJavascript = true;
withTypescript = true;
withMarkdown = true;
withRestructuredText = true;
withSpellChecker = true;
};
complete = essentials // {
withOrg = true;
withNotMuch = true;
withErlang = true;
withElixir = true;
withPurescript = true;
withGLSL = true;
withWGSL = true;
withPlantuml = true;
withMermaid = true;
withProtobuf = true;
withCapnp = true;
withThrift = true;
withAnsible = true;
withGraphQL = true;
withW3M = true;
withDarcs = true;
withHy = true;
withGraphviz = true;
withRescript = true;
withJust = true;
withRSS = true;
};
mkShell = xs:
pkgs.mkShell {
buildInputs = with pkgs; [ nix pkg-config zlib gcc ripgrep ] ++ xs;
};
nixGLSrc = pkgs.fetchFromGitHub {
owner = "guibou";
repo = "nixGL";
rev = "c917918ab9ebeee27b0dd657263d3f57ba6bb8ad";
sha256 = "sha256-KCkWZXCjH+C4Kn7fUGSrEl5btk+sERHhZueSsvVbPWc=";
};
nixGL = import nixGLSrc { pkgs = pkgs; };
gfxShell = with pkgs;
mkShell [
nixGL.auto.nixGLDefault
nixGL.auto.nixVulkanNvidia
nixGL.nixVulkanIntel
vulkan-tools
vulkan-loader
libGLU
libGL
glew
xorg.libX11
xorg.xrandr
xorg.libXcursor
xorg.libXxf86vm
xorg.libXinerama
xorg.libXrandr
xorg.libXi
xorg.libXext
glslang
vulkan-validation-layers
opusfile
openal
xorg.libXdmcp
vulkan-tools-lunarg
SDL
SDL2
wayland
wayland-protocols
glm
directfb
gmp
];
in pkgs.lib.foldr pkgs.lib.recursiveUpdate { } [
{ devShell."x86_64-linux" = gfxShell; }
(get_runtime "-minimal" base)
(get_runtime "" essentials)
(get_runtime "-complete" complete)
(get_lang_runtime "-haskell" { withHaskell = true; })
(get_lang_runtime "-purescript" { withPurescript = true; })
(get_lang_runtime "-rust" { withRust = true; })
(get_lang_runtime "-go" { withGo = true; })
(mkSet "-minimal" base)
(mkSet "" essentials)
(mkSet "-complete" complete)
];
}