From c1ad4464c6db838afbb02a431705cea4ac2f7757 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Sun, 1 Jun 2025 22:57:22 +0200 Subject: [PATCH] lib/trivial: add boolToYesNo --- lib/default.nix | 1 + lib/trivial.nix | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/default.nix b/lib/default.nix index d45e6de0c33f..51705c6aa571 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -127,6 +127,7 @@ let bitXor bitNot boolToString + boolToYesNo mergeAttrs flip defaultTo diff --git a/lib/trivial.nix b/lib/trivial.nix index 2364002668a9..abdff8fbb9fa 100644 --- a/lib/trivial.nix +++ b/lib/trivial.nix @@ -240,6 +240,26 @@ in */ boolToString = b: if b then "true" else "false"; + /** + Converts a boolean to a string. + + This function uses the strings "yes" and "no" to represent + boolean values. + + # Inputs + + `b` + + : The boolean to convert + + # Type + + ``` + boolToYesNo :: bool -> string + ``` + */ + boolToYesNo = b: if b then "yes" else "no"; + /** Merge two attribute sets shallowly, right side trumps left