blob: 0a2cf3438b346afdcee4e0a4d692ef8e6adf39f5 (
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
39
40
41
42
43
44
45
46
|
{ 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;
# http://freedesktop.org/software/fontconfig/fontconfig-user.html
generateFontConfigString = name: attrs:
name + lib.optionalString (attrs != {}) (
":" + lib.concatStringsSep ":" (
lib.mapAttrsToList (key: value: "${key}=${toString value}") attrs
)
)
;
themed-st = pkgs.stdenv.mkDerivation {
name = "themed-st";
dontUnpack = true;
buildInputs = [ pkgs.makeWrapper ];
installPhase = ''
mkdir -p $out/bin
makeWrapper ${pkgs.st}/bin/st $out/bin/st \
--add-flags '-f"${generateFontConfigString 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 ];
};
}
|