You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
server/nix/lib/strings.nix

33 lines
559 B
Nix

{ 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}"
);
}