From 0c4f3acb281be6290c55a6e96bc29fab5b5c7a11 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 11 Sep 2023 18:24:28 +0200 Subject: stockholm -> hrm --- modules/Xresources.nix | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 modules/Xresources.nix (limited to 'modules/Xresources.nix') diff --git a/modules/Xresources.nix b/modules/Xresources.nix new file mode 100644 index 0000000..3f9bc11 --- /dev/null +++ b/modules/Xresources.nix @@ -0,0 +1,44 @@ +{ 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.xorg.xrdb}/bin/xrdb ${pkgs.tv.Xresources}"; + RemainAfterExit = true; + SyslogIdentifier = "Xresources"; + Type = "oneshot"; + User = cfg.user.name; + WorkingDirectory = cfg.user.home; + }; + }; + }; +} -- cgit v1.2.3