From 3d3a3f6d1398a35da49b85ac37c56e67e8b52396 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 12 Jan 2017 01:01:15 +0100 Subject: [PATCH] xresources: add module This module adds basic support for configuring X resources. --- modules/default.nix | 1 + modules/xresources.nix | 43 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 modules/xresources.nix diff --git a/modules/default.nix b/modules/default.nix index 340cfefe..57f5c5c2 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -27,6 +27,7 @@ let ./services/udiskie.nix ./services/xscreensaver.nix ./systemd.nix + ./xresources.nix ./xsession.nix ]; diff --git a/modules/xresources.nix b/modules/xresources.nix new file mode 100644 index 00000000..43e8ff1c --- /dev/null +++ b/modules/xresources.nix @@ -0,0 +1,43 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.xresources; + + formatLine = n: v: + let + v' = + if isBool v then (if v then "true" else "false") + else toString v; + in + "${n}: ${v'}"; + +in + +{ + options = { + xresources.properties = mkOption { + type = types.nullOr types.attrs; + default = null; + example = '' + { + "XTerm*faceName" = "dejavu sans mono"; + "Emacs*toolBar" = 0; + } + ''; + description = '' + X server resources that should be set. If null, then this + feature is disabled and no ~/.Xresources link is produced. + ''; + }; + }; + + config = mkIf (cfg.properties != null) { + home.file.".Xresources".text = + concatStringsSep "\n" ( + mapAttrsToList formatLine cfg.properties + ); + }; +}