From f0649334a4ecdaf37f555f7b50928a3d60b82fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=A9tan=20Lepage?= <33058747+GaetanLepage@users.noreply.github.com> Date: Fri, 10 Mar 2023 12:06:32 +0100 Subject: [PATCH] lib/helpers: mkIfNonNull', ifNonNull' and ifNonNull (#230) --- lib/helpers.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/helpers.nix b/lib/helpers.nix index 4bb8d606..97596c27 100644 --- a/lib/helpers.nix +++ b/lib/helpers.nix @@ -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;