Skip to content

Commit 50c8238

Browse files
authored
chore(nix): improve nix devShell#scope (#11696)
Signed-off-by: Antonio Nuno Monteiro <[email protected]>
1 parent 7a8a703 commit 50c8238

File tree

1 file changed

+33
-12
lines changed

1 file changed

+33
-12
lines changed

flake.nix

+33-12
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,12 @@
8080
testBuildInputs = with pkgs;
8181
[ file mercurial unzip ]
8282
++ lib.optionals stdenv.isLinux [ strace ];
83-
testNativeBuildInputs = with pkgs; [ nodejs-slim pkg-config opam ocamlformat ];
83+
testNativeBuildInputs = pkgs: with pkgs; [
84+
nodejs-slim
85+
pkg-config
86+
opam
87+
ocamlformat
88+
];
8489

8590
docInputs = with pkgs.python3.pkgs; [
8691
sphinx-autobuild
@@ -97,7 +102,24 @@
97102
default = with pkgs; stdenv.mkDerivation {
98103
pname = "dune";
99104
version = "n/a";
100-
src = ./.;
105+
src =
106+
let fs = lib.fileset; in
107+
fs.toSource {
108+
root = ./.;
109+
fileset = fs.unions [
110+
./bin
111+
./boot
112+
./configure
113+
./dune-project
114+
./dune-file
115+
./src
116+
./plugin
117+
./vendor
118+
./otherlibs
119+
./Makefile
120+
(fs.fileFilter (file: file.hasExt "opam" || file.hasExt "template") ./.)
121+
];
122+
};
101123
nativeBuildInputs = with ocamlPackages; [ ocaml findlib ];
102124
buildInputs = lib.optionals stdenv.isDarwin [
103125
darwin.apple_sdk.frameworks.CoreServices
@@ -118,7 +140,7 @@
118140
devShells =
119141
let
120142
makeDuneDevShell =
121-
{ extraBuildInputs ? [ ]
143+
{ extraBuildInputs ? (pkgs: [ ])
122144
, meta ? null
123145
, duneFromScope ? false
124146
}:
@@ -134,7 +156,6 @@
134156
else pkgs;
135157

136158
inherit (pkgs') writeScriptBin stdenv;
137-
inherit docInputs;
138159

139160
duneScript =
140161
writeScriptBin "dune" ''
@@ -148,7 +169,7 @@
148169
export DUNE_SOURCE_ROOT=$PWD
149170
'';
150171
inherit meta;
151-
nativeBuildInputs = testNativeBuildInputs
172+
nativeBuildInputs = (testNativeBuildInputs pkgs')
152173
++ docInputs
153174
++ [ duneScript ];
154175
inputsFrom = [ pkgs'.ocamlPackages.dune_3 ];
@@ -166,7 +187,7 @@
166187
odoc
167188
lwt
168189
patdiff
169-
] ++ extraBuildInputs);
190+
] ++ (extraBuildInputs pkgs'));
170191
};
171192
in
172193
{
@@ -196,7 +217,7 @@
196217
'';
197218
};
198219
slim-melange = makeDuneDevShell {
199-
extraBuildInputs = [
220+
extraBuildInputs = pkgs: [
200221
pkgs.ocamlPackages.melange
201222
];
202223
meta.description = ''
@@ -205,7 +226,7 @@
205226
'';
206227
};
207228
slim-opam = with pkgs; mkShell {
208-
nativeBuildInputs = lib.remove pkgs.ocamlformat testNativeBuildInputs;
229+
nativeBuildInputs = lib.remove pkgs.ocamlformat (testNativeBuildInputs pkgs);
209230
buildInputs = lib.optionals stdenv.isDarwin [
210231
darwin.apple_sdk.frameworks.CoreServices
211232
];
@@ -217,7 +238,7 @@
217238

218239
coq =
219240
pkgs.mkShell {
220-
nativeBuildInputs = testNativeBuildInputs;
241+
nativeBuildInputs = (testNativeBuildInputs pkgs);
221242
# Coq requires OCaml 4.x
222243
inputsFrom = [ pkgs.ocaml-ng.ocamlPackages_4_14.dune_3 ];
223244
buildInputs = with pkgs; [
@@ -230,8 +251,8 @@
230251
'';
231252
};
232253
microbench = makeDuneDevShell {
233-
extraBuildInputs = with pkgs.ocamlPackages; [
234-
core_bench
254+
extraBuildInputs = pkgs: [
255+
pkgs.ocamlPackages.core_bench
235256
];
236257
meta.description = ''
237258
Provides a minimal shell environment that can build the
@@ -249,7 +270,7 @@
249270
};
250271
default =
251272
makeDuneDevShell {
252-
extraBuildInputs = (with pkgs; [
273+
extraBuildInputs = pkgs: (with pkgs; [
253274
# dev tools
254275
ccls
255276
]) ++ (with pkgs.ocamlPackages; [

0 commit comments

Comments
 (0)