lib/helpers: mkIfNonNull', ifNonNull' and ifNonNull (#230)

This commit is contained in:
Gaétan Lepage 2023-03-10 12:06:32 +01:00 committed by GitHub
parent a16d862de4
commit f0649334a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -83,7 +83,16 @@ with lib; rec {
description = desc;
};
mkIfNonNull = c: mkIf (!isNull c) c;
mkIfNonNull' = x: y: (mkIf (!isNull x) y);
mkIfNonNull = x: (mkIfNonNull' x x);
ifNonNull' = x: y:
if (isNull x)
then null
else y;
ifNonNull = x: ifNonNull' x x;
mkCompositeOption = desc: options:
mkNullOrOption (types.submodule {inherit options;}) desc;