mirror of
https://github.com/nix-community/home-manager
synced 2024-11-24 03:59:46 +01:00
9f9e277b60
These (and the `*MD` functions apart from `literalMD`) are now no-ops in nixpkgs and serve no purpose other than to add additional noise and potentially mislead people into thinking unmarked DocBook documentation will still be accepted. Note that if backporting changes including documentation to 23.05, the `mdDoc` calls will need to be re-added. To reproduce this commit, run: $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \ nix shell nixpkgs#coreutils \ -c find . -name '*.nix' \ -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \ --strip {} + $ ./format
104 lines
3.1 KiB
Nix
104 lines
3.1 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.xresources;
|
|
|
|
formatLine = n: v:
|
|
let
|
|
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")
|
|
else if isList v then
|
|
concatMapStringsSep ", " formatList v
|
|
else
|
|
toString v;
|
|
in "${n}: ${formatValue v}";
|
|
|
|
xrdbMerge = "${pkgs.xorg.xrdb}/bin/xrdb -merge ${cfg.path}";
|
|
|
|
in {
|
|
meta.maintainers = [ maintainers.rycee ];
|
|
|
|
options = {
|
|
xresources.properties = mkOption {
|
|
type = with types;
|
|
let
|
|
prim = either bool (either int str);
|
|
entry = either prim (listOf prim);
|
|
in nullOr (attrsOf entry);
|
|
default = null;
|
|
example = literalExpression ''
|
|
{
|
|
"Emacs*toolBar" = 0;
|
|
"XTerm*faceName" = "dejavu sans mono";
|
|
"XTerm*charClass" = [ "37:48" "45-47:48" "58:48" "64:48" "126:48" ];
|
|
}
|
|
'';
|
|
description = ''
|
|
X server resources that should be set.
|
|
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.
|
|
If this and all other xresources options are
|
|
`null`, then this feature is disabled and no
|
|
{file}`~/.Xresources` link is produced.
|
|
'';
|
|
};
|
|
|
|
xresources.extraConfig = mkOption {
|
|
type = types.lines;
|
|
default = "";
|
|
example = literalExpression ''
|
|
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
|
|
`null`, then this feature is disabled and no
|
|
{file}`~/.Xresources` link is produced.
|
|
'';
|
|
};
|
|
|
|
xresources.path = mkOption {
|
|
type = types.str;
|
|
default = "${config.home.homeDirectory}/.Xresources";
|
|
defaultText = "$HOME/.Xresources";
|
|
description =
|
|
"Path where Home Manager should link the {file}`.Xresources` file.";
|
|
};
|
|
};
|
|
|
|
config = mkIf ((cfg.properties != null && cfg.properties != { })
|
|
|| cfg.extraConfig != "") {
|
|
home.file.${cfg.path} = {
|
|
text = concatStringsSep "\n" ([ ]
|
|
++ optional (cfg.extraConfig != "") cfg.extraConfig
|
|
++ optionals (cfg.properties != null)
|
|
(mapAttrsToList formatLine cfg.properties)) + "\n";
|
|
onChange = ''
|
|
if [[ -v DISPLAY ]]; then
|
|
${xrdbMerge}
|
|
fi
|
|
'';
|
|
};
|
|
|
|
xsession.initExtra = xrdbMerge;
|
|
};
|
|
}
|