From 75e943cd1e76fa64b6b2823da598acf5c16ce6f1 Mon Sep 17 00:00:00 2001 From: oddlama Date: Thu, 21 Sep 2023 17:08:44 +0200 Subject: [PATCH] feat: add stylix and switch font to (very similar) JetBrainsMono for italic support --- flake.lock | 76 +++++++++++++++++++++ flake.nix | 24 ++++--- hosts/kroma/default.nix | 7 ++ modules/optional/graphical/default.nix | 35 +++++++++- modules/optional/graphical/fonts.nix | 92 ++++++++++++++------------ users/modules/default.nix | 2 + users/myuser/graphical/kitty.nix | 18 +++-- users/myuser/graphical/theme.nix | 36 ++++++++-- 8 files changed, 229 insertions(+), 61 deletions(-) diff --git a/flake.lock b/flake.lock index 6e8ab67..8505fdd 100644 --- a/flake.lock +++ b/flake.lock @@ -60,6 +60,24 @@ "type": "github" } }, + "base16": { + "inputs": { + "fromYaml": "fromYaml" + }, + "locked": { + "lastModified": 1689633990, + "narHash": "sha256-iwvQg2Vx0IIDWZaKo8Xmzxlv1YPHg+Kp/QSv8dRv0RY=", + "owner": "SenchoPens", + "repo": "base16.nix", + "rev": "dddf2e1c04845d43c89a8e9e37d574519649a404", + "type": "github" + }, + "original": { + "owner": "SenchoPens", + "repo": "base16.nix", + "type": "github" + } + }, "colmena": { "inputs": { "flake-compat": "flake-compat", @@ -296,6 +314,22 @@ "type": "github" } }, + "flake-compat_6": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -390,6 +424,22 @@ "type": "github" } }, + "fromYaml": { + "flake": false, + "locked": { + "lastModified": 1689549921, + "narHash": "sha256-iX0pk/uB019TdBGlaJEWvBCfydT6sRq+eDcGPifVsCM=", + "owner": "SenchoPens", + "repo": "fromYaml", + "rev": "11fbbbfb32e3289d3c631e0134a23854e7865c84", + "type": "github" + }, + "original": { + "owner": "SenchoPens", + "repo": "fromYaml", + "type": "github" + } + }, "gitignore": { "inputs": { "nixpkgs": [ @@ -834,6 +884,7 @@ "nixpkgs-wayland": "nixpkgs-wayland", "nixseparatedebuginfod": "nixseparatedebuginfod", "pre-commit-hooks": "pre-commit-hooks_2", + "stylix": "stylix", "templates": "templates" } }, @@ -880,6 +931,31 @@ "type": "github" } }, + "stylix": { + "inputs": { + "base16": "base16", + "flake-compat": "flake-compat_6", + "home-manager": [ + "home-manager" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1694375893, + "narHash": "sha256-oJGESNjJ/6o6tfuUavBZ7go4Oun7g9YKv7OqaQaY/80=", + "owner": "danth", + "repo": "stylix", + "rev": "c3c9f4784b4f08f6676340126858d936edbce1fa", + "type": "github" + }, + "original": { + "owner": "danth", + "repo": "stylix", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, diff --git a/flake.nix b/flake.nix index f52779c..926a337 100644 --- a/flake.nix +++ b/flake.nix @@ -2,6 +2,17 @@ description = " ❄️ oddlama's nix config and dotfiles"; inputs = { + agenix = { + url = "github:ryantm/agenix"; + inputs.home-manager.follows = "home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + agenix-rekey = { + url = "github:oddlama/agenix-rekey"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + colmena = { url = "github:oddlama/colmena"; inputs.nixpkgs.follows = "nixpkgs"; @@ -23,6 +34,8 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + flake-utils.url = "github:numtide/flake-utils"; + home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; @@ -77,18 +90,13 @@ inputs.flake-utils.follows = "flake-utils"; }; - agenix = { - url = "github:ryantm/agenix"; + stylix = { + url = "github:danth/stylix"; + inputs.nixpkgs.follows = "nixpkgs"; inputs.home-manager.follows = "home-manager"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - agenix-rekey = { - url = "github:oddlama/agenix-rekey"; - inputs.nixpkgs.follows = "nixpkgs"; }; templates.url = "github:NixOS/templates"; - flake-utils.url = "github:numtide/flake-utils"; }; outputs = { diff --git a/hosts/kroma/default.nix b/hosts/kroma/default.nix index 47b3024..53fe9dc 100644 --- a/hosts/kroma/default.nix +++ b/hosts/kroma/default.nix @@ -33,4 +33,11 @@ gpg-connect-agent /bye export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) ''; + + stylix.fonts.sizes = { + #desktop = 20; + #applications = 20; + terminal = 20; + #popups = 20; + }; } diff --git a/modules/optional/graphical/default.nix b/modules/optional/graphical/default.nix index da2eafc..f3e3e4f 100644 --- a/modules/optional/graphical/default.nix +++ b/modules/optional/graphical/default.nix @@ -1,4 +1,9 @@ -{lib, ...}: let +{ + config, + inputs, + lib, + ... +}: let inherit (lib) mkOption @@ -6,10 +11,12 @@ ; in { imports = [ + inputs.stylix.nixosModules.stylix + ./fonts.nix + ./steam.nix ./wayland.nix ./xserver.nix - ./steam.nix ]; options.graphical.gaming.enable = mkOption { @@ -21,5 +28,29 @@ in { config = { # Needed for gtk programs.dconf.enable = true; + stylix = { + # I want to choose what to style myself. + autoEnable = false; + polarity = "dark"; + image = config.lib.stylix.pixel "base00"; + base16Scheme = { + base00 = "282c34"; + base01 = "353b45"; + base02 = "3e4451"; + base03 = "545862"; + base04 = "565c64"; + base05 = "abb2bf"; + base06 = "b6bdca"; + base07 = "c8ccd4"; + base08 = "e06c75"; + base09 = "d19a66"; + base0A = "e5c07b"; + base0B = "98c379"; + base0C = "56b6c2"; + base0D = "61afef"; + base0E = "c678dd"; + base0F = "be5046"; + }; + }; }; } diff --git a/modules/optional/graphical/fonts.nix b/modules/optional/graphical/fonts.nix index fa4e969..b8c2c58 100644 --- a/modules/optional/graphical/fonts.nix +++ b/modules/optional/graphical/fonts.nix @@ -1,52 +1,62 @@ -{ - lib, - pkgs, - ... -}: { +{pkgs, ...}: { fonts = { - fontconfig = { - # Always prefer emojis even if the original font would provide a glyph - localConf = '' - - - - - monospace - - emoji - - - - sans-serif - - emoji - - - - serif - - emoji - - - - ''; - defaultFonts = { - emoji = ["Segoe UI Emoji" "Noto Fonts Emoji"]; - monospace = ["FiraCode Nerd Font"]; - sansSerif = lib.mkBefore ["Segoe UI"]; - serif = ["Source Serif Pro"]; - }; - }; + # Always prefer emojis even if the original font would provide a glyph + fontconfig.localConf = '' + + + + + monospace + + emoji + + + + sans-serif + + emoji + + + + serif + + emoji + + + + ''; packages = with pkgs; [ - (nerdfonts.override {fonts = ["FiraCode" "FiraMono" "SourceCodePro" "JetBrainsMono"];}) - dejavu_fonts + (pkgs.nerdfonts.override {fonts = ["NerdFontsSymbolsOnly"];}) noto-fonts noto-fonts-cjk-sans noto-fonts-cjk-serif noto-fonts-emoji noto-fonts-extra - segoe-ui-ttf ]; }; + + stylix.fonts = { + serif = { + package = pkgs.dejavu_fonts; + name = "IBM Plex Serif"; + }; + + sansSerif = { + package = pkgs.segoe-ui-ttf; + name = "Segoe UI"; + }; + + monospace = { + # No need for patched nerd fonts, kitty can pick up on them automatically, + # and ideally every program should do that: https://sw.kovidgoyal.net/kitty/faq/#kitty-is-not-able-to-use-my-favorite-font + package = pkgs.jetbrains-mono; + name = "JetBrains Mono"; + }; + + emoji = { + package = pkgs.segoe-ui-ttf; + name = "Segoe UI Emoji"; + }; + }; } diff --git a/users/modules/default.nix b/users/modules/default.nix index 867f238..09bc36d 100644 --- a/users/modules/default.nix +++ b/users/modules/default.nix @@ -10,4 +10,6 @@ ./config/shell ./config/utils.nix ]; + + xdg.configFile."nixpkgs/config.nix".text = "{ allowUnfree = true; }"; } diff --git a/users/myuser/graphical/kitty.nix b/users/myuser/graphical/kitty.nix index 3f2bf4f..c2e566c 100644 --- a/users/myuser/graphical/kitty.nix +++ b/users/myuser/graphical/kitty.nix @@ -1,12 +1,19 @@ -{pkgs, ...}: { +{ + config, + lib, + pkgs, + ... +}: { home.sessionVariables = { TERMINFO_DIRS = "${pkgs.kitty.terminfo.outPath}/share/terminfo"; }; + stylix.targets.kitty.enable = true; programs.kitty = { enable = true; settings = { - font_family = "FiraCode Nerd Font"; - font_size = 20; + bold_font = "${config.programs.kitty.font.name} Bold"; + italic_font = "${config.programs.kitty.font.name} Italic"; + bold_italic_font = "${config.programs.kitty.font.name} Bold Italic"; # Do not wait for inherited child processes. close_on_child_death = "yes"; @@ -63,7 +70,10 @@ "ctrl+shift+." = "change_font_size all -2.0"; "ctrl+shift+," = "change_font_size all +2.0"; }; - extraConfig = '' + # XXX: mkForce to prevent stylix from appending theme. + # Fix this by making a correct theme that can be used. + # TODO aaaaaaaaaa + extraConfig = lib.mkForce '' # Use nvim as scrollback pager scrollback_pager nvim -u NONE -c "set nonumber nolist showtabline=0 foldcolumn=0 laststatus=0" -c "autocmd TermOpen * normal G" -c "silent write! /tmp/kitty_scrollback_buffer | te head -c-1 /tmp/kitty_scrollback_buffer; rm /tmp/kitty_scrollback_buffer; cat" ''; diff --git a/users/myuser/graphical/theme.nix b/users/myuser/graphical/theme.nix index 2592f0c..ee99a97 100644 --- a/users/myuser/graphical/theme.nix +++ b/users/myuser/graphical/theme.nix @@ -1,4 +1,8 @@ -{pkgs, ...}: { +{ + lib, + pkgs, + ... +}: { home.pointerCursor = { gtk.enable = true; x11.enable = true; @@ -29,17 +33,14 @@ }; in { enable = true; - font = { - package = pkgs.segoe-ui-ttf; - name = "Segoe UI"; - }; iconTheme = { name = "WhiteSur-dark"; package = pkgs.whitesur-icon-theme; }; - theme = { + # TODO test other themes + theme = lib.mkForce { name = "WhiteSur-Dark-solid"; package = pkgs.whitesur-gtk-theme; }; @@ -55,4 +56,27 @@ enable = true; platformTheme = "gtk"; }; + + stylix = { + polarity = "dark"; + base16Scheme = { + base00 = "282c34"; + base01 = "353b45"; + base02 = "3e4451"; + base03 = "545862"; + base04 = "565c64"; + base05 = "abb2bf"; + base06 = "b6bdca"; + base07 = "c8ccd4"; + base08 = "e06c75"; + base09 = "d19a66"; + base0A = "e5c07b"; + base0B = "98c379"; + base0C = "56b6c2"; + base0D = "61afef"; + base0E = "c678dd"; + base0F = "be5046"; + }; + targets.gtk.enable = true; + }; }