1
1
forked from extern/flakelight

Allow using optFunctionTo on types with submodules

This commit is contained in:
Archit Gupta 2024-02-21 18:40:32 -08:00
parent 3304eb3746
commit 41ec64361f
2 changed files with 14 additions and 5 deletions

View File

@ -5,7 +5,7 @@
{ config, lib, flakelight, genSystems, moduleArgs, ... }:
let
inherit (lib) filterAttrs functionArgs mapAttrs mkIf mkMerge mkOption;
inherit (lib.types) attrs coercedTo functionTo lazyAttrsOf lines listOf
inherit (lib.types) coercedTo lazyAttrsOf lines listOf
package str submodule;
inherit (flakelight) supportedSystem;
inherit (flakelight.types) function nullable optCallWith optFunctionTo;
@ -50,8 +50,7 @@ let
else { overrideShell = val; };
devShellType = coercedTo function wrapFn
(coercedTo attrs (x: _: x)
(functionTo (submodule devShellModule)));
(optFunctionTo (submodule devShellModule));
genDevShell = pkgs: cfg:
if cfg.overrideShell != null then cfg.overrideShell

View File

@ -91,7 +91,17 @@ let
optListOf = elemType: coercedTo elemType singleton (listOf elemType);
optFunctionTo = elemType: coercedTo elemType (x: _: x)
optFunctionTo =
let
nonFunction = mkOptionType {
name = "nonFunction";
description = "non-function";
descriptionClass = "noun";
check = x: ! isFunction x;
merge = mergeOneOption;
};
in
elemType: coercedTo nonFunction (x: _: x)
(functionTo elemType);
optCallWith = args: elemType: coercedTo function (x: x args) elemType;