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/manual.nix \
! -path ./modules/misc/dconf.nix \
! -path ./modules/misc/gtk.nix \
! -path ./modules/misc/news.nix \
! -path ./modules/misc/nixpkgs.nix \
! -path ./modules/misc/xdg.nix \

View file

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