2017-01-12 00:01:15 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.xresources;
|
|
|
|
|
|
|
|
formatLine = n: v:
|
|
|
|
let
|
2018-07-22 18:57:01 +00:00
|
|
|
formatList = x:
|
2020-02-01 23:39:17 +00:00
|
|
|
if isList x then
|
|
|
|
throw "can not convert 2-dimensional lists to Xresources format"
|
|
|
|
else
|
|
|
|
formatValue x;
|
2018-07-22 18:57:01 +00:00
|
|
|
|
|
|
|
formatValue = v:
|
2020-02-01 23:39:17 +00:00
|
|
|
if isBool v then
|
|
|
|
(if v then "true" else "false")
|
|
|
|
else if isList v then
|
|
|
|
concatMapStringsSep ", " formatList v
|
|
|
|
else
|
|
|
|
toString v;
|
|
|
|
in "${n}: ${formatValue v}";
|
2017-01-12 00:01:15 +00:00
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
in {
|
2017-09-26 21:40:31 +00:00
|
|
|
meta.maintainers = [ maintainers.rycee ];
|
|
|
|
|
2017-01-12 00:01:15 +00:00
|
|
|
options = {
|
|
|
|
xresources.properties = mkOption {
|
2020-02-29 21:32:52 +00:00
|
|
|
type = with types;
|
|
|
|
let
|
|
|
|
prim = either bool (either int str);
|
|
|
|
entry = either prim (listOf prim);
|
|
|
|
in nullOr (attrsOf entry);
|
2017-01-12 00:01:15 +00:00
|
|
|
default = null;
|
2020-01-21 21:27:57 +00:00
|
|
|
example = literalExample ''
|
|
|
|
{
|
|
|
|
"Emacs*toolBar" = 0;
|
|
|
|
"XTerm*faceName" = "dejavu sans mono";
|
|
|
|
"XTerm*charClass" = [ "37:48" "45-47:48" "58:48" "64:48" "126:48" ];
|
|
|
|
}
|
|
|
|
'';
|
2017-01-12 00:01:15 +00:00
|
|
|
description = ''
|
2018-03-25 12:59:05 +00:00
|
|
|
X server resources that should be set.
|
2018-07-22 18:57:01 +00: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 12:59:05 +00: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 19:03:55 +00:00
|
|
|
<filename>~/.Xresources</filename> link is produced.
|
2017-01-12 00:01:15 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-06-27 22:41:05 +00:00
|
|
|
config = mkIf ((cfg.properties != null && cfg.properties != { })
|
|
|
|
|| cfg.extraConfig != "") {
|
|
|
|
home.file.".Xresources" = {
|
|
|
|
text = concatStringsSep "\n" ([ ]
|
|
|
|
++ optional (cfg.extraConfig != "") cfg.extraConfig
|
|
|
|
++ optionals (cfg.properties != null)
|
|
|
|
(mapAttrsToList formatLine cfg.properties)) + "\n";
|
|
|
|
onChange = ''
|
|
|
|
if [[ -v DISPLAY ]] ; then
|
|
|
|
$DRY_RUN_CMD ${pkgs.xorg.xrdb}/bin/xrdb -merge $HOME/.Xresources
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
};
|
2018-09-24 21:19:54 +00:00
|
|
|
};
|
2017-01-12 00:01:15 +00:00
|
|
|
}
|