Skip to content

Commit c74e7c5

Browse files
authored
Add outputs.checks (#138)
1 parent bae56fa commit c74e7c5

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## `master`
44

55
- #134: Add `autoWire` option to control generation of flake outputs
6+
- #138: Add `checks` to `outputs` submodule
67

78
## 0.2.0 (Mar 13, 2023)
89

nix/flake-module.nix

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ in
3232
'';
3333
default = false;
3434
};
35-
35+
drv = mkOption {
36+
type = types.package;
37+
readOnly = true;
38+
description = ''
39+
The `hlsCheck` derivation generated for this project.
40+
'';
41+
};
3642
};
3743
};
3844
packageSubmodule = with types; submodule {
@@ -136,13 +142,14 @@ in
136142
The development shell derivation generated for this project.
137143
'';
138144
};
139-
hlsCheck = mkOption {
140-
type = types.package;
145+
checks = mkOption {
146+
type = types.lazyAttrsOf types.package;
141147
readOnly = true;
142148
description = ''
143-
The `hlsCheck` derivation generated for this project.
149+
The flake checks generated for this project.
144150
'';
145151
};
152+
146153
};
147154
};
148155
projectSubmodule = types.submoduleWith {
@@ -310,9 +317,8 @@ in
310317
checks =
311318
mergeMapAttrs
312319
(name: project:
313-
lib.optionalAttrs (project.autoWire && project.devShell.enable && project.devShell.hlsCheck.enable) {
314-
"${name}-hls" = project.outputs.hlsCheck;
315-
})
320+
lib.optionalAttrs project.autoWire project.outputs.checks
321+
)
316322
config.haskellProjects;
317323
};
318324
});

nix/haskell-project.nix

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ in
6262
++ builtins.attrValues (config.devShell.extraLibraries p);
6363
};
6464
});
65+
hlsCheck =
66+
runCommandInSimulatedShell
67+
devShell
68+
self "${projectKey}-hls-check"
69+
{ } "haskell-language-server";
6570
in
6671
{
6772
outputs = {
@@ -84,11 +89,12 @@ in
8489
(name: _: finalPackages."${name}")
8590
config.packages;
8691

87-
hlsCheck = runCommandInSimulatedShell
88-
devShell
89-
self "${projectKey}-hls-check"
90-
{ } "haskell-language-server";
92+
checks = lib.filterAttrs (_: v: v != null) {
93+
"${name}-hls" = if (config.devShell.enable && config.devShell.hlsCheck.enable) then hlsCheck else null;
94+
};
9195

9296
};
97+
98+
devShell.hlsCheck.drv = hlsCheck;
9399
};
94100
}

0 commit comments

Comments
 (0)