Add autoWire option, to control flake outputs (#134)

* Add autoWire option, to control flake outputs

* add changelog
This commit is contained in:
Sridhar Ratnakumar 2023-03-30 16:53:07 -04:00 committed by GitHub
parent 65c166728f
commit 2fde5d0cab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 5 deletions

View File

@ -1,5 +1,9 @@
# Revision history for haskell-flake # Revision history for haskell-flake
## `master`
- #134: Add `autoWire` option to control generation of flake outputs
## 0.2.0 (Mar 13, 2023) ## 0.2.0 (Mar 13, 2023)
- New features - New features

View File

@ -256,8 +256,17 @@ in
This is an internal option, not meant to be set by the user. This is an internal option, not meant to be set by the user.
''; '';
}; };
autoWire = mkOption {
type = types.bool;
description = ''
Automatically wire up the project outputs to the flake outputs.
Disable this if you want to control the flake outputs
yourself. Useful, for example, when overriding the default
shell.
'';
default = true;
};
}; };
}) })
]; ];
@ -269,7 +278,6 @@ in
description = "Haskell projects"; description = "Haskell projects";
type = types.attrsOf projectSubmodule; type = types.attrsOf projectSubmodule;
}; };
}; };
config = config =
@ -290,19 +298,19 @@ in
then packageName then packageName
else "${name}-${packageName}"; else "${name}-${packageName}";
in in
mapKeys dropDefaultPrefix project.outputs.localPackages) lib.optionalAttrs project.autoWire (mapKeys dropDefaultPrefix project.outputs.localPackages))
config.haskellProjects; config.haskellProjects;
devShells = devShells =
mergeMapAttrs mergeMapAttrs
(name: project: (name: project:
lib.optionalAttrs project.devShell.enable { lib.optionalAttrs (project.autoWire && project.devShell.enable) {
"${name}" = project.outputs.devShell; "${name}" = project.outputs.devShell;
}) })
config.haskellProjects; config.haskellProjects;
checks = checks =
mergeMapAttrs mergeMapAttrs
(name: project: (name: project:
lib.optionalAttrs (project.devShell.enable && project.devShell.hlsCheck.enable) { lib.optionalAttrs (project.autoWire && project.devShell.enable && project.devShell.hlsCheck.enable) {
"${name}-hls" = project.outputs.hlsCheck; "${name}-hls" = project.outputs.hlsCheck;
}) })
config.haskellProjects; config.haskellProjects;