1
0
Fork 0
mirror of https://github.com/hercules-ci/flake-parts.git synced 2024-12-14 11:47:31 +00:00

Merge pull request #14 from hercules-ci/polyfill-functionTo

Polyfill functionTo where it is pressing
This commit is contained in:
Robert Hensing 2022-05-17 23:30:32 +02:00 committed by GitHub
commit cb99722a25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

24
lib.nix
View file

@ -3,9 +3,29 @@ let
inherit (lib)
mkOption
types
functionTo
;
# Polyfill functionTo to make sure it has type merging.
# Remove 2022-12
functionTo =
let sample = types.functionTo lib.types.str;
in
if sample.functor.wrapped._type or null == "option-type"
then types.functionTo
else
elemType: lib.mkOptionType {
name = "functionTo";
description = "function that evaluates to a(n) ${elemType.description}";
check = lib.isFunction;
merge = loc: defs:
fnArgs: (lib.mergeDefinitions (loc ++ [ "[function body]" ]) elemType (map (fn: { inherit (fn) file; value = fn.value fnArgs; }) defs)).mergedValue;
getSubOptions = prefix: elemType.getSubOptions (prefix ++ [ "[function body]" ]);
getSubModules = elemType.getSubModules;
substSubModules = m: functionTo (elemType.substSubModules m);
functor = (lib.defaultFunctor "functionTo") // { type = functionTo; wrapped = elemType; };
nestedTypes.elemType = elemType;
};
flake-modules-core-lib = {
evalFlakeModule =
{ self
@ -30,7 +50,7 @@ let
mkPerSystemType =
module:
types.functionTo (types.submoduleWith {
functionTo (types.submoduleWith {
modules = [ module ];
shorthandOnlyDefinesConfig = false;
});