Change autoWire to be an enum type (#143)

This commit is contained in:
Sridhar Ratnakumar 2023-04-12 18:22:28 -04:00 committed by GitHub
parent de35e3189e
commit 8fb3bbe77c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 13 deletions

View File

@ -4,6 +4,7 @@
- #134: Add `autoWire` option to control generation of flake outputs
- #138: Add `checks` to `outputs` submodule
- #143: Changed `autoWire` to be an enum type, for granular controlling of which outputs to autowire.
## 0.2.0 (Mar 13, 2023)

View File

@ -263,17 +263,21 @@ in
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.
autoWire =
let
outputTypes = [ "packages" "checks" "devShells" ];
in
mkOption {
type = types.listOf (types.enum outputTypes);
description = ''
List of flake output types to autowire.
Disable this if you want to control the flake outputs
yourself. Useful, for example, when overriding the default
shell.
'';
default = true;
};
Using an empty list will disable autowiring entirely,
enabling you to manually wire them using
`config.haskellProjects.<name>.outputs`.
'';
default = outputTypes;
};
};
})
];
@ -291,6 +295,7 @@ in
let
# Like mapAttrs, but merges the values (also attrsets) of the resulting attrset.
mergeMapAttrs = f: attrs: lib.mkMerge (lib.mapAttrsToList f attrs);
contains = k: vs: lib.any (x: x == k) vs;
in
{
packages =
@ -305,19 +310,19 @@ in
then packageName
else "${name}-${packageName}";
in
lib.optionalAttrs project.autoWire (mapKeys dropDefaultPrefix project.outputs.localPackages))
lib.optionalAttrs (contains "packages" project.autoWire) (mapKeys dropDefaultPrefix project.outputs.localPackages))
config.haskellProjects;
devShells =
mergeMapAttrs
(name: project:
lib.optionalAttrs (project.autoWire && project.devShell.enable) {
lib.optionalAttrs (contains "devShells" project.autoWire && project.devShell.enable) {
"${name}" = project.outputs.devShell;
})
config.haskellProjects;
checks =
mergeMapAttrs
(name: project:
lib.optionalAttrs project.autoWire project.outputs.checks
lib.optionalAttrs (contains "checks" project.autoWire) project.outputs.checks
)
config.haskellProjects;
};