flocon/shared/lib/generators/gtk.nix
Anthony Rodriguez 6ab835555c
treewide: remove home-manager (switch to hjem)
As my NixOS configuration kept growing, I noticed that I don't need
home-manager as much as I did before. A lot of what I need is just a way
to map nix attrsets to the program's respective configuration format,
which is something that I can now do myself, as my nix knowledge got
more extensive. After all of this, I decided to completely get rid of
home-manager, and switch to a simpler solution called hjem, which just
lets me write files to my home directory that are automatically
symlinked using `systemd-tmpfiles`.

This allows me to simplify my configuration, remove the separation
between NixOS and home-manager modules, and cut my eval times by quite a
lot (which allows for faster `nixos-rebuild switch`!).
2025-01-27 23:57:47 +01:00

31 lines
1 KiB
Nix

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.
inherit (lib) generators isBool boolToString mapAttrsToList concatMapStrings isString escape;
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 {
toGtk3Ini = generators.toINI {
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);
}