Skip to content

Commit 5bd78f7

Browse files
committed
Fixes devshells
1 parent 935cdd6 commit 5bd78f7

File tree

2 files changed

+42
-126
lines changed

2 files changed

+42
-126
lines changed

extras/flake-haskell.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ let
77
, dependencies ? [ ]
88
, devShellTools ? [ ]
99
, devShellHook
10+
, devShellAdditionalPackages ? [ ]
1011
, index-state
1112
, compiler-nix-name
1213
, modules ? [ ]
1314
}: {
14-
inherit src name dependencies devShellTools devShellHook index-state compiler-nix-name modules;
15+
inherit src name dependencies devShellTools devShellHook index-state compiler-nix-name modules devShellAdditionalPackages;
1516
};
1617

1718
hsNixProj = opts: with (haskellNixOpts opts);
@@ -35,6 +36,7 @@ let
3536
withHoogle = true;
3637
exactDeps = true;
3738
nativeBuildInputs = devShellTools;
39+
additional = devShellAdditionalPackages;
3840

3941
tools = {
4042
cabal = { };

libs/build.nix

Lines changed: 39 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -103,58 +103,27 @@
103103
# - the CLI application (`lbf-prelude-to-haskell`) to compile `.lbf`
104104
# schemas
105105
let
106-
project = { lib, ... }: {
106+
hsFlake = config.lbf-nix.haskellFlake {
107107
src = config.packages.lbf-prelude-haskell;
108108

109109
name = "dev-prelude-haskell";
110110

111111
inherit (config.settings.haskell) index-state compiler-nix-name;
112112

113-
extraHackage = [
113+
dependencies = [
114114
"${config.packages.lbr-prelude-haskell-src}"
115115
"${config.packages.lbf-prelude-haskell}"
116116
];
117+
# Note: Add `lbf-prelude` Haskell package in the devShell environment.
118+
# This *must* be the name of the autogenerated cabal package from
119+
# `lbf-prelude-haskell`
120+
devShellAdditionalPackages = ps: [ ps.lbf-prelude ];
117121

118-
modules = [
119-
(_: {
120-
packages = {
121-
allComponent.doHoogle = true;
122-
allComponent.doHaddock = true;
123-
};
124-
})
125-
];
126-
127-
shell = {
128-
129-
withHoogle = true;
130-
131-
exactDeps = true;
132-
133-
nativeBuildInputs = config.settings.shell.tools
134-
++ [ config.packages.lbf-prelude-to-haskell ];
135-
136-
# Note: the `additional` (contrast to `packages`) attribute
137-
# includes the dependencies + the package itself. See:
138-
# https://input-output-hk.github.io/haskell.nix/reference/library.html#shellfor
139-
# This *must* be the name of the autogenerated cabal package from
140-
# `lbf-prelude-haskell`
141-
additional = ps: [ ps.lbf-prelude ];
142-
143-
tools = {
144-
cabal = { };
145-
haskell-language-server = { };
146-
};
147-
148-
shellHook = lib.mkForce config.settings.shell.hook;
149-
};
122+
devShellTools = config.settings.shell.tools ++ [ config.packages.lbf-prelude-to-haskell ];
123+
devShellHook = config.settings.shell.hook;
150124
};
151-
hsNixFlake = (pkgs.haskell-nix.cabalProject' [
152-
inputs.mlabs-tooling.lib.mkHackageMod
153-
inputs.mlabs-tooling.lib.moduleMod
154-
project
155-
]).flake { };
156125
in
157-
hsNixFlake.devShell;
126+
hsFlake.devShell;
158127

159128
dev-plutustx =
160129
# Note:
@@ -170,72 +139,47 @@
170139
# Note:
171140
# This is mostly duplicated code from `dev-prelude-haskell`
172141
let
173-
project = { lib, ... }: {
142+
hsFlake = config.lbf-nix.haskellPlutusFlake {
174143
src = config.packages.lbf-plutus-haskell;
175144

176145
name = "dev-plutustx";
177146

178147
inherit (config.settings.haskell) index-state compiler-nix-name;
179148

180-
extraHackage = [
149+
dependencies = [
181150
"${config.packages.lbr-prelude-haskell-src}"
182151
"${config.packages.lbf-prelude-haskell}"
183152
"${config.packages.lbr-plutus-haskell-src}"
184153
"${config.packages.lbf-plutus-haskell}"
185154
];
186-
187-
modules = [
188-
(_: {
189-
packages = {
190-
allComponent.doHoogle = true;
191-
allComponent.doHaddock = true;
192-
};
193-
})
155+
# Note: Add `lbf-prelude` and `lbf-plutus` Haskell packages in the devShell environment.
156+
# This *must* be the name of the autogenerated cabal package from
157+
# `lbf-prelude-haskell` and `lbf-plutus-haskell`
158+
devShellAdditionalPackages = ps: [ ps.lbf-prelude ps.lbf-plutus ];
159+
160+
devShellTools = config.settings.shell.tools ++ [
161+
# We include both the Prelude and Plutus
162+
# frontend. Perhaps, we should _only_ include the
163+
# Plutus frontend, but it doesn't hurt to include both.
164+
config.packages.lbf-prelude-to-haskell
165+
config.packages.lbf-plutus-to-haskell
194166
];
195167

196-
shell = {
197-
198-
withHoogle = true;
199-
200-
exactDeps = true;
201-
202-
nativeBuildInputs = config.settings.shell.tools
203-
++ [
204-
# We include both the Prelude and Plutus
205-
# frontend. Perhaps, we should _only_ include the
206-
# Plutus frontend, but it doesn't hurt to include both.
207-
config.packages.lbf-prelude-to-haskell
208-
config.packages.lbf-plutus-to-haskell
209-
];
210-
211-
additional = ps: [ ps.lbf-plutus ];
212-
213-
tools = {
214-
cabal = { };
215-
haskell-language-server = { };
216-
};
217-
218-
shellHook = lib.mkForce config.settings.shell.hook;
219-
};
168+
devShellHook = config.settings.shell.hook;
220169
};
221-
hsNixFlake = (pkgs.haskell-nix.cabalProject' [
222-
inputs.mlabs-tooling.lib.mkHackageMod
223-
inputs.mlabs-tooling.lib.moduleMod
224-
project
225-
]).flake { };
226170
in
227-
hsNixFlake.devShell;
171+
hsFlake.devShell;
228172

229173
dev-plutarch =
230174
let
231-
project = { lib, ... }: {
175+
hsFlake = config.lbf-nix.haskellPlutusFlake {
232176
src = config.packages.lbf-plutus-plutarch;
233177

234178
name = "dev-plutarch";
235179

236180
inherit (config.settings.haskell) index-state compiler-nix-name;
237181

238-
extraHackage = [
182+
dependencies = [
239183
# Load Plutarch support (Prelude, Plutus)
240184
"${config.packages.lbf-prelude-plutarch}"
241185
"${config.packages.lbf-plutus-plutarch}"
@@ -249,54 +193,24 @@
249193
"${inputs.plutarch}"
250194
"${inputs.plutarch}/plutarch-extra"
251195
];
252-
253-
modules = [
254-
(_: {
255-
packages = {
256-
#allComponent.doHoogle = true;
257-
#allComponent.doHaddock = true;
258-
259-
# lbf-prelude.configureFlags = [ "-f-dev" ];
260-
};
261-
})
196+
devShellAdditionalPackages = ps: [
197+
ps.lbf-prelude-plutarch
198+
ps.lbf-plutus-plutarch
199+
ps.lbr-plutarch
200+
ps.plutus-tx
201+
ps.plutus-ledger-api
262202
];
263203

264-
shell = {
265-
266-
withHoogle = true;
267-
268-
exactDeps = true;
269-
270-
nativeBuildInputs = config.settings.shell.tools ++ [
271-
config.packages.lbf-plutus-to-plutarch
272-
config.packages.lbf-prelude-to-haskell
273-
config.packages.lbf-plutus-to-haskell
274-
];
275-
276-
additional = ps: [
277-
ps.lbf-prelude-plutarch
278-
ps.lbf-plutus-plutarch
279-
ps.lbr-plutarch
280-
ps.plutus-tx
281-
ps.plutus-ledger-api
282-
];
283-
284-
tools = {
285-
cabal = { };
286-
haskell-language-server = { };
287-
};
204+
devShellTools = config.settings.shell.tools ++ [
205+
config.packages.lbf-plutus-to-plutarch
206+
config.packages.lbf-prelude-to-haskell
207+
config.packages.lbf-plutus-to-haskell
208+
];
288209

289-
shellHook = lib.mkForce config.settings.shell.hook;
290-
};
210+
devShellHook = config.settings.shell.hook;
291211
};
292-
hsNixFlake = (pkgs.haskell-nix.cabalProject' [
293-
inputs.mlabs-tooling.lib.mkHackageMod
294-
inputs.mlabs-tooling.lib.moduleMod
295-
project
296-
]).flake { };
297212
in
298-
hsNixFlake.devShell;
299-
213+
hsFlake.devShell;
300214
};
301215
};
302216
}

0 commit comments

Comments
 (0)