2017-01-12 01:01:15 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.xresources;
|
|
|
|
|
|
|
|
formatLine = n: v:
|
|
|
|
let
|
2018-07-22 20:57:01 +02:00
|
|
|
formatList = x:
|
2020-02-02 00:39:17 +01:00
|
|
|
if isList x then
|
|
|
|
throw "can not convert 2-dimensional lists to Xresources format"
|
|
|
|
else
|
|
|
|
formatValue x;
|
2018-07-22 20:57:01 +02:00
|
|
|
|
|
|
|
formatValue = v:
|
2020-02-02 00:39:17 +01: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 01:01:15 +01:00
|
|
|
|
2021-06-28 08:50:40 +02:00
|
|
|
xrdbMerge = "${pkgs.xorg.xrdb}/bin/xrdb -merge ${cfg.path}";
|
2021-06-10 11:56:41 +02:00
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
in {
|
2017-09-26 23:40:31 +02:00
|
|
|
meta.maintainers = [ maintainers.rycee ];
|
|
|
|
|
2017-01-12 01:01:15 +01:00
|
|
|
options = {
|
|
|
|
xresources.properties = mkOption {
|
2020-02-29 22:32:52 +01:00
|
|
|
type = with types;
|
|
|
|
let
|
|
|
|
prim = either bool (either int str);
|
|
|
|
entry = either prim (listOf prim);
|
|
|
|
in nullOr (attrsOf entry);
|
2017-01-12 01:01:15 +01:00
|
|
|
default = null;
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2020-01-21 22:27:57 +01:00
|
|
|
{
|
|
|
|
"Emacs*toolBar" = 0;
|
|
|
|
"XTerm*faceName" = "dejavu sans mono";
|
|
|
|
"XTerm*charClass" = [ "37:48" "45-47:48" "58:48" "64:48" "126:48" ];
|
|
|
|
}
|
|
|
|
'';
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc ''
|
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.
|
2021-06-10 11:56:41 +02:00
|
|
|
All other values are directly formatted using builtins.toString.
|
2018-07-22 20:57:01 +02:00
|
|
|
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
|
2023-07-01 01:30:13 +02:00
|
|
|
`null`, then this feature is disabled and no
|
|
|
|
{file}`~/.Xresources` link is produced.
|
2018-03-25 14:59:05 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
xresources.extraConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2018-03-25 14:59:05 +02:00
|
|
|
builtins.readFile (
|
|
|
|
pkgs.fetchFromGitHub {
|
|
|
|
owner = "solarized";
|
|
|
|
repo = "xresources";
|
|
|
|
rev = "025ceddbddf55f2eb4ab40b05889148aab9699fc";
|
|
|
|
sha256 = "0lxv37gmh38y9d3l8nbnsm1mskcv10g3i83j0kac0a2qmypv1k9f";
|
|
|
|
} + "/Xresources.dark"
|
|
|
|
)
|
|
|
|
'';
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc ''
|
2018-03-25 14:59:05 +02:00
|
|
|
Additional X server resources contents.
|
|
|
|
If this and all other xresources options are
|
2023-07-01 01:30:13 +02:00
|
|
|
`null`, then this feature is disabled and no
|
|
|
|
{file}`~/.Xresources` link is produced.
|
2017-01-12 01:01:15 +01:00
|
|
|
'';
|
|
|
|
};
|
2021-06-28 08:50:40 +02:00
|
|
|
|
|
|
|
xresources.path = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "${config.home.homeDirectory}/.Xresources";
|
|
|
|
defaultText = "$HOME/.Xresources";
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc
|
|
|
|
"Path where Home Manager should link the {file}`.Xresources` file.";
|
2021-06-28 08:50:40 +02:00
|
|
|
};
|
2017-01-12 01:01:15 +01:00
|
|
|
};
|
|
|
|
|
2020-06-28 00:41:05 +02:00
|
|
|
config = mkIf ((cfg.properties != null && cfg.properties != { })
|
|
|
|
|| cfg.extraConfig != "") {
|
2021-06-28 08:50:40 +02:00
|
|
|
home.file.${cfg.path} = {
|
2020-06-28 00:41:05 +02:00
|
|
|
text = concatStringsSep "\n" ([ ]
|
|
|
|
++ optional (cfg.extraConfig != "") cfg.extraConfig
|
|
|
|
++ optionals (cfg.properties != null)
|
|
|
|
(mapAttrsToList formatLine cfg.properties)) + "\n";
|
|
|
|
onChange = ''
|
2021-08-01 00:54:47 +02:00
|
|
|
if [[ -v DISPLAY ]]; then
|
|
|
|
${xrdbMerge}
|
2020-06-28 00:41:05 +02:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
};
|
2021-06-10 11:56:41 +02:00
|
|
|
|
|
|
|
xsession.initExtra = xrdbMerge;
|
2018-09-24 23:19:54 +02:00
|
|
|
};
|
2017-01-12 01:01:15 +01:00
|
|
|
}
|