mirror of
https://github.com/nix-community/home-manager
synced 2024-11-22 20:53:14 +00:00
gtk: add module
Quite rough around the edges, though.
This commit is contained in:
parent
5fbbbd1ea4
commit
30e30688b8
2 changed files with 132 additions and 0 deletions
|
@ -8,6 +8,7 @@ let
|
|||
modules = [
|
||||
./home-environment.nix
|
||||
./manual.nix
|
||||
./misc/gtk.nix
|
||||
./misc/pam.nix
|
||||
./programs/bash.nix
|
||||
./programs/beets.nix
|
||||
|
|
131
modules/misc/gtk.nix
Normal file
131
modules/misc/gtk.nix
Normal file
|
@ -0,0 +1,131 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.gtk;
|
||||
cfg2 = config.gtk.gtk2;
|
||||
cfg3 = config.gtk.gtk3;
|
||||
|
||||
toGtk3Ini = (import ../lib/generators.nix).toINI {
|
||||
mkKeyValue = key: value:
|
||||
let
|
||||
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'}";
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
options = {
|
||||
gtk = {
|
||||
enable = mkEnableOption "GTK 2/3 configuration";
|
||||
|
||||
fontName = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
example = "DejaVu Sans 8";
|
||||
description = ''
|
||||
The font to use in GTK+ 2/3 applications.
|
||||
'';
|
||||
};
|
||||
|
||||
themeName = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
example = "Vertex-Dark";
|
||||
description = "The name of the GTK+2/3 theme to use.";
|
||||
};
|
||||
|
||||
iconThemeName = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
example = "Tango";
|
||||
description = "The name of the icon theme to use.";
|
||||
};
|
||||
|
||||
gtk2 = mkOption {
|
||||
description = "Options specific to GTK+ 2";
|
||||
default = {};
|
||||
type = types.submodule {
|
||||
options = {
|
||||
extraConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
example = "gtk-can-change-accels = 1";
|
||||
description = ''
|
||||
Extra configuration lines to add verbatim to
|
||||
<filename>~/.gtkrc-2.0</filename>.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
gtk3 = mkOption {
|
||||
description = "Options specific to GTK+ 3";
|
||||
default = {};
|
||||
type = types.submodule {
|
||||
options = {
|
||||
extraConfig = mkOption {
|
||||
type = types.attrs;
|
||||
default = {};
|
||||
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>.
|
||||
'';
|
||||
};
|
||||
|
||||
extraCss = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = ''
|
||||
Extra configuration lines to add verbatim to
|
||||
<filename>~/.config/gtk-3.0/gtk.css</filename>.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf (cfg.enable != null) (
|
||||
let
|
||||
ini =
|
||||
optionalAttrs (cfg.fontName != null)
|
||||
{ gtk-font-name = cfg.fontName; }
|
||||
//
|
||||
optionalAttrs (cfg.themeName != null)
|
||||
{ gtk-theme-name = cfg.themeName; }
|
||||
//
|
||||
optionalAttrs (cfg.iconThemeName != null)
|
||||
{ gtk-icon-theme-name = cfg.iconThemeName; };
|
||||
in
|
||||
{
|
||||
home.file.".gtkrc-2.0".text =
|
||||
concatStringsSep "\n" (
|
||||
mapAttrsToList formatGtk2Option ini
|
||||
) + "\n" + cfg2.extraConfig;
|
||||
|
||||
home.file.".config/gtk-3.0/settings.ini".text =
|
||||
toGtk3Ini { Settings = ini // cfg3.extraConfig; };
|
||||
|
||||
home.file.".config/gtk-3.0/gtk.css".text = cfg3.extraCss;
|
||||
}
|
||||
);
|
||||
}
|
Loading…
Reference in a new issue