{ config, lib, pkgs, ... }: let cfg = config.programs._st; toString = x: if lib.isBool x then (if x then "true" else "false") else builtins.toString x; generateXftFontString = name: attrs: name + lib.optionalString (attrs != {}) ( ":" + lib.concatStringsSep ":" ( lib.mapAttrsToList (key: value: "${key}=${toString value}") attrs ) ) ; themed-st = pkgs.st.overrideAttrs (old: { buildInputs = old.buildInputs or [] ++ [ pkgs.makeWrapper ]; postInstall = old.postInstall or "" + '' wrapProgram $out/bin/st \ --add-flags '-f"${generateXftFontString cfg.font.name cfg.font.attrs}"' ''; }); in { options.programs._st = { enable = lib.mkEnableOption "enables theming st with home manager"; font = { name = lib.mkOption { type = lib.types.str; example = "JetBrainsMonoNL Nerd Font Mono"; default = "monospace"; }; attrs = lib.mkOption { type = lib.types.attrs; default = {}; example = { size = 12; antialias = true; autohint = true; }; }; }; }; config = lib.mkIf cfg.enable { home.packages = [ themed-st ]; }; }