Replace nixpkgs nullOr type with custom type

`nullOr`'s merge function requires definitions to all be null or all be
non-null. It was being used where the intent was that null be used as a
value representing unset, and as such the merge should return null if
all definitions are null and ignore nulls otherwise. This adds a type
with that merge semantics.
This commit is contained in:
Archit Gupta
2024-02-07 00:54:03 -08:00
parent 9fe4cb1994
commit 543e3aaa4d
15 changed files with 74 additions and 50 deletions

View File

@ -6,10 +6,11 @@
let
inherit (lib) filterAttrs functionArgs mapAttrs mkDefault mkIf mkMerge
mkOption;
inherit (lib.types) attrs coercedTo functionTo lazyAttrsOf lines listOf nullOr
inherit (lib.types) attrs coercedTo functionTo lazyAttrsOf lines listOf
package str submodule;
inherit (flakelight) supportedSystem;
inherit (flakelight.types) function optCallWith optFunctionTo packageDef;
inherit (flakelight.types) function nullable optCallWith optFunctionTo
packageDef;
devShellModule.options = {
inputsFrom = mkOption {
@ -38,7 +39,7 @@ let
};
overrideShell = mkOption {
type = nullOr packageDef;
type = nullable packageDef;
internal = true;
default = null;
};
@ -53,7 +54,7 @@ in
options = {
devShell = mkOption {
default = null;
type = nullOr (coercedTo function wrapFn
type = nullable (coercedTo function wrapFn
(coercedTo attrs (x: _: x)
(functionTo (submodule devShellModule))));
};