2025-01-27 23:30:24 +01:00
lib : let
# toGtk3Ini , formatGtk2Option , and finalGtk2Text are all taken from https://github.com/nix-community/home-manager, with some minor modifications to their function.
# All of the gtk generator functions are available under the MIT License.
2025-02-23 00:01:57 +01:00
inherit ( builtins ) isBool ;
inherit ( lib . attrsets ) mapAttrsToList ;
inherit ( lib . generators ) toINI ;
inherit ( lib . strings ) concatMapStrings escape isString ;
inherit ( lib . trivial ) boolToString ;
2025-01-27 23:30:24 +01:00
formatGtk2Option = n : v : let
v' =
if isBool v
then boolToString v
else if isString v
then '' " ${ v } " ''
else toString v ;
in " ${ escape [ " = " ] n } = ${ v' } " ;
in {
2025-02-23 00:01:57 +01:00
toGtk3Ini = toINI {
2025-01-27 23:30:24 +01:00
mkKeyValue = key : value : let
value' =
if isBool value
then boolToString value
else toString value ;
in " ${ escape [ " = " ] key } = ${ value' } " ;
} ;
formatGtk2Option = n : v : let
v' =
if isBool v
then boolToString v
else if isString v
then '' " ${ v } " ''
else toString v ;
in " ${ escape [ " = " ] n } = ${ v' } " ;
finalGtk2Text = { attrs }: concatMapStrings ( l : l + " \n " ) ( mapAttrsToList formatGtk2Option attrs ) ;
}