gtk: apply nixfmt

This commit is contained in:
Robert Helgesson 2020-05-25 00:46:58 +02:00
parent ac6235e53d
commit 31ed6f1604
No known key found for this signature in database
GPG Key ID: 36BDAA14C2797E89
2 changed files with 46 additions and 59 deletions

1
format
View File

@ -27,7 +27,6 @@ find . -name '*.nix' \
! -path ./modules/lib/file-type.nix \ ! -path ./modules/lib/file-type.nix \
! -path ./modules/manual.nix \ ! -path ./modules/manual.nix \
! -path ./modules/misc/dconf.nix \ ! -path ./modules/misc/dconf.nix \
! -path ./modules/misc/gtk.nix \
! -path ./modules/misc/news.nix \ ! -path ./modules/misc/news.nix \
! -path ./modules/misc/nixpkgs.nix \ ! -path ./modules/misc/nixpkgs.nix \
! -path ./modules/misc/xdg.nix \ ! -path ./modules/misc/xdg.nix \

View File

@ -11,21 +11,22 @@ let
toGtk3Ini = generators.toINI { toGtk3Ini = generators.toINI {
mkKeyValue = key: value: mkKeyValue = key: value:
let let
value' = value' = if isBool value then
if isBool value then (if value then "true" else "false") (if value then "true" else "false")
else toString value; else
in toString value;
"${key}=${value'}"; in "${key}=${value'}";
}; };
formatGtk2Option = n: v: formatGtk2Option = n: v:
let let
v' = v' = if isBool v then
if isBool v then (if v then "true" else "false") (if v then "true" else "false")
else if isString v then "\"${v}\"" else if isString v then
else toString v; ''"${v}"''
in else
"${n} = ${v'}"; toString v;
in "${n} = ${v'}";
themeType = types.submodule { themeType = types.submodule {
options = { options = {
@ -48,13 +49,11 @@ let
}; };
}; };
in in {
{
meta.maintainers = [ maintainers.rycee ]; meta.maintainers = [ maintainers.rycee ];
imports = [ imports = [
(mkRemovedOptionModule ["gtk" "gtk3" "waylandSupport"] '' (mkRemovedOptionModule [ "gtk" "gtk3" "waylandSupport" ] ''
This options is not longer needed and can be removed. This options is not longer needed and can be removed.
'') '')
]; ];
@ -105,8 +104,11 @@ in
extraConfig = mkOption { extraConfig = mkOption {
type = with types; attrsOf (either bool (either int str)); type = with types; attrsOf (either bool (either int str));
default = {}; default = { };
example = { gtk-cursor-blink = false; gtk-recent-files-limit = 20; }; example = {
gtk-cursor-blink = false;
gtk-recent-files-limit = 20;
};
description = '' description = ''
Extra configuration options to add to Extra configuration options to add to
<filename>~/.config/gtk-3.0/settings.ini</filename>. <filename>~/.config/gtk-3.0/settings.ini</filename>.
@ -125,52 +127,38 @@ in
}; };
}; };
config = mkIf cfg.enable ( config = mkIf cfg.enable (let
let ini = optionalAttrs (cfg.font != null) { gtk-font-name = cfg.font.name; }
ini = // optionalAttrs (cfg.theme != null) { gtk-theme-name = cfg.theme.name; }
optionalAttrs (cfg.font != null) // optionalAttrs (cfg.iconTheme != null) {
{ gtk-font-name = cfg.font.name; } gtk-icon-theme-name = cfg.iconTheme.name;
// };
optionalAttrs (cfg.theme != null)
{ gtk-theme-name = cfg.theme.name; }
//
optionalAttrs (cfg.iconTheme != null)
{ gtk-icon-theme-name = cfg.iconTheme.name; };
dconfIni = dconfIni = optionalAttrs (cfg.font != null) { font-name = cfg.font.name; }
optionalAttrs (cfg.font != null) // optionalAttrs (cfg.theme != null) { gtk-theme = cfg.theme.name; }
{ font-name = cfg.font.name; } // optionalAttrs (cfg.iconTheme != null) {
// icon-theme = cfg.iconTheme.name;
optionalAttrs (cfg.theme != null) };
{ gtk-theme = cfg.theme.name; }
//
optionalAttrs (cfg.iconTheme != null)
{ icon-theme = cfg.iconTheme.name; };
optionalPackage = opt: optionalPackage = opt:
optional (opt != null && opt.package != null) opt.package; optional (opt != null && opt.package != null) opt.package;
in in {
{ home.packages = optionalPackage cfg.font ++ optionalPackage cfg.theme
home.packages = ++ optionalPackage cfg.iconTheme;
optionalPackage cfg.font
++ optionalPackage cfg.theme
++ optionalPackage cfg.iconTheme;
home.file.".gtkrc-2.0".text = home.file.".gtkrc-2.0".text =
concatStringsSep "\n" ( concatStringsSep "\n" (mapAttrsToList formatGtk2Option ini) + "\n"
mapAttrsToList formatGtk2Option ini + cfg2.extraConfig;
) + "\n" + cfg2.extraConfig;
xdg.configFile."gtk-3.0/settings.ini".text = xdg.configFile."gtk-3.0/settings.ini".text =
toGtk3Ini { Settings = ini // cfg3.extraConfig; }; toGtk3Ini { Settings = ini // cfg3.extraConfig; };
xdg.configFile."gtk-3.0/gtk.css".text = cfg3.extraCss; xdg.configFile."gtk-3.0/gtk.css".text = cfg3.extraCss;
xdg.configFile."gtk-3.0/bookmarks" = mkIf (cfg3.bookmarks != []) { xdg.configFile."gtk-3.0/bookmarks" = mkIf (cfg3.bookmarks != [ ]) {
text = concatStringsSep "\n" cfg3.bookmarks; text = concatStringsSep "\n" cfg3.bookmarks;
}; };
dconf.settings."org/gnome/desktop/interface" = dconfIni; dconf.settings."org/gnome/desktop/interface" = dconfIni;
} });
);
} }