forked from extern/flakelight
Allow using optFunctionTo on types with submodules
This commit is contained in:
parent
3304eb3746
commit
41ec64361f
@ -5,7 +5,7 @@
|
|||||||
{ config, lib, flakelight, genSystems, moduleArgs, ... }:
|
{ config, lib, flakelight, genSystems, moduleArgs, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib) filterAttrs functionArgs mapAttrs mkIf mkMerge mkOption;
|
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;
|
package str submodule;
|
||||||
inherit (flakelight) supportedSystem;
|
inherit (flakelight) supportedSystem;
|
||||||
inherit (flakelight.types) function nullable optCallWith optFunctionTo;
|
inherit (flakelight.types) function nullable optCallWith optFunctionTo;
|
||||||
@ -50,8 +50,7 @@ let
|
|||||||
else { overrideShell = val; };
|
else { overrideShell = val; };
|
||||||
|
|
||||||
devShellType = coercedTo function wrapFn
|
devShellType = coercedTo function wrapFn
|
||||||
(coercedTo attrs (x: _: x)
|
(optFunctionTo (submodule devShellModule));
|
||||||
(functionTo (submodule devShellModule)));
|
|
||||||
|
|
||||||
genDevShell = pkgs: cfg:
|
genDevShell = pkgs: cfg:
|
||||||
if cfg.overrideShell != null then cfg.overrideShell
|
if cfg.overrideShell != null then cfg.overrideShell
|
||||||
|
14
default.nix
14
default.nix
@ -91,8 +91,18 @@ let
|
|||||||
|
|
||||||
optListOf = elemType: coercedTo elemType singleton (listOf elemType);
|
optListOf = elemType: coercedTo elemType singleton (listOf elemType);
|
||||||
|
|
||||||
optFunctionTo = elemType: coercedTo elemType (x: _: x)
|
optFunctionTo =
|
||||||
(functionTo elemType);
|
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;
|
optCallWith = args: elemType: coercedTo function (x: x args) elemType;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user