1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-14 15:19:45 +01:00
home-manager/modules/xresources.nix

79 lines
2.4 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.xresources;
formatLine = n: v:
let
2018-07-22 20:57:01 +02:00
formatList = x:
if isList x
then throw "can not convert 2-dimensional lists to Xresources format"
else formatValue x;
formatValue = v:
if isBool v then (if v then "true" else "false")
2018-07-22 20:57:01 +02:00
else if isList v then concatMapStringsSep ", " formatList v
else toString v;
in
2018-07-22 20:57:01 +02:00
"${n}: ${formatValue v}";
in
{
meta.maintainers = [ maintainers.rycee ];
options = {
xresources.properties = mkOption {
type = types.nullOr types.attrs;
default = null;
2017-01-15 20:03:55 +01:00
example = {
"Emacs*toolBar" = 0;
2018-07-22 20:57:01 +02:00
"XTerm*faceName" = "dejavu sans mono";
"XTerm*charClass" = [ "37:48" "45-47:48" "58:48" "64:48" "126:48" ];
2017-01-15 20:03:55 +01:00
};
description = ''
2018-03-25 14:59:05 +02:00
X server resources that should be set.
2018-07-22 20:57:01 +02:00
Booleans are formatted as "true" or "false" respectively.
List elements are recursively formatted as a string and joined by commas.
All other values are directly formatted using builtins.toString.
Note, that 2-dimensional lists are not supported and specifying one will throw an exception.
2018-03-25 14:59:05 +02:00
If this and all other xresources options are
<code>null</code>, then this feature is disabled and no
<filename>~/.Xresources</filename> link is produced.
'';
};
xresources.extraConfig = mkOption {
type = types.lines;
default = "";
example = literalExample ''
builtins.readFile (
pkgs.fetchFromGitHub {
owner = "solarized";
repo = "xresources";
rev = "025ceddbddf55f2eb4ab40b05889148aab9699fc";
sha256 = "0lxv37gmh38y9d3l8nbnsm1mskcv10g3i83j0kac0a2qmypv1k9f";
} + "/Xresources.dark"
)
'';
description = ''
Additional X server resources contents.
If this and all other xresources options are
<code>null</code>, then this feature is disabled and no
2017-01-15 20:03:55 +01:00
<filename>~/.Xresources</filename> link is produced.
'';
};
};
2018-03-25 14:59:05 +02:00
config = mkIf (cfg.properties != null || cfg.extraConfig != "") {
home.file.".Xresources".text =
2018-03-25 14:59:05 +02:00
concatStringsSep "\n" ([]
++ (optional (cfg.extraConfig != "") cfg.extraConfig)
++ (optionals (cfg.properties != null) (mapAttrsToList formatLine cfg.properties))
2017-01-13 01:12:26 +01:00
) + "\n";
};
}