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:
commit
cb99722a25
1 changed files with 22 additions and 2 deletions
24
lib.nix
24
lib.nix
|
@ -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;
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue