add lib.strings.conditionalString
parent
b80ebe6811
commit
79fd0353cb
@ -0,0 +1,32 @@
|
||||
{ lib, ... }@flakeArg:
|
||||
let
|
||||
inherit (builtins)
|
||||
isAttrs
|
||||
isBool
|
||||
isList
|
||||
isNull
|
||||
isString
|
||||
typeOf
|
||||
;
|
||||
inherit (lib.strings) optionalString;
|
||||
in
|
||||
{
|
||||
|
||||
conditionalString =
|
||||
cond:
|
||||
optionalString (
|
||||
if isNull cond then
|
||||
false
|
||||
else if isBool cond then
|
||||
cond
|
||||
else if isString cond then
|
||||
cond != ""
|
||||
else if isList cond then
|
||||
cond != [ ]
|
||||
else if isAttrs cond then
|
||||
cond.enable or (cond != { })
|
||||
else
|
||||
throw "unexpected type of condition ${typeOf cond}"
|
||||
);
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue