diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f155d4..ea7fcb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## `master` - #134: Add `autoWire` option to control generation of flake outputs + - #138: Add `checks` to `outputs` submodule ## 0.2.0 (Mar 13, 2023) diff --git a/nix/flake-module.nix b/nix/flake-module.nix index fce932e..04dee0b 100644 --- a/nix/flake-module.nix +++ b/nix/flake-module.nix @@ -32,7 +32,13 @@ in ''; default = false; }; - + drv = mkOption { + type = types.package; + readOnly = true; + description = '' + The `hlsCheck` derivation generated for this project. + ''; + }; }; }; packageSubmodule = with types; submodule { @@ -136,13 +142,14 @@ in The development shell derivation generated for this project. ''; }; - hlsCheck = mkOption { - type = types.package; + checks = mkOption { + type = types.lazyAttrsOf types.package; readOnly = true; description = '' - The `hlsCheck` derivation generated for this project. + The flake checks generated for this project. ''; }; + }; }; projectSubmodule = types.submoduleWith { @@ -310,9 +317,8 @@ in checks = mergeMapAttrs (name: project: - lib.optionalAttrs (project.autoWire && project.devShell.enable && project.devShell.hlsCheck.enable) { - "${name}-hls" = project.outputs.hlsCheck; - }) + lib.optionalAttrs project.autoWire project.outputs.checks + ) config.haskellProjects; }; }); diff --git a/nix/haskell-project.nix b/nix/haskell-project.nix index 7215a18..c8c2577 100644 --- a/nix/haskell-project.nix +++ b/nix/haskell-project.nix @@ -62,6 +62,11 @@ in ++ builtins.attrValues (config.devShell.extraLibraries p); }; }); + hlsCheck = + runCommandInSimulatedShell + devShell + self "${projectKey}-hls-check" + { } "haskell-language-server"; in { outputs = { @@ -84,11 +89,12 @@ in (name: _: finalPackages."${name}") config.packages; - hlsCheck = runCommandInSimulatedShell - devShell - self "${projectKey}-hls-check" - { } "haskell-language-server"; + checks = lib.filterAttrs (_: v: v != null) { + "${name}-hls" = if (config.devShell.enable && config.devShell.hlsCheck.enable) then hlsCheck else null; + }; }; + + devShell.hlsCheck.drv = hlsCheck; }; }