lib/types/fontType: Add size attribute (#1848)
* lib/types: Add size attribute to fontType * tests: Add test for kitty * modules/types/fontType: Make size nullable * Add release notes Co-authored-by: Sebastian Zivota <sebastian.zivota@mailbox.org>
This commit is contained in:
parent
cc60c22c69
commit
33edf558a0
8 changed files with 83 additions and 5 deletions
|
@ -162,6 +162,16 @@ qt = {
|
||||||
};
|
};
|
||||||
----
|
----
|
||||||
|
|
||||||
|
* The library type `fontType` now has a `size` attribute in addition to `name`. For example:
|
||||||
|
+
|
||||||
|
[source,nix]
|
||||||
|
----
|
||||||
|
font = {
|
||||||
|
name = "DejaVu Sans";
|
||||||
|
size = 8;
|
||||||
|
};
|
||||||
|
----
|
||||||
|
|
||||||
[[sec-release-21.05-state-version-changes]]
|
[[sec-release-21.05-state-version-changes]]
|
||||||
=== State Version Changes
|
=== State Version Changes
|
||||||
|
|
||||||
|
|
|
@ -47,9 +47,18 @@ in rec {
|
||||||
|
|
||||||
name = mkOption {
|
name = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
example = "DejaVu Sans 8";
|
example = "DejaVu Sans";
|
||||||
description = ''
|
description = ''
|
||||||
The family name and size of the font within the package.
|
The family name of the font within the package.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
size = mkOption {
|
||||||
|
type = types.nullOr types.int;
|
||||||
|
default = null;
|
||||||
|
example = "8";
|
||||||
|
description = ''
|
||||||
|
The size of the font.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -128,8 +128,12 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable (let
|
config = mkIf cfg.enable (let
|
||||||
ini = optionalAttrs (cfg.font != null) { gtk-font-name = cfg.font.name; }
|
ini = optionalAttrs (cfg.font != null) {
|
||||||
// optionalAttrs (cfg.theme != null) { gtk-theme-name = cfg.theme.name; }
|
gtk-font-name = let
|
||||||
|
fontSize =
|
||||||
|
optionalString (cfg.font.size != null) " ${toString cfg.font.size}";
|
||||||
|
in "${cfg.font.name}" + fontSize;
|
||||||
|
} // optionalAttrs (cfg.theme != null) { gtk-theme-name = cfg.theme.name; }
|
||||||
// optionalAttrs (cfg.iconTheme != null) {
|
// optionalAttrs (cfg.iconTheme != null) {
|
||||||
gtk-icon-theme-name = cfg.iconTheme.name;
|
gtk-icon-theme-name = cfg.iconTheme.name;
|
||||||
};
|
};
|
||||||
|
|
|
@ -79,7 +79,11 @@ in {
|
||||||
# Generated by Home Manager.
|
# Generated by Home Manager.
|
||||||
# See https://sw.kovidgoyal.net/kitty/conf.html
|
# See https://sw.kovidgoyal.net/kitty/conf.html
|
||||||
|
|
||||||
${optionalString (cfg.font != null) "font_family ${cfg.font.name}"}
|
${optionalString (cfg.font != null) ''
|
||||||
|
font_family ${cfg.font.name}
|
||||||
|
${optionalString (cfg.font.size != null)
|
||||||
|
"font_size ${toString cfg.font.size}"}
|
||||||
|
''}
|
||||||
|
|
||||||
${toKittyConfig cfg.settings}
|
${toKittyConfig cfg.settings}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ import nmt {
|
||||||
./modules/programs/gpg
|
./modules/programs/gpg
|
||||||
./modules/programs/i3status
|
./modules/programs/i3status
|
||||||
./modules/programs/kakoune
|
./modules/programs/kakoune
|
||||||
|
./modules/programs/kitty
|
||||||
./modules/programs/lf
|
./modules/programs/lf
|
||||||
./modules/programs/lieer
|
./modules/programs/lieer
|
||||||
./modules/programs/man
|
./modules/programs/man
|
||||||
|
|
1
tests/modules/programs/kitty/default.nix
Normal file
1
tests/modules/programs/kitty/default.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ kitty-example-settings = ./example-settings.nix; }
|
17
tests/modules/programs/kitty/example-settings-expected.conf
Normal file
17
tests/modules/programs/kitty/example-settings-expected.conf
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# Generated by Home Manager.
|
||||||
|
# See https://sw.kovidgoyal.net/kitty/conf.html
|
||||||
|
|
||||||
|
font_family DejaVu Sans
|
||||||
|
font_size 8
|
||||||
|
|
||||||
|
|
||||||
|
enable_audio_bell no
|
||||||
|
scrollback_lines 10000
|
||||||
|
update_check_interval 0
|
||||||
|
|
||||||
|
|
||||||
|
map ctrl+c copy_or_interrupt
|
||||||
|
map ctrl+f>2 set_font_size 20
|
||||||
|
|
||||||
|
|
||||||
|
|
32
tests/modules/programs/kitty/example-settings.nix
Normal file
32
tests/modules/programs/kitty/example-settings.nix
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
programs.kitty = {
|
||||||
|
enable = true;
|
||||||
|
package = pkgs.writeScriptBin "dummy-kitty" "";
|
||||||
|
settings = {
|
||||||
|
scrollback_lines = 10000;
|
||||||
|
enable_audio_bell = false;
|
||||||
|
update_check_interval = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
font.name = "DejaVu Sans";
|
||||||
|
font.size = 8;
|
||||||
|
|
||||||
|
keybindings = {
|
||||||
|
"ctrl+c" = "copy_or_interrupt";
|
||||||
|
"ctrl+f>2" = "set_font_size 20";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/kitty/kitty.conf
|
||||||
|
assertFileContent \
|
||||||
|
home-files/.config/kitty/kitty.conf \
|
||||||
|
${./example-settings-expected.conf}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue