summaryrefslogtreecommitdiffstats
path: root/tv/3modules/Xresources.nix
blob: ab233dd659e3d656d4a9f5f3e6244b27559cab35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
with import <stockholm/lib>;
{ config, pkgs, ... }: let
  cfg = {
    enable = config.services.xserver.enable && config.tv.Xresources != {};
    user = config.krebs.build.user;
  };
in {
  options.tv.Xresources = mkOption {
    default = {};
    type = types.attrsOf types.str;
  };
  config = {
    nixpkgs.overlays = singleton (self: super: {
      tv = super.tv or {} // {
        Xresources =
          self.writeText "Xresources"
            (concatStrings (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.xorg.xrdb}/bin/xrdb ${pkgs.tv.Xresources}";
        RemainAfterExit = true;
        SyslogIdentifier = "Xresources";
        Type = "oneshot";
        User = cfg.user.name;
        WorkingDirectory = cfg.user.home;
      };
    };
  };
}