summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/Xresources.nix44
-rw-r--r--modules/x11/xresources.nix44
2 files changed, 44 insertions, 44 deletions
diff --git a/modules/Xresources.nix b/modules/Xresources.nix
deleted file mode 100644
index afba48e3..00000000
--- a/modules/Xresources.nix
+++ /dev/null
@@ -1,44 +0,0 @@
-{ config, lib, pkgs, ... }: let
- cfg = {
- enable = config.services.xserver.enable && config.tv.Xresources != {};
- user = config.krebs.build.user;
- };
- local.types.Xresources = lib.types.attrsOf lib.types.str;
-
- mapAttrNames = f: lib.mapAttrs' (name: lib.nameValuePair (f name));
- mapAttrValues = f: lib.mapAttrs (_: f);
-in {
- options.tv.Xresources = lib.mkOption {
- default = {};
- type = lib.types.attrsOf lib.types.str;
- };
- config = {
- nixpkgs.overlays = lib.singleton (self: super: {
- tv = super.tv or {} // {
- Xresources =
- self.writeText "Xresources"
- (lib.concatStrings
- (lib.mapAttrsToList
- (name: value: /* xdefaults */ ''
- ${name}: ${value}
- '')
- config.tv.Xresources));
- };
- });
- systemd.services.${if cfg.enable then "Xresources" else null} = {
- wantedBy = [ "graphical.target" ];
- after = [ "xmonad.service" ];
- environment = {
- DISPLAY = ":${toString config.services.xserver.display}";
- };
- serviceConfig = {
- ExecStart = "${pkgs.xrdb}/bin/xrdb ${pkgs.tv.Xresources}";
- RemainAfterExit = true;
- SyslogIdentifier = "Xresources";
- Type = "oneshot";
- User = cfg.user.name;
- WorkingDirectory = cfg.user.home;
- };
- };
- };
-}
diff --git a/modules/x11/xresources.nix b/modules/x11/xresources.nix
new file mode 100644
index 00000000..981d1cad
--- /dev/null
+++ b/modules/x11/xresources.nix
@@ -0,0 +1,44 @@
+# Loads X resources into each X session, before the session's other
+# services start.
+{ config, lib, pkgs, ... }: let
+ cfg = config.hrm.xresources;
+
+ files =
+ pkgs.linkFarm "xresources"
+ (lib.mapAttrs
+ (display: resources:
+ pkgs.writeText "xresources-${display}"
+ (lib.concatStrings
+ (lib.mapAttrsToList
+ (name: value: "${name}: ${value}\n")
+ resources)))
+ ({ "*" = {}; } // cfg));
+in {
+ options.hrm.xresources = lib.mkOption {
+ default = {};
+ type = lib.types.attrsOf (lib.types.attrsOf lib.types.str);
+ example = {
+ "*"."Xcursor.size" = "64";
+ "8"."XTerm*background" = "#1e171e";
+ };
+ description = ''
+ X resources, by display number. Those under "*" are for every
+ display, and a display's own override them.
+ '';
+ };
+ config = lib.mkIf config.hrm.xsession.enable {
+ hrm.xsession.services = [ "xresources" ];
+ systemd.user.services."xresources@".serviceConfig = {
+ ExecStart = pkgs.writeDash "xresources-load" ''
+ set -efu
+ LC_ALL=C ${pkgs.xrdb}/bin/xrdb -load ${files}/'*'
+ f=${files}/''${DISPLAY#:}
+ if test -e "$f"; then
+ LC_ALL=C ${pkgs.xrdb}/bin/xrdb -override "$f"
+ fi
+ '';
+ RemainAfterExit = true;
+ Type = "oneshot";
+ };
+ };
+}