diff --git a/default.nix b/default.nix index 80aeb4331..6466507b7 100644 --- a/default.nix +++ b/default.nix @@ -1,6 +1,9 @@ -(import (let lock = builtins.fromJSON (builtins.readFile ./flake.lock); -in fetchTarball { - url = - "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; - sha256 = lock.nodes.flake-compat.locked.narHash; -}) { src = ./.; }).defaultNix +(import ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } +) { src = ./.; }).defaultNix diff --git a/docs/default.nix b/docs/default.nix index 5b524cc61..5f005cf6c 100644 --- a/docs/default.nix +++ b/docs/default.nix @@ -1,28 +1,38 @@ -{ pkgs, lib, inputs, ... }: +{ + pkgs, + lib, + inputs, + ... +}: let - makeOptionsDoc = configuration: pkgs.nixosOptionsDoc { - inherit (configuration) options; + makeOptionsDoc = + configuration: + pkgs.nixosOptionsDoc { + inherit (configuration) options; - # Filter out any options not beginning with `stylix` - transformOptions = option: option // { - visible = option.visible && - builtins.elemAt option.loc 0 == "stylix"; + # Filter out any options not beginning with `stylix` + transformOptions = + option: + option + // { + visible = option.visible && builtins.elemAt option.loc 0 == "stylix"; + }; }; - }; - nixos = makeOptionsDoc - (lib.nixosSystem { + nixos = makeOptionsDoc ( + lib.nixosSystem { inherit (pkgs) system; modules = [ inputs.home-manager.nixosModules.home-manager inputs.self.nixosModules.stylix ./settings.nix ]; - }); + } + ); - homeManager = makeOptionsDoc - (inputs.home-manager.lib.homeManagerConfiguration { + homeManager = makeOptionsDoc ( + inputs.home-manager.lib.homeManagerConfiguration { inherit pkgs; modules = [ inputs.self.homeManagerModules.stylix @@ -35,9 +45,11 @@ let }; } ]; - }); + } + ); -in pkgs.stdenvNoCC.mkDerivation { +in +pkgs.stdenvNoCC.mkDerivation { name = "stylix-book"; src = ./.; diff --git a/flake.nix b/flake.nix index 979e2342e..ae001790b 100644 --- a/flake.nix +++ b/flake.nix @@ -74,16 +74,29 @@ }; outputs = - { nixpkgs, base16, self, ... }@inputs: + { + nixpkgs, + base16, + self, + ... + }@inputs: inputs.flake-utils.lib.eachDefaultSystem ( - system: let + system: + let inherit (nixpkgs) lib; pkgs = nixpkgs.legacyPackages.${system}; - in { + in + { checks.git-hooks = inputs.git-hooks.lib.${system}.run { hooks = { deadnix.enable = true; hlint.enable = true; + + nixfmt-rfc-style = { + enable = true; + settings.width = 80; + }; + statix.enable = true; stylish-haskell.enable = true; typos.enable = true; @@ -109,7 +122,8 @@ }; }; - packages = let + packages = + let universalPackages = { docs = import ./docs { inherit pkgs inputs lib; }; palette-generator = pkgs.callPackage ./palette-generator { }; @@ -117,41 +131,47 @@ # Testbeds are virtual machines based on NixOS, therefore they are # only available for Linux systems. - testbedPackages = lib.optionalAttrs - (lib.hasSuffix "-linux" system) - (import ./stylix/testbed.nix { inherit pkgs inputs lib; }); + testbedPackages = lib.optionalAttrs (lib.hasSuffix "-linux" system) ( + import ./stylix/testbed.nix { inherit pkgs inputs lib; } + ); in - universalPackages // testbedPackages; + universalPackages // testbedPackages; } ) // { - nixosModules.stylix = { pkgs, ... }@args: { - imports = [ - (import ./stylix/nixos inputs { - inherit (self.packages.${pkgs.system}) palette-generator; - base16 = base16.lib args; - homeManagerModule = self.homeManagerModules.stylix; - }) - ]; - }; + nixosModules.stylix = + { pkgs, ... }@args: + { + imports = [ + (import ./stylix/nixos inputs { + inherit (self.packages.${pkgs.system}) palette-generator; + base16 = base16.lib args; + homeManagerModule = self.homeManagerModules.stylix; + }) + ]; + }; - homeManagerModules.stylix = { pkgs, ... }@args: { - imports = [ - (import ./stylix/hm inputs { - inherit (self.packages.${pkgs.system}) palette-generator; - base16 = base16.lib args; - }) - ]; - }; + homeManagerModules.stylix = + { pkgs, ... }@args: + { + imports = [ + (import ./stylix/hm inputs { + inherit (self.packages.${pkgs.system}) palette-generator; + base16 = base16.lib args; + }) + ]; + }; - darwinModules.stylix = { pkgs, ... }@args: { - imports = [ - (import ./stylix/darwin inputs { - inherit (self.packages.${pkgs.system}) palette-generator; - base16 = base16.lib args; - homeManagerModule = self.homeManagerModules.stylix; - }) - ]; - }; + darwinModules.stylix = + { pkgs, ... }@args: + { + imports = [ + (import ./stylix/darwin inputs { + inherit (self.packages.${pkgs.system}) palette-generator; + base16 = base16.lib args; + homeManagerModule = self.homeManagerModules.stylix; + }) + ]; + }; }; } diff --git a/modules/alacritty/hm.nix b/modules/alacritty/hm.nix index e9974f31c..b40e2486a 100644 --- a/modules/alacritty/hm.nix +++ b/modules/alacritty/hm.nix @@ -9,46 +9,55 @@ in { options.stylix.targets.alacritty.enable = config.lib.stylix.mkEnableTarget "Alacritty" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.alacritty.enable) { - programs.alacritty.settings = { - font = with config.stylix.fonts; { - normal = { - family = monospace.name; - style = "Regular"; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.alacritty.enable) + { + programs.alacritty.settings = { + font = with config.stylix.fonts; { + normal = { + family = monospace.name; + style = "Regular"; + }; + size = sizes.terminal; + }; + window.opacity = with config.stylix.opacity; terminal; + colors = with colors; { + primary = { + foreground = base05; + background = base00; + bright_foreground = base07; + }; + selection = { + text = base05; + background = base02; + }; + cursor = { + text = base00; + cursor = base05; + }; + normal = { + black = base00; + white = base05; + inherit + red + green + yellow + blue + magenta + cyan + ; + }; + bright = { + black = base03; + white = base07; + red = bright-red; + green = bright-green; + inherit yellow; + blue = bright-blue; + magenta = bright-magenta; + cyan = bright-cyan; + }; + }; }; - size = sizes.terminal; }; - window.opacity = with config.stylix.opacity; terminal; - colors = with colors; { - primary = { - foreground = base05; - background = base00; - bright_foreground = base07; - }; - selection = { - text = base05; - background = base02; - }; - cursor = { - text = base00; - cursor = base05; - }; - normal = { - black = base00; - white = base05; - inherit red green yellow blue magenta cyan; - }; - bright = { - black = base03; - white = base07; - red = bright-red; - green = bright-green; - inherit yellow; - blue = bright-blue; - magenta = bright-magenta; - cyan = bright-cyan; - }; - }; - }; - }; } diff --git a/modules/avizo/hm.nix b/modules/avizo/hm.nix index e67a2d3f9..5feeff994 100644 --- a/modules/avizo/hm.nix +++ b/modules/avizo/hm.nix @@ -1,4 +1,9 @@ -{ config, lib, options, ... }: +{ + config, + lib, + options, + ... +}: with config.lib.stylix.colors; with config.stylix.fonts; @@ -6,21 +11,22 @@ let aviOpacity = toString config.stylix.opacity.popups; in { - options.stylix.targets.avizo.enable = - config.lib.stylix.mkEnableTarget "Avizo" true; + options.stylix.targets.avizo.enable = config.lib.stylix.mkEnableTarget "Avizo" true; # Referenced https://github.com/stacyharper/base16-mako - config = lib.optionalAttrs (options.services ? avizo) (lib.mkIf (config.stylix.enable && config.stylix.targets.avizo.enable) { - services.avizo = { + config = lib.optionalAttrs (options.services ? avizo) ( + lib.mkIf (config.stylix.enable && config.stylix.targets.avizo.enable) { + services.avizo = { settings = { - default = { - background = "rgba(${base01-rgb-r}, ${base01-rgb-g}, ${base01-rgb-b}, ${aviOpacity})"; - border-color = "rgba(${base0D-rgb-r}, ${base0D-rgb-g}, ${base0D-rgb-b}, ${aviOpacity})"; - bar-fg-color = "rgba(${base05-rgb-r}, ${base05-rgb-g}, ${base05-rgb-b}, ${aviOpacity})"; - bar-bg-color = "rgba(${base01-rgb-r}, ${base01-rgb-g}, ${base01-rgb-b}, ${aviOpacity})"; - image-opacity = aviOpacity; - }; + default = { + background = "rgba(${base01-rgb-r}, ${base01-rgb-g}, ${base01-rgb-b}, ${aviOpacity})"; + border-color = "rgba(${base0D-rgb-r}, ${base0D-rgb-g}, ${base0D-rgb-b}, ${aviOpacity})"; + bar-fg-color = "rgba(${base05-rgb-r}, ${base05-rgb-g}, ${base05-rgb-b}, ${aviOpacity})"; + bar-bg-color = "rgba(${base01-rgb-r}, ${base01-rgb-g}, ${base01-rgb-b}, ${aviOpacity})"; + image-opacity = aviOpacity; + }; }; - }; - }); + }; + } + ); } diff --git a/modules/bat/hm.nix b/modules/bat/hm.nix index e38751e6a..cf7dab93c 100644 --- a/modules/bat/hm.nix +++ b/modules/bat/hm.nix @@ -1,8 +1,7 @@ { config, lib, ... }: { - options.stylix.targets.bat.enable = - config.lib.stylix.mkEnableTarget "Bat" true; + options.stylix.targets.bat.enable = config.lib.stylix.mkEnableTarget "Bat" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.bat.enable) { programs.bat = { diff --git a/modules/bemenu/hm.nix b/modules/bemenu/hm.nix index e629e4dbe..1b2e97ab2 100644 --- a/modules/bemenu/hm.nix +++ b/modules/bemenu/hm.nix @@ -3,8 +3,11 @@ with config.lib.stylix.colors.withHashtag; with config.stylix.fonts; let - bemenuOpacity = lib.toHexString (((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100); -in { + bemenuOpacity = lib.toHexString ( + ((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100 + ); +in +{ options.stylix.targets.bemenu = { enable = config.lib.stylix.mkEnableTarget "bemenu" true; @@ -25,27 +28,31 @@ in { }; }; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.bemenu.enable) { - programs.bemenu.settings = with config.stylix.targets.bemenu; { - tb = "${base01}${bemenuOpacity}"; # Title bg - nb = "${base01}${bemenuOpacity}"; # Normal bg - fb = "${base01}${bemenuOpacity}"; # Filter bg - hb = "${base03}${bemenuOpacity}"; # Highlighted bg - sb = "${base03}${bemenuOpacity}"; # Selected bg - scb = "${base01}"; # Scrollbar bg + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.bemenu.enable) + { + programs.bemenu.settings = with config.stylix.targets.bemenu; { + tb = "${base01}${bemenuOpacity}"; # Title bg + nb = "${base01}${bemenuOpacity}"; # Normal bg + fb = "${base01}${bemenuOpacity}"; # Filter bg + hb = "${base03}${bemenuOpacity}"; # Highlighted bg + sb = "${base03}${bemenuOpacity}"; # Selected bg + scb = "${base01}"; # Scrollbar bg - hf = "${base0A}"; # Highlighted fg - sf = "${base0B}"; # Selected fg - tf = "${base05}"; # Title fg - ff = "${base05}"; # Filter fg - nf = "${base05}"; # Normal fg - scf = "${base03}"; # Scrollbar fg + hf = "${base0A}"; # Highlighted fg + sf = "${base0B}"; # Selected fg + tf = "${base05}"; # Title fg + ff = "${base05}"; # Filter fg + nf = "${base05}"; # Normal fg + scf = "${base03}"; # Scrollbar fg - ab = "${if alternate then base00 else base01}"; # Alternate bg - af = "${if alternate then base04 else base05}"; # Alternate fg + ab = "${if alternate then base00 else base01}"; # Alternate bg + af = "${if alternate then base04 else base05}"; # Alternate fg - # Font name - fn = "${sansSerif.name} ${lib.optionalString (fontSize != null) (builtins.toString fontSize)}"; - }; - }; + # Font name + fn = "${sansSerif.name} ${ + lib.optionalString (fontSize != null) (builtins.toString fontSize) + }"; + }; + }; } diff --git a/modules/bspwm/hm.nix b/modules/bspwm/hm.nix index 108f41f57..1faa3a0d9 100644 --- a/modules/bspwm/hm.nix +++ b/modules/bspwm/hm.nix @@ -2,9 +2,9 @@ let colors = config.lib.stylix.colors.withHashtag; -in { - options.stylix.targets.bspwm.enable = - config.lib.stylix.mkEnableTarget "bspwm" true; +in +{ + options.stylix.targets.bspwm.enable = config.lib.stylix.mkEnableTarget "bspwm" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.bspwm.enable) { xsession.windowManager.bspwm.settings = { diff --git a/modules/btop/hm.nix b/modules/btop/hm.nix index 4c7a709a9..aab476919 100644 --- a/modules/btop/hm.nix +++ b/modules/btop/hm.nix @@ -1,61 +1,69 @@ { config, lib, ... }: let - colors = config.lib.stylix.colors.withHashtag; -in { - options.stylix.targets.btop.enable = config.lib.stylix.mkEnableTarget "btop" true; + colors = config.lib.stylix.colors.withHashtag; +in +{ + options.stylix.targets.btop.enable = config.lib.stylix.mkEnableTarget "btop" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.btop.enable && config.programs.btop.enable) { + config = + lib.mkIf + ( + config.stylix.enable + && config.stylix.targets.btop.enable + && config.programs.btop.enable + ) + { programs.btop.settings = { - color_theme = "stylix"; - theme_background = lib.mkIf (config.stylix.opacity.terminal != 1.0) false; + color_theme = "stylix"; + theme_background = lib.mkIf (config.stylix.opacity.terminal != 1.0) false; }; xdg.configFile."btop/themes/stylix.theme".text = with colors; '' - #Generated by Stylix - theme[main_bg]="${base00}" - theme[main_fg]="${base05}" - theme[title]="${base05}" - theme[hi_fg]="${base0D}" - theme[selected_bg]="${base03}" - theme[selected_fg]="${base0D}" - theme[inactive_fg]="${base04}" - theme[graph_text]="${base06}" - theme[meter_bg]="${base03}" - theme[proc_misc]="${base06}" - theme[cpu_box]="${base0E}" - theme[mem_box]="${base0B}" - theme[net_box]="${base0C}" - theme[proc_box]="${base0D}" - theme[div_line]="${base01}" - theme[temp_start]="${base0B}" - theme[temp_mid]="${base0A}" - theme[temp_end]="${base08}" - theme[cpu_start]="${base0B}" - theme[cpu_mid]="${base0A}" - theme[cpu_end]="${base08}" - theme[free_start]="${base0B}" - theme[free_mid]="${base0A}" - theme[free_end]="${base08}" - theme[cached_start]="${base0B}" - theme[cached_mid]="${base0A}" - theme[cached_end]="${base08}" - theme[available_start]="${base0B}" - theme[available_mid]="${base0A}" - theme[available_end]="${base08}" - theme[used_start]="${base0B}" - theme[used_mid]="${base0A}" - theme[used_end]="${base08}" - theme[download_start]="${base0B}" - theme[download_mid]="${base0A}" - theme[download_end]="${base08}" - theme[upload_start]="${base0B}" - theme[upload_mid]="${base0A}" - theme[upload_end]="${base08}" - theme[process_start]="${base0B}" - theme[process_mid]="${base0A}" - theme[process_end]="${base08}" + #Generated by Stylix + theme[main_bg]="${base00}" + theme[main_fg]="${base05}" + theme[title]="${base05}" + theme[hi_fg]="${base0D}" + theme[selected_bg]="${base03}" + theme[selected_fg]="${base0D}" + theme[inactive_fg]="${base04}" + theme[graph_text]="${base06}" + theme[meter_bg]="${base03}" + theme[proc_misc]="${base06}" + theme[cpu_box]="${base0E}" + theme[mem_box]="${base0B}" + theme[net_box]="${base0C}" + theme[proc_box]="${base0D}" + theme[div_line]="${base01}" + theme[temp_start]="${base0B}" + theme[temp_mid]="${base0A}" + theme[temp_end]="${base08}" + theme[cpu_start]="${base0B}" + theme[cpu_mid]="${base0A}" + theme[cpu_end]="${base08}" + theme[free_start]="${base0B}" + theme[free_mid]="${base0A}" + theme[free_end]="${base08}" + theme[cached_start]="${base0B}" + theme[cached_mid]="${base0A}" + theme[cached_end]="${base08}" + theme[available_start]="${base0B}" + theme[available_mid]="${base0A}" + theme[available_end]="${base08}" + theme[used_start]="${base0B}" + theme[used_mid]="${base0A}" + theme[used_end]="${base08}" + theme[download_start]="${base0B}" + theme[download_mid]="${base0A}" + theme[download_end]="${base08}" + theme[upload_start]="${base0B}" + theme[upload_mid]="${base0A}" + theme[upload_end]="${base08}" + theme[process_start]="${base0B}" + theme[process_mid]="${base0A}" + theme[process_end]="${base08}" ''; }; } diff --git a/modules/chromium/nixos.nix b/modules/chromium/nixos.nix index 8f193f272..110496c02 100644 --- a/modules/chromium/nixos.nix +++ b/modules/chromium/nixos.nix @@ -1,14 +1,15 @@ { config, lib, ... }: { - options.stylix.targets.chromium.enable = - config.lib.stylix.mkEnableTarget "Chromium, Google Chrome and Brave" true; + options.stylix.targets.chromium.enable = config.lib.stylix.mkEnableTarget "Chromium, Google Chrome and Brave" true; - config.programs.chromium = lib.mkIf (config.stylix.enable && config.stylix.targets.chromium.enable) { - # This enables policies without installing the browser. Policies take up a - # negligible amount of space, so it's reasonable to have this always on. - enable = true; + config.programs.chromium = + lib.mkIf (config.stylix.enable && config.stylix.targets.chromium.enable) + { + # This enables policies without installing the browser. Policies take up a + # negligible amount of space, so it's reasonable to have this always on. + enable = true; - extraOpts.BrowserThemeColor = config.lib.stylix.colors.withHashtag.base00; - }; + extraOpts.BrowserThemeColor = config.lib.stylix.colors.withHashtag.base00; + }; } diff --git a/modules/console/nixos.nix b/modules/console/nixos.nix index b5b2b2b10..5bdec89c9 100644 --- a/modules/console/nixos.nix +++ b/modules/console/nixos.nix @@ -3,25 +3,26 @@ with config.lib.stylix.colors; { - options.stylix.targets.console.enable = - config.lib.stylix.mkEnableTarget "the Linux kernel console" true; + options.stylix.targets.console.enable = config.lib.stylix.mkEnableTarget "the Linux kernel console" true; - config.console.colors = lib.mkIf (config.stylix.enable && config.stylix.targets.console.enable) [ - base00-hex - red - green - yellow - blue - magenta - cyan - base05-hex - base03-hex - red - green - yellow - blue - magenta - cyan - base06-hex - ]; + config.console.colors = + lib.mkIf (config.stylix.enable && config.stylix.targets.console.enable) + [ + base00-hex + red + green + yellow + blue + magenta + cyan + base05-hex + base03-hex + red + green + yellow + blue + magenta + cyan + base06-hex + ]; } diff --git a/modules/dunst/hm.nix b/modules/dunst/hm.nix index 7c4ad0ba0..cec86beee 100644 --- a/modules/dunst/hm.nix +++ b/modules/dunst/hm.nix @@ -3,10 +3,12 @@ with config.lib.stylix.colors.withHashtag; with config.stylix.fonts; let - dunstOpacity = lib.toHexString (((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100); -in { - options.stylix.targets.dunst.enable = - config.lib.stylix.mkEnableTarget "Dunst" true; + dunstOpacity = lib.toHexString ( + ((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100 + ); +in +{ + options.stylix.targets.dunst.enable = config.lib.stylix.mkEnableTarget "Dunst" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.dunst.enable) { services.dunst.settings = { diff --git a/modules/emacs/hm.nix b/modules/emacs/hm.nix index 665e0a326..ae52868f0 100644 --- a/modules/emacs/hm.nix +++ b/modules/emacs/hm.nix @@ -1,63 +1,68 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: with config.lib.stylix.colors.withHashtag; with config.stylix.fonts; let - emacsOpacity = builtins.toString (builtins.ceil (config.stylix.opacity.applications * 100)); + emacsOpacity = builtins.toString ( + builtins.ceil (config.stylix.opacity.applications * 100) + ); in { - options.stylix.targets.emacs.enable = - config.lib.stylix.mkEnableTarget "Emacs" true; + options.stylix.targets.emacs.enable = config.lib.stylix.mkEnableTarget "Emacs" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.emacs.enable) { programs.emacs = { - extraPackages = epkgs: - [ - (epkgs.trivialBuild { - pname = "base16-stylix-theme"; - version = "0.1.0"; - src = pkgs.writeText "base16-stylix-theme.el" '' - (require 'base16-theme) + extraPackages = epkgs: [ + (epkgs.trivialBuild { + pname = "base16-stylix-theme"; + version = "0.1.0"; + src = pkgs.writeText "base16-stylix-theme.el" '' + (require 'base16-theme) - (defvar base16-stylix-theme-colors - '(:base00 "${base00}" - :base01 "${base01}" - :base02 "${base02}" - :base03 "${base03}" - :base04 "${base04}" - :base05 "${base05}" - :base06 "${base06}" - :base07 "${base07}" - :base08 "${base08}" - :base09 "${base09}" - :base0A "${base0A}" - :base0B "${base0B}" - :base0C "${base0C}" - :base0D "${base0D}" - :base0E "${base0E}" - :base0F "${base0F}") - "All colors for Base16 stylix are defined here.") + (defvar base16-stylix-theme-colors + '(:base00 "${base00}" + :base01 "${base01}" + :base02 "${base02}" + :base03 "${base03}" + :base04 "${base04}" + :base05 "${base05}" + :base06 "${base06}" + :base07 "${base07}" + :base08 "${base08}" + :base09 "${base09}" + :base0A "${base0A}" + :base0B "${base0B}" + :base0C "${base0C}" + :base0D "${base0D}" + :base0E "${base0E}" + :base0F "${base0F}") + "All colors for Base16 stylix are defined here.") - ;; Define the theme - (deftheme base16-stylix) + ;; Define the theme + (deftheme base16-stylix) - ;; Add all the faces to the theme - (base16-theme-define 'base16-stylix base16-stylix-theme-colors) + ;; Add all the faces to the theme + (base16-theme-define 'base16-stylix base16-stylix-theme-colors) - ;; Mark the theme as provided - (provide-theme 'base16-stylix) + ;; Mark the theme as provided + (provide-theme 'base16-stylix) - ;; Add path to theme to theme-path - (add-to-list 'custom-theme-load-path - (file-name-directory - (file-truename load-file-name))) + ;; Add path to theme to theme-path + (add-to-list 'custom-theme-load-path + (file-name-directory + (file-truename load-file-name))) - (provide 'base16-stylix-theme) - ''; - packageRequires = [ epkgs.base16-theme ]; - }) - ]; + (provide 'base16-stylix-theme) + ''; + packageRequires = [ epkgs.base16-theme ]; + }) + ]; extraConfig = '' ;; ---- Generated by stylix ---- diff --git a/modules/feh/hm.nix b/modules/feh/hm.nix index 3642ec693..bf34848b7 100644 --- a/modules/feh/hm.nix +++ b/modules/feh/hm.nix @@ -1,23 +1,23 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: { - options.stylix.targets.feh.enable = - config.lib.stylix.mkEnableTarget - "the desktop background using Feh" - true; + options.stylix.targets.feh.enable = config.lib.stylix.mkEnableTarget "the desktop background using Feh" true; - config.xsession.initExtra = - lib.mkIf ( - config.stylix.enable - && config.stylix.targets.feh.enable - && ( - with config.xsession.windowManager; - bspwm.enable - || herbstluftwm.enable - || i3.enable - || spectrwm.enable - || xmonad.enable - ) + config.xsession.initExtra = lib.mkIf ( + config.stylix.enable + && config.stylix.targets.feh.enable + && ( + with config.xsession.windowManager; + bspwm.enable + || herbstluftwm.enable + || i3.enable + || spectrwm.enable + || xmonad.enable ) - "${pkgs.feh}/bin/feh --no-fehbg --bg-scale ${config.stylix.image}"; + ) "${pkgs.feh}/bin/feh --no-fehbg --bg-scale ${config.stylix.image}"; } diff --git a/modules/feh/nixos.nix b/modules/feh/nixos.nix index 2826af181..733cf267c 100644 --- a/modules/feh/nixos.nix +++ b/modules/feh/nixos.nix @@ -1,20 +1,16 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: { - options.stylix.targets.feh.enable = - config.lib.stylix.mkEnableTarget - "the desktop background using Feh" - true; + options.stylix.targets.feh.enable = config.lib.stylix.mkEnableTarget "the desktop background using Feh" true; - config.services.xserver.displayManager.sessionCommands = - lib.mkIf ( - config.stylix.enable - && config.stylix.targets.feh.enable - && ( - with config.services.xserver.windowManager; - xmonad.enable - || i3.enable - ) - ) - "${pkgs.feh}/bin/feh --no-fehbg --bg-scale ${config.stylix.image}"; + config.services.xserver.displayManager.sessionCommands = lib.mkIf ( + config.stylix.enable + && config.stylix.targets.feh.enable + && (with config.services.xserver.windowManager; xmonad.enable || i3.enable) + ) "${pkgs.feh}/bin/feh --no-fehbg --bg-scale ${config.stylix.image}"; } diff --git a/modules/firefox/hm.nix b/modules/firefox/hm.nix index 6e8f2ee79..392e6cbd9 100644 --- a/modules/firefox/hm.nix +++ b/modules/firefox/hm.nix @@ -8,12 +8,12 @@ let "font.name.serif.x-western" = config.stylix.fonts.serif.name; }; }; - makeProfileSettingsPair = profileName: - lib.nameValuePair profileName profileSettings; -in { + makeProfileSettingsPair = + profileName: lib.nameValuePair profileName profileSettings; +in +{ options.stylix.targets.firefox = { - enable = - config.lib.stylix.mkEnableTarget "Firefox" true; + enable = config.lib.stylix.mkEnableTarget "Firefox" true; profileNames = lib.mkOption { description = "The Firefox profile names to apply styling on."; @@ -22,8 +22,11 @@ in { }; }; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.firefox.enable) { - programs.firefox.profiles = lib.listToAttrs - (map makeProfileSettingsPair config.stylix.targets.firefox.profileNames); - }; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.firefox.enable) + { + programs.firefox.profiles = lib.listToAttrs ( + map makeProfileSettingsPair config.stylix.targets.firefox.profileNames + ); + }; } diff --git a/modules/fish/hm.nix b/modules/fish/hm.nix index 4493aecc7..9aacf380c 100644 --- a/modules/fish/hm.nix +++ b/modules/fish/hm.nix @@ -1,8 +1,7 @@ { config, lib, ... }: { - options.stylix.targets.fish.enable = - config.lib.stylix.mkEnableTarget "Fish" true; + options.stylix.targets.fish.enable = config.lib.stylix.mkEnableTarget "Fish" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.fish.enable) { programs.fish.interactiveShellInit = import ./prompt.nix config; diff --git a/modules/fish/nixos.nix b/modules/fish/nixos.nix index 2fa26dd90..0f0e17673 100644 --- a/modules/fish/nixos.nix +++ b/modules/fish/nixos.nix @@ -1,8 +1,7 @@ { config, lib, ... }: { - options.stylix.targets.fish.enable = - config.lib.stylix.mkEnableTarget "Fish" true; + options.stylix.targets.fish.enable = config.lib.stylix.mkEnableTarget "Fish" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.fish.enable) { programs.fish.promptInit = import ./prompt.nix config; diff --git a/modules/fish/prompt.nix b/modules/fish/prompt.nix index f3792808d..c07ea295f 100644 --- a/modules/fish/prompt.nix +++ b/modules/fish/prompt.nix @@ -4,7 +4,8 @@ let theme = config.lib.stylix.colors { templateRepo = config.lib.stylix.templates.base16-fish; }; -in '' +in +'' source ${theme} # See https://github.com/tomyun/base16-fish/issues/7 for why this condition exists diff --git a/modules/foot/hm.nix b/modules/foot/hm.nix index d9e191dee..9e592fbfa 100644 --- a/modules/foot/hm.nix +++ b/modules/foot/hm.nix @@ -7,17 +7,17 @@ let templateRepo = config.lib.stylix.templates.base16-foot; }; -in { - options.stylix.targets.foot.enable = - config.lib.stylix.mkEnableTarget "Foot" true; +in +{ + options.stylix.targets.foot.enable = config.lib.stylix.mkEnableTarget "Foot" true; config.programs.foot.settings = lib.mkIf cfg.enable { main = { - include = theme; - font = - with config.stylix.fonts; - "${monospace.name}:size=${toString sizes.terminal}"; - dpi-aware = "no"; + include = theme; + font = + with config.stylix.fonts; + "${monospace.name}:size=${toString sizes.terminal}"; + dpi-aware = "no"; }; colors.alpha = with config.stylix.opacity; terminal; }; diff --git a/modules/fuzzel/hm.nix b/modules/fuzzel/hm.nix index 62ce2d6b7..1554a84c5 100644 --- a/modules/fuzzel/hm.nix +++ b/modules/fuzzel/hm.nix @@ -5,25 +5,26 @@ with config.lib.stylix.colors; let opacity = lib.toHexString (builtins.ceil (config.stylix.opacity.popups * 255)); -in { - options.stylix.targets.fuzzel.enable = - config.lib.stylix.mkEnableTarget "Fuzzel" true; +in +{ + options.stylix.targets.fuzzel.enable = config.lib.stylix.mkEnableTarget "Fuzzel" true; config.programs.fuzzel.settings = - lib.mkIf (config.stylix.enable && config.stylix.targets.fuzzel.enable) { - colors = { - background = "${base00-hex}${opacity}"; - text = "${base05-hex}ff"; - match = "${base0A-hex}ff"; - selection = "${base03-hex}ff"; - selection-text = "${base05-hex}ff"; - selection-match = "${base0A-hex}ff"; - border = "${base0D-hex}ff"; - }; + lib.mkIf (config.stylix.enable && config.stylix.targets.fuzzel.enable) + { + colors = { + background = "${base00-hex}${opacity}"; + text = "${base05-hex}ff"; + match = "${base0A-hex}ff"; + selection = "${base03-hex}ff"; + selection-text = "${base05-hex}ff"; + selection-match = "${base0A-hex}ff"; + border = "${base0D-hex}ff"; + }; - main = { - font = "${config.stylix.fonts.sansSerif.name}:size=${toString config.stylix.fonts.sizes.popups}"; - dpi-aware = "no"; + main = { + font = "${config.stylix.fonts.sansSerif.name}:size=${toString config.stylix.fonts.sizes.popups}"; + dpi-aware = "no"; + }; }; - }; } diff --git a/modules/gedit/hm.nix b/modules/gedit/hm.nix index 4f974d5b4..f123064b2 100644 --- a/modules/gedit/hm.nix +++ b/modules/gedit/hm.nix @@ -6,9 +6,9 @@ let extension = "xml"; }; -in { - options.stylix.targets.gedit.enable = - config.lib.stylix.mkEnableTarget "GEdit" true; +in +{ + options.stylix.targets.gedit.enable = config.lib.stylix.mkEnableTarget "GEdit" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.gedit.enable) { xdg.dataFile = { diff --git a/modules/gitui/hm.nix b/modules/gitui/hm.nix index 9f742fcee..5b3d283a1 100644 --- a/modules/gitui/hm.nix +++ b/modules/gitui/hm.nix @@ -2,7 +2,8 @@ let inherit (config.lib.stylix) colors; - mkRgb = color: + mkRgb = + color: let r = colors."${color}-rgb-r"; g = colors."${color}-rgb-g"; @@ -11,8 +12,7 @@ let "Rgb(${r}, ${g}, ${b})"; in { - options.stylix.targets.gitui.enable = - config.lib.stylix.mkEnableTarget "GitUI" true; + options.stylix.targets.gitui.enable = config.lib.stylix.mkEnableTarget "GitUI" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.gitui.enable) { programs.gitui.theme = '' diff --git a/modules/gnome/hm.nix b/modules/gnome/hm.nix index ea98eccc6..ce234fa00 100644 --- a/modules/gnome/hm.nix +++ b/modules/gnome/hm.nix @@ -1,13 +1,18 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let inherit (config.stylix.fonts) sansSerif serif monospace; fontSize = toString config.stylix.fonts.sizes.applications; documentFontSize = toString (config.stylix.fonts.sizes.applications - 1); -in { - options.stylix.targets.gnome.enable = - config.lib.stylix.mkEnableTarget "GNOME" true; +in +{ + options.stylix.targets.gnome.enable = config.lib.stylix.mkEnableTarget "GNOME" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.gnome.enable) { dconf.settings = { @@ -23,9 +28,7 @@ in { # settings tile is removed. The value is still used by Epiphany to # request dark mode for websites which support it. color-scheme = - if config.stylix.polarity == "dark" - then "prefer-dark" - else "default"; + if config.stylix.polarity == "dark" then "prefer-dark" else "default"; # Some GTK apps will use these font settings if they exist. # i.e emacs-pgtk. @@ -39,10 +42,12 @@ in { xdg.dataFile."themes/Stylix/gnome-shell/gnome-shell.css" = { source = - let theme = pkgs.callPackage ./theme.nix { - inherit (config.lib.stylix) colors templates; - }; - in "${theme}/share/gnome-shell/gnome-shell.css"; + let + theme = pkgs.callPackage ./theme.nix { + inherit (config.lib.stylix) colors templates; + }; + in + "${theme}/share/gnome-shell/gnome-shell.css"; onChange = '' if [[ -x "$(command -v gnome-extensions)" ]]; then gnome-extensions disable user-theme@gnome-shell-extensions.gcampax.github.com diff --git a/modules/gnome/nixos.nix b/modules/gnome/nixos.nix index 993a10dba..a19f15353 100644 --- a/modules/gnome/nixos.nix +++ b/modules/gnome/nixos.nix @@ -1,50 +1,64 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: let theme = pkgs.callPackage ./theme.nix { inherit (config.lib.stylix) colors templates; }; -in { - options.stylix.targets.gnome.enable = - config.lib.stylix.mkEnableTarget "GNOME and GDM" true; +in +{ + options.stylix.targets.gnome.enable = config.lib.stylix.mkEnableTarget "GNOME and GDM" true; - config = lib.mkIf ( - config.stylix.enable - && config.stylix.targets.gnome.enable - && config.services.xserver.desktopManager.gnome.enable - ) { - # As Stylix is controlling the wallpaper, there is no need for this - # pack of default wallpapers to be installed. - # If you want to use one, you can set stylix.image to something like - # "${pkgs.gnome-backgrounds}/path/to/your/preferred/background" - # which will then download the pack regardless of its exclusion below. - environment.gnome.excludePackages = [ pkgs.gnome-backgrounds ]; + config = + lib.mkIf + ( + config.stylix.enable + && config.stylix.targets.gnome.enable + && config.services.xserver.desktopManager.gnome.enable + ) + { + # As Stylix is controlling the wallpaper, there is no need for this + # pack of default wallpapers to be installed. + # If you want to use one, you can set stylix.image to something like + # "${pkgs.gnome-backgrounds}/path/to/your/preferred/background" + # which will then download the pack regardless of its exclusion below. + environment.gnome.excludePackages = [ pkgs.gnome-backgrounds ]; - nixpkgs.overlays = [(_: super: { - gnome-shell = super.gnome-shell.overrideAttrs (oldAttrs: { - # Themes are usually applied via an extension, but extensions are - # not available on the login screen. The only way to change the - # theme there is by replacing the default. - postFixup = (oldAttrs.postFixup or "") + '' - cp ${theme}/share/gnome-shell/gnome-shell-theme.gresource \ - $out/share/gnome-shell/gnome-shell-theme.gresource - ''; - patches = (oldAttrs.patches or []) ++ [ - ./shell_remove_dark_mode.patch + nixpkgs.overlays = [ + (_: super: { + gnome-shell = super.gnome-shell.overrideAttrs (oldAttrs: { + # Themes are usually applied via an extension, but extensions are + # not available on the login screen. The only way to change the + # theme there is by replacing the default. + postFixup = + (oldAttrs.postFixup or "") + + '' + cp ${theme}/share/gnome-shell/gnome-shell-theme.gresource \ + $out/share/gnome-shell/gnome-shell-theme.gresource + ''; + patches = (oldAttrs.patches or [ ]) ++ [ + ./shell_remove_dark_mode.patch + ]; + }); + }) ]; - }); - })]; - # Cursor settings are usually applied via Home Manager, - # but the login screen uses a separate database. - environment.systemPackages = [ config.stylix.cursor.package ]; - programs.dconf.profiles.gdm.databases = [{ - lockAll = true; - settings."org/gnome/desktop/interface" = { - cursor-theme = config.stylix.cursor.name; - cursor-size = lib.gvariant.mkInt32 config.stylix.cursor.size; + # Cursor settings are usually applied via Home Manager, + # but the login screen uses a separate database. + environment.systemPackages = [ config.stylix.cursor.package ]; + programs.dconf.profiles.gdm.databases = [ + { + lockAll = true; + settings."org/gnome/desktop/interface" = { + cursor-theme = config.stylix.cursor.name; + cursor-size = lib.gvariant.mkInt32 config.stylix.cursor.size; + }; + } + ]; }; - }]; - }; } diff --git a/modules/gnome/theme.nix b/modules/gnome/theme.nix index 6a6ea7c96..c4bd8c903 100644 --- a/modules/gnome/theme.nix +++ b/modules/gnome/theme.nix @@ -1,4 +1,10 @@ -{ stdenv, sass, glib, colors, templates }: +{ + stdenv, + sass, + glib, + colors, + templates, +}: let colorsScss = colors { @@ -6,7 +12,8 @@ let extension = "scss"; }; -in stdenv.mkDerivation { +in +stdenv.mkDerivation { name = "${colors.slug}-gnome-shell-theme"; src = templates.gnome-shell; patches = [ ./shell_colors.patch ]; @@ -15,7 +22,10 @@ in stdenv.mkDerivation { cp ${colorsScss} data/theme/gnome-shell-sass/_colors.scss ''; - nativeBuildInputs = [ sass glib.dev ]; + nativeBuildInputs = [ + sass + glib.dev + ]; buildPhase = '' sass data/theme/gnome-shell-light.scss \ >data/theme/gnome-shell-light.css diff --git a/modules/grub/nixos.nix b/modules/grub/nixos.nix index f90df7cff..ed639f7af 100644 --- a/modules/grub/nixos.nix +++ b/modules/grub/nixos.nix @@ -1,4 +1,9 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: with config.lib.stylix; with config.stylix.fonts; @@ -7,23 +12,26 @@ with config.lib.stylix.colors.withHashtag; let # Grub requires fonts to be converted to "PFF2 format" # This function takes a font { name, package } and produces a .pf2 file - mkGrubFont = font: - pkgs.runCommand "${font.package.name}.pf2" { - FONTCONFIG_FILE = - pkgs.makeFontsConf { fontDirectories = [ font.package ]; }; - } '' - # Use fontconfig to select the correct .ttf or .otf file based on name - font=$( - ${lib.getExe' pkgs.fontconfig "fc-match"} \ - ${lib.escapeShellArg font.name} \ - --format=%{file} - ) - - # Convert to .pf2 - ${pkgs.grub2}/bin/grub-mkfont $font --output $out --size ${toString sizes.applications} - ''; - -in { + mkGrubFont = + font: + pkgs.runCommand "${font.package.name}.pf2" + { + FONTCONFIG_FILE = pkgs.makeFontsConf { fontDirectories = [ font.package ]; }; + } + '' + # Use fontconfig to select the correct .ttf or .otf file based on name + font=$( + ${lib.getExe' pkgs.fontconfig "fc-match"} \ + ${lib.escapeShellArg font.name} \ + --format=%{file} + ) + + # Convert to .pf2 + ${pkgs.grub2}/bin/grub-mkfont $font --output $out --size ${toString sizes.applications} + ''; + +in +{ options.stylix.targets.grub = { enable = config.lib.stylix.mkEnableTarget "GRUB" true; @@ -34,79 +42,87 @@ in { }; }; - config.boot.loader.grub = lib.mkIf (config.stylix.enable && config.stylix.targets.grub.enable) { - backgroundColor = base00; - # Need to override the NixOS splash, this will match the background - splashImage = pixel "base00"; - - # This font will be used for the GRUB terminal - font = toString (mkGrubFont monospace); - - # TODO: Include OS icons - theme = pkgs.runCommand "stylix-grub" { - themeTxt = '' - desktop-image: "background.png" - desktop-image-scale-method: "crop" - desktop-color: "${base00}" - - title-text: "" - - terminal-left: "10%" - terminal-top: "20%" - terminal-width: "80%" - terminal-height: "60%" - - + progress_bar { - left = 25% - top = 80%+20 # 20 pixels below boot menu - width = 50% - height = 30 - - id = "__timeout__" - show_text = true - font = "${sansSerif.name}" - text = "@TIMEOUT_NOTIFICATION_MIDDLE@" - - border_color = "${base00}" - bg_color = "${base00}" - fg_color = "${base0B}" - text_color = "${base05}" - } - - + boot_menu { - left = 25% - top = 20% - width = 50% - height = 60% - menu_pixmap_style = "background_*.png" - - item_height = 40 - item_icon_space = 8 - item_spacing = 0 - item_padding = 0 - item_font = "${sansSerif.name}" - item_color = "${base05}" - - selected_item_color = "${base01}" - selected_item_pixmap_style = "selection_*.png" - } - ''; - passAsFile = [ "themeTxt" ]; - } '' - mkdir $out - cp $themeTxtPath $out/theme.txt - - ${if config.stylix.targets.grub.useImage - # Make sure the background image is .png by asking to convert it - then - "${pkgs.imagemagick}/bin/convert ${config.stylix.image} png32:$out/background.png" - else - "cp ${pixel "base00"} $out/background.png"} - - cp ${pixel "base01"} $out/background_c.png - cp ${pixel "base0B"} $out/selection_c.png - - cp ${mkGrubFont sansSerif} $out/sans_serif.pf2 - ''; - }; + config.boot.loader.grub = + lib.mkIf (config.stylix.enable && config.stylix.targets.grub.enable) + { + backgroundColor = base00; + # Need to override the NixOS splash, this will match the background + splashImage = pixel "base00"; + + # This font will be used for the GRUB terminal + font = toString (mkGrubFont monospace); + + # TODO: Include OS icons + theme = + pkgs.runCommand "stylix-grub" + { + themeTxt = '' + desktop-image: "background.png" + desktop-image-scale-method: "crop" + desktop-color: "${base00}" + + title-text: "" + + terminal-left: "10%" + terminal-top: "20%" + terminal-width: "80%" + terminal-height: "60%" + + + progress_bar { + left = 25% + top = 80%+20 # 20 pixels below boot menu + width = 50% + height = 30 + + id = "__timeout__" + show_text = true + font = "${sansSerif.name}" + text = "@TIMEOUT_NOTIFICATION_MIDDLE@" + + border_color = "${base00}" + bg_color = "${base00}" + fg_color = "${base0B}" + text_color = "${base05}" + } + + + boot_menu { + left = 25% + top = 20% + width = 50% + height = 60% + menu_pixmap_style = "background_*.png" + + item_height = 40 + item_icon_space = 8 + item_spacing = 0 + item_padding = 0 + item_font = "${sansSerif.name}" + item_color = "${base05}" + + selected_item_color = "${base01}" + selected_item_pixmap_style = "selection_*.png" + } + ''; + passAsFile = [ "themeTxt" ]; + } + '' + mkdir $out + cp $themeTxtPath $out/theme.txt + + ${ + if + config.stylix.targets.grub.useImage + # Make sure the background image is .png by asking to convert it + then + "${pkgs.imagemagick}/bin/convert ${config.stylix.image} png32:$out/background.png" + else + "cp ${pixel "base00"} $out/background.png" + } + + cp ${pixel "base01"} $out/background_c.png + cp ${pixel "base0B"} $out/selection_c.png + + cp ${mkGrubFont sansSerif} $out/sans_serif.pf2 + ''; + }; } diff --git a/modules/gtk/hm.nix b/modules/gtk/hm.nix index 6faa8082e..7bda53357 100644 --- a/modules/gtk/hm.nix +++ b/modules/gtk/hm.nix @@ -1,4 +1,9 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let cfg = config.stylix.targets.gtk; @@ -8,15 +13,15 @@ let extension = "css"; }; - finalCss = pkgs.runCommandLocal "gtk.css" {} '' + finalCss = pkgs.runCommandLocal "gtk.css" { } '' cat ${baseCss} >>$out echo ${lib.escapeShellArg cfg.extraCss} >>$out ''; -in { +in +{ options.stylix.targets.gtk = { - enable = config.lib.stylix.mkEnableTarget - "all GTK3, GTK4 and Libadwaita apps" true; + enable = config.lib.stylix.mkEnableTarget "all GTK3, GTK4 and Libadwaita apps" true; extraCss = lib.mkOption { description = '' diff --git a/modules/gtk/nixos.nix b/modules/gtk/nixos.nix index 3368857ae..b6192798c 100644 --- a/modules/gtk/nixos.nix +++ b/modules/gtk/nixos.nix @@ -1,8 +1,7 @@ { config, lib, ... }: { - options.stylix.targets.gtk.enable = - config.lib.stylix.mkEnableTarget "all GTK3, GTK4 and Libadwaita apps" true; + options.stylix.targets.gtk.enable = config.lib.stylix.mkEnableTarget "all GTK3, GTK4 and Libadwaita apps" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.gtk.enable) { # Required for Home Manager's GTK settings to work diff --git a/modules/helix/hm.nix b/modules/helix/hm.nix index b1e7ee69e..96482a96f 100644 --- a/modules/helix/hm.nix +++ b/modules/helix/hm.nix @@ -1,4 +1,9 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let theme = config.lib.stylix.colors { @@ -8,20 +13,25 @@ let # Removing the background exposes transparency from the terminal. The # background might be helpful if the terminal isn't themed, so we only # do this if transparency is actually enabled. - transparentTheme = pkgs.runCommandLocal "helix-transparent.toml" {} '' + transparentTheme = pkgs.runCommandLocal "helix-transparent.toml" { } '' sed 's/,\? bg = "base00"//g' <${theme} >$out ''; -in { - options.stylix.targets.helix.enable = - config.lib.stylix.mkEnableTarget "Helix" true; +in +{ + options.stylix.targets.helix.enable = config.lib.stylix.mkEnableTarget "Helix" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.helix.enable && config.programs.helix.enable) { - programs.helix.settings.theme = "stylix"; + config = + lib.mkIf + ( + config.stylix.enable + && config.stylix.targets.helix.enable + && config.programs.helix.enable + ) + { + programs.helix.settings.theme = "stylix"; - xdg.configFile."helix/themes/stylix.toml".source = - if config.stylix.opacity.terminal == 1.0 - then theme - else transparentTheme; - }; + xdg.configFile."helix/themes/stylix.toml".source = + if config.stylix.opacity.terminal == 1.0 then theme else transparentTheme; + }; } diff --git a/modules/hyprland/hm.nix b/modules/hyprland/hm.nix index 8d6ddd23d..fb25c403e 100644 --- a/modules/hyprland/hm.nix +++ b/modules/hyprland/hm.nix @@ -26,16 +26,20 @@ let misc.background_color = rgb base00; }; -in { - options.stylix.targets.hyprland.enable = - config.lib.stylix.mkEnableTarget "Hyprland" true; +in +{ + options.stylix.targets.hyprland.enable = config.lib.stylix.mkEnableTarget "Hyprland" true; config = lib.mkIf - (config.stylix.enable && config.stylix.targets.hyprland.enable && config.wayland.windowManager.hyprland.enable) - { - services.hyprpaper.enable = true; - stylix.targets.hyprpaper.enable = true; - wayland.windowManager.hyprland.settings = settings; - }; + ( + config.stylix.enable + && config.stylix.targets.hyprland.enable + && config.wayland.windowManager.hyprland.enable + ) + { + services.hyprpaper.enable = true; + stylix.targets.hyprpaper.enable = true; + wayland.windowManager.hyprland.settings = settings; + }; } diff --git a/modules/hyprpaper/hm.nix b/modules/hyprpaper/hm.nix index dbb7b08a1..6852a54b6 100644 --- a/modules/hyprpaper/hm.nix +++ b/modules/hyprpaper/hm.nix @@ -1,14 +1,13 @@ -{ config, lib, ... }: { - options.stylix.targets.hyprpaper.enable = - config.lib.stylix.mkEnableTarget "Hyprpaper" true; +{ config, lib, ... }: +{ + options.stylix.targets.hyprpaper.enable = config.lib.stylix.mkEnableTarget "Hyprpaper" true; config = - lib.mkIf - (config.stylix.enable && config.stylix.targets.hyprpaper.enable) - { - services.hyprpaper.settings = { - preload = [ "${config.stylix.image}" ]; - wallpaper = [ ",${config.stylix.image}" ]; + lib.mkIf (config.stylix.enable && config.stylix.targets.hyprpaper.enable) + { + services.hyprpaper.settings = { + preload = [ "${config.stylix.image}" ]; + wallpaper = [ ",${config.stylix.image}" ]; + }; }; - }; } diff --git a/modules/i3/hm.nix b/modules/i3/hm.nix index 6004e1cce..794c8cd08 100644 --- a/modules/i3/hm.nix +++ b/modules/i3/hm.nix @@ -8,55 +8,59 @@ let focused = base0D; unfocused = base03; - fonts = let - inherit (config.stylix) fonts; - in { - names = [ fonts.sansSerif.name ]; - size = fonts.sizes.desktop * 1.0; - }; + fonts = + let + inherit (config.stylix) fonts; + in + { + names = [ fonts.sansSerif.name ]; + size = fonts.sizes.desktop * 1.0; + }; -in { - options.stylix.targets.i3.enable = - config.lib.stylix.mkEnableTarget "i3" true; +in +{ + options.stylix.targets.i3.enable = config.lib.stylix.mkEnableTarget "i3" true; config = lib.mkMerge [ (lib.mkIf config.stylix.targets.i3.enable { xsession.windowManager.i3.config = { inherit fonts; - colors = let - background = base00; - indicator = base0B; - in { - inherit background; - urgent = { - inherit background indicator text; - border = urgent; - childBorder = urgent; - }; - focused = { - inherit background indicator text; - border = focused; - childBorder = focused; - }; - focusedInactive = { - inherit background indicator text; - border = unfocused; - childBorder = unfocused; - }; - unfocused = { - inherit background indicator text; - border = unfocused; - childBorder = unfocused; - }; - placeholder = { - inherit background indicator text; - border = unfocused; - childBorder = unfocused; + colors = + let + background = base00; + indicator = base0B; + in + { + inherit background; + urgent = { + inherit background indicator text; + border = urgent; + childBorder = urgent; + }; + focused = { + inherit background indicator text; + border = focused; + childBorder = focused; + }; + focusedInactive = { + inherit background indicator text; + border = unfocused; + childBorder = unfocused; + }; + unfocused = { + inherit background indicator text; + border = unfocused; + childBorder = unfocused; + }; + placeholder = { + inherit background indicator text; + border = unfocused; + childBorder = unfocused; + }; }; - }; -# output."*".bg = "${config.stylix.image} fill"; + # output."*".bg = "${config.stylix.image} fill"; }; }) @@ -65,33 +69,35 @@ in { lib.stylix.i3.bar = { inherit fonts; - colors = let - background = base00; - border = background; - in { - inherit background; - statusline = text; - separator = base03; - focusedWorkspace = { - inherit text background; - border = focused; - }; - activeWorkspace = { - inherit border background; - text = focused; - }; - inactiveWorkspace = { - inherit text border background; - }; - urgentWorkspace = { - inherit text background; - border = urgent; - }; - bindingMode = { - inherit text border; - background = urgent; + colors = + let + background = base00; + border = background; + in + { + inherit background; + statusline = text; + separator = base03; + focusedWorkspace = { + inherit text background; + border = focused; + }; + activeWorkspace = { + inherit border background; + text = focused; + }; + inactiveWorkspace = { + inherit text border background; + }; + urgentWorkspace = { + inherit text background; + border = urgent; + }; + bindingMode = { + inherit text border; + background = urgent; + }; }; - }; }; } ]; diff --git a/modules/k9s/hm.nix b/modules/k9s/hm.nix index 56f8b2729..0706ce331 100644 --- a/modules/k9s/hm.nix +++ b/modules/k9s/hm.nix @@ -3,8 +3,7 @@ with config.lib.stylix.colors.withHashtag; { - options.stylix.targets.k9s.enable = - config.lib.stylix.mkEnableTarget "k9s" true; + options.stylix.targets.k9s.enable = config.lib.stylix.mkEnableTarget "k9s" true; config = lib.mkIf config.stylix.targets.k9s.enable { programs.k9s.skins.skin = { @@ -77,8 +76,14 @@ with config.lib.stylix.colors.withHashtag; views = { charts = { bgColor = "default"; - defaultDialColors = [ base0C-hex base0D-hex ]; - defaultChartColors = [ base0C-hex base0D-hex ]; + defaultDialColors = [ + base0C-hex + base0D-hex + ]; + defaultChartColors = [ + base0C-hex + base0D-hex + ]; }; table = { diff --git a/modules/kde/hm.nix b/modules/kde/hm.nix index d7d7f64c4..e2a3084a0 100644 --- a/modules/kde/hm.nix +++ b/modules/kde/hm.nix @@ -1,15 +1,23 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: with config.stylix.fonts; with config.lib.stylix.colors; let - formatValue = value: - if builtins.isBool value - then if value then "true" else "false" - else builtins.toString value; - - formatSection = path: data: + formatValue = + value: + if builtins.isBool value then + if value then "true" else "false" + else + builtins.toString value; + + formatSection = + path: data: let header = lib.concatStrings (map (p: "[${p}]") path); formatChild = name: formatLines (path ++ [ name ]); @@ -18,23 +26,24 @@ let directChildren = partitioned.right; indirectChildren = partitioned.wrong; in - lib.optional (directChildren != []) header ++ - directChildren ++ - lib.flatten indirectChildren; - - formatLines = path: data: - if builtins.isAttrs data - then - if data?_immutable - then - if builtins.isAttrs data.value - then formatSection (path ++ [ "$i" ]) data.value - else "${lib.last path}[$i]=${formatValue data.value}" - else formatSection path data - else "${lib.last path}=${formatValue data}"; - - formatConfig = data: - lib.concatStringsSep "\n" (formatLines [] data); + lib.optional (directChildren != [ ]) header + ++ directChildren + ++ lib.flatten indirectChildren; + + formatLines = + path: data: + if builtins.isAttrs data then + if data ? _immutable then + if builtins.isAttrs data.value then + formatSection (path ++ [ "$i" ]) data.value + else + "${lib.last path}[$i]=${formatValue data.value}" + else + formatSection path data + else + "${lib.last path}=${formatValue data}"; + + formatConfig = data: lib.concatStringsSep "\n" (formatLines [ ] data); # Marking a setting as immutable should prevent it being overwritten # through the system settings menu. @@ -46,9 +55,9 @@ let # PascalCase is the standard naming for color scheme files. Schemes named # in kebab-case will load when selected manually, but don't work with a # look and feel package. - colorschemeSlug = lib.concatStrings - (builtins.filter builtins.isString - (builtins.split "[^a-zA-Z]" scheme)); + colorschemeSlug = lib.concatStrings ( + builtins.filter builtins.isString (builtins.split "[^a-zA-Z]" scheme) + ); colorEffect = { ColorEffect = 0; @@ -140,41 +149,44 @@ let # Contains a wallpaper package, a colorscheme file, and a look and feel # package which depends on both. - themePackage = pkgs.runCommandLocal "stylix-kde-theme" { - colorscheme = formatConfig colorscheme; - wallpaperMetadata = builtins.toJSON wallpaperMetadata; - wallpaperImage = config.stylix.image; - lookAndFeelMetadata = builtins.toJSON lookAndFeelMetadata; - lookAndFeelDefaults = formatConfig lookAndFeelDefaults; - } '' - write_text() { - mkdir --parents "$(dirname "$2")" - printf '%s\n' "$1" >"$2" - } - - PATH="${pkgs.imagemagick}/bin:$PATH" - - wallpaper="$out/share/wallpapers/stylix" - look_and_feel="$out/share/plasma/look-and-feel/stylix" - - mkdir --parents "$wallpaper/contents/images" - - magick \ - "$wallpaperImage" \ - -thumbnail 400x250 \ - "$wallpaper/contents/screenshot.png" - - dimensions="$(identify -ping -format '%wx%h' "$wallpaperImage")" - magick "$wallpaperImage" "$wallpaper/contents/images/$dimensions.png" - - write_text \ - "$colorscheme" \ - "$out/share/color-schemes/${colorschemeSlug}.colors" - - write_text "$wallpaperMetadata" "$wallpaper/metadata.json" - write_text "$lookAndFeelMetadata" "$look_and_feel/metadata.json" - write_text "$lookAndFeelDefaults" "$look_and_feel/contents/defaults" - ''; + themePackage = + pkgs.runCommandLocal "stylix-kde-theme" + { + colorscheme = formatConfig colorscheme; + wallpaperMetadata = builtins.toJSON wallpaperMetadata; + wallpaperImage = config.stylix.image; + lookAndFeelMetadata = builtins.toJSON lookAndFeelMetadata; + lookAndFeelDefaults = formatConfig lookAndFeelDefaults; + } + '' + write_text() { + mkdir --parents "$(dirname "$2")" + printf '%s\n' "$1" >"$2" + } + + PATH="${pkgs.imagemagick}/bin:$PATH" + + wallpaper="$out/share/wallpapers/stylix" + look_and_feel="$out/share/plasma/look-and-feel/stylix" + + mkdir --parents "$wallpaper/contents/images" + + magick \ + "$wallpaperImage" \ + -thumbnail 400x250 \ + "$wallpaper/contents/screenshot.png" + + dimensions="$(identify -ping -format '%wx%h' "$wallpaperImage")" + magick "$wallpaperImage" "$wallpaper/contents/images/$dimensions.png" + + write_text \ + "$colorscheme" \ + "$out/share/color-schemes/${colorschemeSlug}.colors" + + write_text "$wallpaperMetadata" "$wallpaper/metadata.json" + write_text "$lookAndFeelMetadata" "$look_and_feel/metadata.json" + write_text "$lookAndFeelDefaults" "$look_and_feel/contents/defaults" + ''; # The cursor theme can be configured through a look and feel package, # however its size cannot. @@ -208,64 +220,74 @@ let }; }; - configPackage = pkgs.runCommandLocal "stylix-kde-config" { - kcminputrc = formatConfig kcminputrc; - kded5rc = formatConfig kded5rc; - kdeglobals = formatConfig kdeglobals; - } '' - mkdir "$out" - - printf '%s\n' "$kcminputrc" >"$out/kcminputrc" - printf '%s\n' "$kded5rc" >"$out/kded5rc" - printf '%s\n' "$kdeglobals" >"$out/kdeglobals" - ''; - -in { - options.stylix.targets.kde.enable = - config.lib.stylix.mkEnableTarget "KDE" true; - - config = lib.mkIf (config.stylix.enable && config.stylix.targets.kde.enable && pkgs.stdenv.hostPlatform.isLinux) { - home.packages = [ themePackage ]; - xdg.systemDirs.config = [ "${configPackage}" ]; - - # plasma-apply-wallpaperimage is necessary to change the wallpaper - # after the first login. - # - # plasma-apply-lookandfeel is only here to trigger a hot reload, the theme - # would still be applied without it if you logged out and back in. - # - # Home Manager clears $PATH before running the activation script, but we - # want to avoid installing these tools explicitly because that would pull - # in large dependencies for people who aren't actually using KDE. - # The workaround used is to assume a list of common paths where the tools - # might be installed, and look there. The ideal solution would require - # changes to KDE to make it possible to update the wallpaper through - # config files alone. - home.activation.stylixLookAndFeel = lib.hm.dag.entryAfter [ "writeBoundary" ] '' - global_path() { - for directory in /run/current-system/sw/bin /usr/bin /bin; do - if [[ -f "$directory/$1" ]]; then - printf '%s\n' "$directory/$1" - return 0 - fi - done - - return 1 + configPackage = + pkgs.runCommandLocal "stylix-kde-config" + { + kcminputrc = formatConfig kcminputrc; + kded5rc = formatConfig kded5rc; + kdeglobals = formatConfig kdeglobals; } + '' + mkdir "$out" + + printf '%s\n' "$kcminputrc" >"$out/kcminputrc" + printf '%s\n' "$kded5rc" >"$out/kded5rc" + printf '%s\n' "$kdeglobals" >"$out/kdeglobals" + ''; + +in +{ + options.stylix.targets.kde.enable = config.lib.stylix.mkEnableTarget "KDE" true; + + config = + lib.mkIf + ( + config.stylix.enable + && config.stylix.targets.kde.enable + && pkgs.stdenv.hostPlatform.isLinux + ) + { + home.packages = [ themePackage ]; + xdg.systemDirs.config = [ "${configPackage}" ]; + + # plasma-apply-wallpaperimage is necessary to change the wallpaper + # after the first login. + # + # plasma-apply-lookandfeel is only here to trigger a hot reload, the theme + # would still be applied without it if you logged out and back in. + # + # Home Manager clears $PATH before running the activation script, but we + # want to avoid installing these tools explicitly because that would pull + # in large dependencies for people who aren't actually using KDE. + # The workaround used is to assume a list of common paths where the tools + # might be installed, and look there. The ideal solution would require + # changes to KDE to make it possible to update the wallpaper through + # config files alone. + home.activation.stylixLookAndFeel = lib.hm.dag.entryAfter [ "writeBoundary" ] '' + global_path() { + for directory in /run/current-system/sw/bin /usr/bin /bin; do + if [[ -f "$directory/$1" ]]; then + printf '%s\n' "$directory/$1" + return 0 + fi + done + + return 1 + } + + if wallpaper_image="$(global_path plasma-apply-wallpaperimage)"; then + "$wallpaper_image" "${themePackage}/share/wallpapers/stylix" + else + verboseEcho \ + "plasma-apply-wallpaperimage: command not found" + fi - if wallpaper_image="$(global_path plasma-apply-wallpaperimage)"; then - "$wallpaper_image" "${themePackage}/share/wallpapers/stylix" - else - verboseEcho \ - "plasma-apply-wallpaperimage: command not found" - fi - - if look_and_feel="$(global_path plasma-apply-lookandfeel)"; then - "$look_and_feel" --apply stylix - else - verboseEcho \ - "Skipping plasma-apply-lookandfeel: command not found" - fi - ''; - }; + if look_and_feel="$(global_path plasma-apply-lookandfeel)"; then + "$look_and_feel" --apply stylix + else + verboseEcho \ + "Skipping plasma-apply-lookandfeel: command not found" + fi + ''; + }; } diff --git a/modules/kitty/hm.nix b/modules/kitty/hm.nix index 5c82e8d38..034a25037 100644 --- a/modules/kitty/hm.nix +++ b/modules/kitty/hm.nix @@ -6,7 +6,8 @@ let templateRepo = config.lib.stylix.templates.base16-kitty; target = if cfg.variant256Colors then "default-256" else "default"; }; -in { +in +{ options.stylix.targets.kitty = { enable = config.lib.stylix.mkEnableTarget "Kitty" true; @@ -26,7 +27,9 @@ in { inherit (config.stylix.fonts.monospace) package name; size = config.stylix.fonts.sizes.terminal; }; - settings.background_opacity = with config.stylix.opacity; "${builtins.toString terminal}"; + settings.background_opacity = + with config.stylix.opacity; + "${builtins.toString terminal}"; extraConfig = '' include ${theme} ''; diff --git a/modules/kmscon/nixos.nix b/modules/kmscon/nixos.nix index 791894abf..879d84640 100644 --- a/modules/kmscon/nixos.nix +++ b/modules/kmscon/nixos.nix @@ -1,41 +1,44 @@ { config, lib, ... }: { - options.stylix.targets.kmscon.enable = - config.lib.stylix.mkEnableTarget "the kmscon virtual console" true; + options.stylix.targets.kmscon.enable = config.lib.stylix.mkEnableTarget "the kmscon virtual console" true; - config.services.kmscon = lib.mkIf (config.stylix.enable && config.stylix.targets.kmscon.enable) { - fonts = [config.stylix.fonts.monospace]; - extraConfig = - let - formatBase = name: - let - getComponent = comp: config.lib.stylix.colors."${name}-rgb-${comp}"; - in - "${getComponent "r"},${getComponent "g"},${getComponent "b"}"; - in '' - font-size=${builtins.toString config.stylix.fonts.sizes.terminal} + config.services.kmscon = + lib.mkIf (config.stylix.enable && config.stylix.targets.kmscon.enable) + { + fonts = [ config.stylix.fonts.monospace ]; + extraConfig = + let + formatBase = + name: + let + getComponent = comp: config.lib.stylix.colors."${name}-rgb-${comp}"; + in + "${getComponent "r"},${getComponent "g"},${getComponent "b"}"; + in + '' + font-size=${builtins.toString config.stylix.fonts.sizes.terminal} - palette=custom + palette=custom - palette-black=${formatBase "base00"} - palette-red=${formatBase "base08"} - palette-green=${formatBase "base0B"} - palette-yellow=${formatBase "base0A"} - palette-blue=${formatBase "base0D"} - palette-magenta=${formatBase "base0E"} - palette-cyan=${formatBase "base0C"} - palette-light-grey=${formatBase "base05"} - palette-dark-grey=${formatBase "base03"} - palette-light-red=${formatBase "base08"} - palette-light-green=${formatBase "base0B"} - palette-light-yellow=${formatBase "base0A"} - palette-light-blue=${formatBase "base0D"} - palette-light-magenta=${formatBase "base0E"} - palette-light-cyan=${formatBase "base0C"} - palette-white=${formatBase "base07"} + palette-black=${formatBase "base00"} + palette-red=${formatBase "base08"} + palette-green=${formatBase "base0B"} + palette-yellow=${formatBase "base0A"} + palette-blue=${formatBase "base0D"} + palette-magenta=${formatBase "base0E"} + palette-cyan=${formatBase "base0C"} + palette-light-grey=${formatBase "base05"} + palette-dark-grey=${formatBase "base03"} + palette-light-red=${formatBase "base08"} + palette-light-green=${formatBase "base0B"} + palette-light-yellow=${formatBase "base0A"} + palette-light-blue=${formatBase "base0D"} + palette-light-magenta=${formatBase "base0E"} + palette-light-cyan=${formatBase "base0C"} + palette-white=${formatBase "base07"} - palette-background=${formatBase "base00"} - palette-foreground=${formatBase "base05"} - ''; - }; + palette-background=${formatBase "base00"} + palette-foreground=${formatBase "base05"} + ''; + }; } diff --git a/modules/lazygit/hm.nix b/modules/lazygit/hm.nix index 94ea43808..072b2b504 100644 --- a/modules/lazygit/hm.nix +++ b/modules/lazygit/hm.nix @@ -2,25 +2,32 @@ config, lib, ... -}: let +}: +let colors = config.lib.stylix.colors.withHashtag; -in { +in +{ options.stylix.targets.lazygit.enable = config.lib.stylix.mkEnableTarget "lazygit" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.lazygit.enable) { - programs.lazygit.settings.gui.theme = { - activeBorderColor = [ - colors.base07 - "bold" - ]; - inactiveBorderColor = [colors.base04]; - searchingActiveBorderColor = [colors.base02 "bold"]; - optionsTextColor = [colors.base06]; - selectedLineBgColor = [colors.base03]; - cherryPickedCommitBgColor = [colors.base02]; - cherryPickedCommitFgColor = [colors.base03]; - unstagedChangesColor = [colors.base08]; - defaultFgColor = [colors.base05]; - }; - }; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.lazygit.enable) + { + programs.lazygit.settings.gui.theme = { + activeBorderColor = [ + colors.base07 + "bold" + ]; + inactiveBorderColor = [ colors.base04 ]; + searchingActiveBorderColor = [ + colors.base02 + "bold" + ]; + optionsTextColor = [ colors.base06 ]; + selectedLineBgColor = [ colors.base03 ]; + cherryPickedCommitBgColor = [ colors.base02 ]; + cherryPickedCommitFgColor = [ colors.base03 ]; + unstagedChangesColor = [ colors.base08 ]; + defaultFgColor = [ colors.base05 ]; + }; + }; } diff --git a/modules/lightdm/nixos.nix b/modules/lightdm/nixos.nix index e0ea1d382..af06239e4 100644 --- a/modules/lightdm/nixos.nix +++ b/modules/lightdm/nixos.nix @@ -1,9 +1,9 @@ { config, lib, ... }: { - options.stylix.targets.lightdm.enable = - config.lib.stylix.mkEnableTarget "LightDM" true; + options.stylix.targets.lightdm.enable = config.lib.stylix.mkEnableTarget "LightDM" true; - config.services.xserver.displayManager.lightdm.background = - lib.mkIf (config.stylix.enable && config.stylix.targets.lightdm.enable) config.stylix.image; + config.services.xserver.displayManager.lightdm.background = lib.mkIf ( + config.stylix.enable && config.stylix.targets.lightdm.enable + ) config.stylix.image; } diff --git a/modules/mako/hm.nix b/modules/mako/hm.nix index b999b8d38..1e180a1ac 100644 --- a/modules/mako/hm.nix +++ b/modules/mako/hm.nix @@ -1,33 +1,42 @@ -{ config, lib, options, ... }: +{ + config, + lib, + options, + ... +}: with config.lib.stylix.colors.withHashtag; with config.stylix.fonts; let - makoOpacity = lib.toHexString (((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100); -in { - options.stylix.targets.mako.enable = - config.lib.stylix.mkEnableTarget "Mako" true; + makoOpacity = lib.toHexString ( + ((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100 + ); +in +{ + options.stylix.targets.mako.enable = config.lib.stylix.mkEnableTarget "Mako" true; # Referenced https://github.com/stacyharper/base16-mako - config = lib.optionalAttrs (options.services ? mako) (lib.mkIf (config.stylix.enable && config.stylix.targets.mako.enable) { - services.mako = { - backgroundColor = base00 + makoOpacity; - borderColor = base0D; - textColor = base05; - progressColor = "over ${base02}"; - font = "${sansSerif.name} ${toString sizes.popups}"; - # I wish the mako hm module was like the dunst one - extraConfig = '' - [urgency=low] - background-color=${base00}${makoOpacity} - border-color=${base0D} - text-color=${base0A} + config = lib.optionalAttrs (options.services ? mako) ( + lib.mkIf (config.stylix.enable && config.stylix.targets.mako.enable) { + services.mako = { + backgroundColor = base00 + makoOpacity; + borderColor = base0D; + textColor = base05; + progressColor = "over ${base02}"; + font = "${sansSerif.name} ${toString sizes.popups}"; + # I wish the mako hm module was like the dunst one + extraConfig = '' + [urgency=low] + background-color=${base00}${makoOpacity} + border-color=${base0D} + text-color=${base0A} - [urgency=high] - background-color=${base00}${makoOpacity} - border-color=${base0D} - text-color=${base08} - ''; - }; - }); + [urgency=high] + background-color=${base00}${makoOpacity} + border-color=${base0D} + text-color=${base08} + ''; + }; + } + ); } diff --git a/modules/mangohud/hm.nix b/modules/mangohud/hm.nix index d13deedf1..f251bd717 100644 --- a/modules/mangohud/hm.nix +++ b/modules/mangohud/hm.nix @@ -1,37 +1,40 @@ { config, lib, ... }: let - inherit (config.stylix) fonts opacity; - inherit (config.lib.stylix) colors; -in { - options.stylix.targets.mangohud.enable = config.lib.stylix.mkEnableTarget "mangohud" true; + inherit (config.stylix) fonts opacity; + inherit (config.lib.stylix) colors; +in +{ + options.stylix.targets.mangohud.enable = config.lib.stylix.mkEnableTarget "mangohud" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.mangohud.enable) { + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.mangohud.enable) + { programs.mangohud.settings = with colors; { - font_size = fonts.sizes.applications; - font_size_text = fonts.sizes.applications; - background_alpha = opacity.popups; - alpha = opacity.applications; - text_color = base05; - text_outline_color = base00; - background_color = base00; - gpu_color = base0B; - cpu_color = base0D; - vram_color = base0C; - media_player_color = base05; - engine_color = base0E; - wine_color = base0E; - frametime_color = base0B; - battery_color = base04; - io_color = base0A; - gpu_load_color = "${base0B}, ${base0A}, ${base08}"; - cpu_load_color = "${base0B}, ${base0A}, ${base08}"; - fps_color = "${base0B}, ${base0A}, ${base08}"; + font_size = fonts.sizes.applications; + font_size_text = fonts.sizes.applications; + background_alpha = opacity.popups; + alpha = opacity.applications; + text_color = base05; + text_outline_color = base00; + background_color = base00; + gpu_color = base0B; + cpu_color = base0D; + vram_color = base0C; + media_player_color = base05; + engine_color = base0E; + wine_color = base0E; + frametime_color = base0B; + battery_color = base04; + io_color = base0A; + gpu_load_color = "${base0B}, ${base0A}, ${base08}"; + cpu_load_color = "${base0B}, ${base0A}, ${base08}"; + fps_color = "${base0B}, ${base0A}, ${base08}"; - # TODO: Use the point unit: - # https://github.com/danth/stylix/issues/251. - font_scale = 1.33333; + # TODO: Use the point unit: + # https://github.com/danth/stylix/issues/251. + font_scale = 1.33333; }; - }; + }; } diff --git a/modules/ncspot/hm.nix b/modules/ncspot/hm.nix index 42491c51d..a01d533ca 100644 --- a/modules/ncspot/hm.nix +++ b/modules/ncspot/hm.nix @@ -1,33 +1,35 @@ { config, lib, ... }: { - options.stylix.targets.ncspot.enable = - config.lib.stylix.mkEnableTarget "Ncspot" true; + options.stylix.targets.ncspot.enable = config.lib.stylix.mkEnableTarget "Ncspot" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.ncspot.enable) { - programs.ncspot.settings = - let - colors = config.lib.stylix.colors.withHashtag; - in { - theme = with colors; { - background = base00; - primary = base05; - secondary = base03; - title = base06; - playing = base05; - playing_selected = base06; - playing_bg = base02; - highlight = base05; - highlight_bg = base02; - error = base07; - error_bg = base0F; - statusbar = base00; - statusbar_progress = base04; - statusbar_bg = base04; - cmdline = base05; - cmdline_bg = base00; - search_match = base05; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.ncspot.enable) + { + programs.ncspot.settings = + let + colors = config.lib.stylix.colors.withHashtag; + in + { + theme = with colors; { + background = base00; + primary = base05; + secondary = base03; + title = base06; + playing = base05; + playing_selected = base06; + playing_bg = base02; + highlight = base05; + highlight_bg = base02; + error = base07; + error_bg = base0F; + statusbar = base00; + statusbar_progress = base04; + statusbar_bg = base04; + cmdline = base05; + cmdline_bg = base00; + search_match = base05; + }; + }; }; - }; - }; } diff --git a/modules/neovim/hm.nix b/modules/neovim/hm.nix index 587c196e8..beebe8f64 100644 --- a/modules/neovim/hm.nix +++ b/modules/neovim/hm.nix @@ -1,9 +1,13 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: { options.stylix.targets.neovim = { - enable = - config.lib.stylix.mkEnableTarget "Neovim" true; + enable = config.lib.stylix.mkEnableTarget "Neovim" true; transparentBackground = { main = lib.mkEnableOption "background transparency for the main Neovim window"; @@ -11,33 +15,35 @@ }; }; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.neovim.enable) { - programs.neovim = - let - cfg = config.stylix.targets.neovim; - in + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.neovim.enable) { - plugins = lib.singleton { - plugin = pkgs.vimPlugins.base16-nvim; - type = "lua"; - config = lib.mkMerge [ - (with config.lib.stylix.colors.withHashtag; '' - require('base16-colorscheme').setup({ - base00 = '${base00}', base01 = '${base01}', base02 = '${base02}', base03 = '${base03}', - base04 = '${base04}', base05 = '${base05}', base06 = '${base06}', base07 = '${base07}', - base08 = '${base08}', base09 = '${base09}', base0A = '${base0A}', base0B = '${base0B}', - base0C = '${base0C}', base0D = '${base0D}', base0E = '${base0E}', base0F = '${base0F}' - }) - '') - (lib.mkIf cfg.transparentBackground.main '' - vim.cmd.highlight({ "Normal", "guibg=NONE", "ctermbg=NONE" }) - vim.cmd.highlight({ "NonText", "guibg=NONE", "ctermbg=NONE" }) - '') - (lib.mkIf cfg.transparentBackground.signColumn '' - vim.cmd.highlight({ "SignColumn", "guibg=NONE", "ctermbg=NONE" }) - '') - ]; - }; + programs.neovim = + let + cfg = config.stylix.targets.neovim; + in + { + plugins = lib.singleton { + plugin = pkgs.vimPlugins.base16-nvim; + type = "lua"; + config = lib.mkMerge [ + (with config.lib.stylix.colors.withHashtag; '' + require('base16-colorscheme').setup({ + base00 = '${base00}', base01 = '${base01}', base02 = '${base02}', base03 = '${base03}', + base04 = '${base04}', base05 = '${base05}', base06 = '${base06}', base07 = '${base07}', + base08 = '${base08}', base09 = '${base09}', base0A = '${base0A}', base0B = '${base0B}', + base0C = '${base0C}', base0D = '${base0D}', base0E = '${base0E}', base0F = '${base0F}' + }) + '') + (lib.mkIf cfg.transparentBackground.main '' + vim.cmd.highlight({ "Normal", "guibg=NONE", "ctermbg=NONE" }) + vim.cmd.highlight({ "NonText", "guibg=NONE", "ctermbg=NONE" }) + '') + (lib.mkIf cfg.transparentBackground.signColumn '' + vim.cmd.highlight({ "SignColumn", "guibg=NONE", "ctermbg=NONE" }) + '') + ]; + }; + }; }; - }; } diff --git a/modules/nixos-icons/nixos.nix b/modules/nixos-icons/nixos.nix index 90f037c91..45462c3bc 100644 --- a/modules/nixos-icons/nixos.nix +++ b/modules/nixos-icons/nixos.nix @@ -1,25 +1,33 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: with config.lib.stylix.colors; { - options.stylix.targets.nixos-icons.enable = - config.lib.stylix.mkEnableTarget "the NixOS logo" true; + options.stylix.targets.nixos-icons.enable = config.lib.stylix.mkEnableTarget "the NixOS logo" true; - config.nixpkgs.overlays = lib.mkIf (config.stylix.enable && config.stylix.targets.nixos-icons.enable) [(_: super: { - nixos-icons = super.nixos-icons.overrideAttrs (oldAttrs: { - src = pkgs.applyPatches { - inherit (oldAttrs) src; - prePatch = '' - substituteInPlace logo/nix-snowflake-white.svg --replace-fail '#ffffff' '#${base05}' + config.nixpkgs.overlays = + lib.mkIf (config.stylix.enable && config.stylix.targets.nixos-icons.enable) + [ + (_: super: { + nixos-icons = super.nixos-icons.overrideAttrs (oldAttrs: { + src = pkgs.applyPatches { + inherit (oldAttrs) src; + prePatch = '' + substituteInPlace logo/nix-snowflake-white.svg --replace-fail '#ffffff' '#${base05}' - # Insert attribution comment after the XML prolog - sed \ - --in-place \ - '2i' \ - logo/nix-snowflake-white.svg - ''; - }; - }); - })]; + # Insert attribution comment after the XML prolog + sed \ + --in-place \ + '2i' \ + logo/nix-snowflake-white.svg + ''; + }; + }); + }) + ]; } diff --git a/modules/nixvim/nixvim.nix b/modules/nixvim/nixvim.nix index dbc1da661..36c1b58bf 100644 --- a/modules/nixvim/nixvim.nix +++ b/modules/nixvim/nixvim.nix @@ -3,10 +3,10 @@ lib, options, ... -}: { +}: +{ options.stylix.targets.nixvim = { - enable = - config.lib.stylix.mkEnableTarget "nixvim" true; + enable = config.lib.stylix.mkEnableTarget "nixvim" true; transparentBackground = { main = lib.mkEnableOption "background transparency for the main NeoVim window"; signColumn = lib.mkEnableOption "background transparency for the NeoVim sign column"; @@ -16,40 +16,90 @@ imports = [ # Added: 2024-08-06 (lib.mkRenamedOptionModule - [ "stylix" "targets" "nixvim" "transparent_bg" "main" ] - [ "stylix" "targets" "nixvim" "transparentBackground" "main" ]) + [ + "stylix" + "targets" + "nixvim" + "transparent_bg" + "main" + ] + [ + "stylix" + "targets" + "nixvim" + "transparentBackground" + "main" + ] + ) # Added: 2024-08-06 (lib.mkRenamedOptionModule - [ "stylix" "targets" "nixvim" "transparent_bg" "sign_column" ] - [ "stylix" "targets" "nixvim" "transparentBackground" "signColumn" ]) + [ + "stylix" + "targets" + "nixvim" + "transparent_bg" + "sign_column" + ] + [ + "stylix" + "targets" + "nixvim" + "transparentBackground" + "signColumn" + ] + ) ]; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.nixvim.enable && (config.programs ? nixvim)) ( - lib.optionalAttrs (builtins.hasAttr "nixvim" options.programs) { - programs.nixvim = { - colorschemes.base16 = { - colorscheme = { - inherit (config.lib.stylix.colors.withHashtag) - base00 base01 base02 base03 base04 base05 base06 base07 - base08 base09 base0A base0B base0C base0D base0E base0F; - }; + config = + lib.mkIf + ( + config.stylix.enable + && config.stylix.targets.nixvim.enable + && (config.programs ? nixvim) + ) + ( + lib.optionalAttrs (builtins.hasAttr "nixvim" options.programs) { + programs.nixvim = { + colorschemes.base16 = { + colorscheme = { + inherit (config.lib.stylix.colors.withHashtag) + base00 + base01 + base02 + base03 + base04 + base05 + base06 + base07 + base08 + base09 + base0A + base0B + base0C + base0D + base0E + base0F + ; + }; - enable = true; - }; + enable = true; + }; - highlight = let - cfg = config.stylix.targets.nixvim; - transparent = { - bg = "none"; - ctermbg = "none"; + highlight = + let + cfg = config.stylix.targets.nixvim; + transparent = { + bg = "none"; + ctermbg = "none"; + }; + in + { + Normal = lib.mkIf cfg.transparentBackground.main transparent; + NonText = lib.mkIf cfg.transparentBackground.main transparent; + SignColumn = lib.mkIf cfg.transparentBackground.signColumn transparent; + }; }; - in { - Normal = lib.mkIf cfg.transparentBackground.main transparent; - NonText = lib.mkIf cfg.transparentBackground.main transparent; - SignColumn = lib.mkIf cfg.transparentBackground.signColumn transparent; - }; - }; - } - ); + } + ); } diff --git a/modules/nushell/hm.nix b/modules/nushell/hm.nix index 9f5801c65..9a36f5bad 100644 --- a/modules/nushell/hm.nix +++ b/modules/nushell/hm.nix @@ -3,46 +3,47 @@ with config.lib.stylix.colors.withHashtag; { - options.stylix.targets.nushell.enable = - config.lib.stylix.mkEnableTarget "Nushell" true; + options.stylix.targets.nushell.enable = config.lib.stylix.mkEnableTarget "Nushell" true; # Adapted from https://www.nushell.sh/book/coloring_and_theming.html#theming - config.programs.nushell.extraConfig = lib.mkIf (config.stylix.enable && config.stylix.targets.nushell.enable) '' - $env.config.color_config = { - separator: "${base03}" - leading_trailing_space_bg: "${base04}" - header: "${base0B}" - date: "${base0E}" - filesize: "${base0D}" - row_index: "${base0C}" - bool: "${base08}" - int: "${base0B}" - duration: "${base08}" - range: "${base08}" - float: "${base08}" - string: "${base04}" - nothing: "${base08}" - binary: "${base08}" - cellpath: "${base08}" - hints: dark_gray + config.programs.nushell.extraConfig = + lib.mkIf (config.stylix.enable && config.stylix.targets.nushell.enable) + '' + $env.config.color_config = { + separator: "${base03}" + leading_trailing_space_bg: "${base04}" + header: "${base0B}" + date: "${base0E}" + filesize: "${base0D}" + row_index: "${base0C}" + bool: "${base08}" + int: "${base0B}" + duration: "${base08}" + range: "${base08}" + float: "${base08}" + string: "${base04}" + nothing: "${base08}" + binary: "${base08}" + cellpath: "${base08}" + hints: dark_gray - shape_garbage: { fg: "${base07}" bg: "${base08}" } - shape_bool: "${base0D}" - shape_int: { fg: "${base0E}" attr: b } - shape_float: { fg: "${base0E}" attr: b } - shape_range: { fg: "${base0A}" attr: b } - shape_internalcall: { fg: "${base0C}" attr: b } - shape_external: "${base0C}" - shape_externalarg: { fg: "${base0B}" attr: b } - shape_literal: "${base0D}" - shape_operator: "${base0A}" - shape_signature: { fg: "${base0B}" attr: b } - shape_string: "${base0B}" - shape_filepath: "${base0D}" - shape_globpattern: { fg: "${base0D}" attr: b } - shape_variable: "${base0E}" - shape_flag: { fg: "${base0D}" attr: b } - shape_custom: { attr: b } - } - ''; + shape_garbage: { fg: "${base07}" bg: "${base08}" } + shape_bool: "${base0D}" + shape_int: { fg: "${base0E}" attr: b } + shape_float: { fg: "${base0E}" attr: b } + shape_range: { fg: "${base0A}" attr: b } + shape_internalcall: { fg: "${base0C}" attr: b } + shape_external: "${base0C}" + shape_externalarg: { fg: "${base0B}" attr: b } + shape_literal: "${base0D}" + shape_operator: "${base0A}" + shape_signature: { fg: "${base0B}" attr: b } + shape_string: "${base0B}" + shape_filepath: "${base0D}" + shape_globpattern: { fg: "${base0D}" attr: b } + shape_variable: "${base0E}" + shape_flag: { fg: "${base0D}" attr: b } + shape_custom: { attr: b } + } + ''; } diff --git a/modules/plymouth/nixos.nix b/modules/plymouth/nixos.nix index 72a08f3ba..b8ec216ad 100644 --- a/modules/plymouth/nixos.nix +++ b/modules/plymouth/nixos.nix @@ -1,4 +1,9 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: let cfg = config.stylix.targets.plymouth; @@ -18,19 +23,17 @@ let $themeDir/logo.png ${ - if cfg.logoAnimated - then "cp ${./theme.script} $themeDir/stylix.script" - else "cp ${./theme_still.script} $themeDir/stylix.script" + if cfg.logoAnimated then + "cp ${./theme.script} $themeDir/stylix.script" + else + "cp ${./theme_still.script} $themeDir/stylix.script" } - ${ - with config.lib.stylix.colors; - '' - substituteInPlace $themeDir/stylix.script \ - --replace-fail "%BASE00%" "${base00-dec-r}, ${base00-dec-g}, ${base00-dec-b}" \ - --replace-fail "%BASE05%" "${base05-dec-r}, ${base05-dec-g}, ${base05-dec-b}" - '' - } + ${with config.lib.stylix.colors; '' + substituteInPlace $themeDir/stylix.script \ + --replace-fail "%BASE00%" "${base00-dec-r}, ${base00-dec-g}, ${base00-dec-b}" \ + --replace-fail "%BASE05%" "${base05-dec-r}, ${base05-dec-g}, ${base05-dec-b}" + ''} echo " [Plymouth Theme] @@ -43,7 +46,8 @@ let " > $themeDir/stylix.plymouth ''; -in { +in +{ options.stylix.targets.plymouth = { enable = config.lib.stylix.mkEnableTarget "the Plymouth boot screen" true; @@ -68,9 +72,13 @@ in { }; imports = [ - ( - lib.mkRemovedOptionModule - [ "stylix" "targets" "plymouth" "blackBackground" ] + (lib.mkRemovedOptionModule + [ + "stylix" + "targets" + "plymouth" + "blackBackground" + ] "This was removed since it goes against the chosen color scheme. If you want this, consider disabling the target and configuring Plymouth by hand." ) ]; diff --git a/modules/qutebrowser/hm.nix b/modules/qutebrowser/hm.nix index 033ad4b7d..715156ac9 100644 --- a/modules/qutebrowser/hm.nix +++ b/modules/qutebrowser/hm.nix @@ -17,267 +17,269 @@ let secondary-info = base0C; warning = base0E; -in { - options.stylix.targets.qutebrowser.enable = - config.lib.stylix.mkEnableTarget "Qutebrowser" true; - - config = lib.mkIf (config.stylix.enable && config.stylix.targets.qutebrowser.enable) { - programs.qutebrowser.settings = { - colors = { - completion = { - category = { - bg = background; - fg = info; - - border = { - bottom = background; - top = background; - }; - }; - - even.bg = background; - fg = foreground; - - item.selected = { - bg = selection-background; - - border = { - bottom = selection-background; - top = selection-background; - }; +in +{ + options.stylix.targets.qutebrowser.enable = config.lib.stylix.mkEnableTarget "Qutebrowser" true; + + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.qutebrowser.enable) + { + programs.qutebrowser.settings = { + colors = { + completion = { + category = { + bg = background; + fg = info; + + border = { + bottom = background; + top = background; + }; + }; - fg = foreground; - }; + even.bg = background; + fg = foreground; - match.fg = info; - odd.bg = secondary-background; + item.selected = { + bg = selection-background; - scrollbar = { - bg = background; - fg = foreground; - }; - }; + border = { + bottom = selection-background; + top = selection-background; + }; - contextmenu = { - disabled = { - bg = secondary-background; - fg = inverted-foreground; - }; + fg = foreground; + }; - menu = { - bg = background; - fg = foreground; - }; + match.fg = info; + odd.bg = secondary-background; - selected = { - bg = selection-background; - fg = foreground; - }; - }; + scrollbar = { + bg = background; + fg = foreground; + }; + }; - downloads = { - bar.bg = background; + contextmenu = { + disabled = { + bg = secondary-background; + fg = inverted-foreground; + }; - error = { - bg = error; - fg = inverted-foreground; - }; + menu = { + bg = background; + fg = foreground; + }; - start = { - bg = info; - fg = inverted-foreground; - }; + selected = { + bg = selection-background; + fg = foreground; + }; + }; - stop = { - bg = secondary-info; - fg = inverted-foreground; - }; - }; + downloads = { + bar.bg = background; - hints = { - bg = secondary-background; - fg = foreground; - match.fg = info; - }; + error = { + bg = error; + fg = inverted-foreground; + }; - keyhint = { - bg = background; - fg = foreground; - suffix.fg = foreground; - }; + start = { + bg = info; + fg = inverted-foreground; + }; - messages = { - error = { - bg = error; - fg = inverted-foreground; - border = error; - }; + stop = { + bg = secondary-info; + fg = inverted-foreground; + }; + }; - info = { - bg = info; - fg = inverted-foreground; - border = info; - }; + hints = { + bg = secondary-background; + fg = foreground; + match.fg = info; + }; - warning = { - bg = warning; - fg = inverted-foreground; - border = warning; - }; - }; + keyhint = { + bg = background; + fg = foreground; + suffix.fg = foreground; + }; - prompts = { - bg = background; - border = background; - fg = foreground; - selected.bg = secondary-background; - }; + messages = { + error = { + bg = error; + fg = inverted-foreground; + border = error; + }; - statusbar = { - caret = { - bg = selection-background; - fg = foreground; + info = { + bg = info; + fg = inverted-foreground; + border = info; + }; - selection = { - bg = selection-background; - fg = foreground; + warning = { + bg = warning; + fg = inverted-foreground; + border = warning; + }; }; - }; - - command = { - bg = background; - fg = foreground; - private = { - bg = secondary-background; + prompts = { + bg = background; + border = background; fg = foreground; + selected.bg = secondary-background; }; - }; - insert = { - bg = info; - fg = inverted-foreground; - }; + statusbar = { + caret = { + bg = selection-background; + fg = foreground; - normal = { - bg = background; - fg = foreground; - }; + selection = { + bg = selection-background; + fg = foreground; + }; + }; - passthrough = { - bg = secondary-info; - fg = inverted-foreground; - }; + command = { + bg = background; + fg = foreground; - private = { - bg = secondary-background; - fg = foreground; - }; + private = { + bg = secondary-background; + fg = foreground; + }; + }; - progress.bg = info; + insert = { + bg = info; + fg = inverted-foreground; + }; - url = { - error.fg = error; - fg = foreground; - hover.fg = foreground; + normal = { + bg = background; + fg = foreground; + }; - success = { - http.fg = secondary-info; - https.fg = info; - }; + passthrough = { + bg = secondary-info; + fg = inverted-foreground; + }; - warn.fg = warning; - }; - }; + private = { + bg = secondary-background; + fg = foreground; + }; - tabs = { - bar.bg = background; + progress.bg = info; - even = { - bg = secondary-background; - fg = foreground; - }; + url = { + error.fg = error; + fg = foreground; + hover.fg = foreground; - indicator = { - inherit error; - start = secondary-info; - stop = info; - }; + success = { + http.fg = secondary-info; + https.fg = info; + }; - odd = { - bg = background; - fg = foreground; - }; - - pinned = { - even = { - bg = info; - fg = inverted-foreground; + warn.fg = warning; + }; }; - odd = { - bg = secondary-info; - fg = inverted-foreground; - }; + tabs = { + bar.bg = background; - selected = { even = { - bg = selection-background; + bg = secondary-background; fg = foreground; }; + indicator = { + inherit error; + start = secondary-info; + stop = info; + }; + odd = { - bg = selection-background; + bg = background; fg = foreground; }; - }; - }; - selected = { - even = { - bg = selection-background; - fg = foreground; - }; + pinned = { + even = { + bg = info; + fg = inverted-foreground; + }; + + odd = { + bg = secondary-info; + fg = inverted-foreground; + }; + + selected = { + even = { + bg = selection-background; + fg = foreground; + }; + + odd = { + bg = selection-background; + fg = foreground; + }; + }; + }; - odd = { - bg = selection-background; - fg = foreground; + selected = { + even = { + bg = selection-background; + fg = foreground; + }; + + odd = { + bg = selection-background; + fg = foreground; + }; + }; }; - }; - }; - webpage = let - isDark = config.stylix.polarity == "dark"; - in { - darkmode.enabled = lib.mkIf isDark (lib.mkDefault true); + webpage = + let + isDark = config.stylix.polarity == "dark"; + in + { + darkmode.enabled = lib.mkIf isDark (lib.mkDefault true); - preferred_color_scheme = - lib.mkIf - isDark (lib.mkDefault config.stylix.polarity); - }; - }; + preferred_color_scheme = lib.mkIf isDark (lib.mkDefault config.stylix.polarity); + }; + }; + + fonts = { + default_family = sansSerif.name; + default_size = "${toString sizes.applications}pt"; + + web = { + family = { + cursive = serif.name; + fantasy = serif.name; + fixed = monospace.name; + sans_serif = sansSerif.name; + serif = serif.name; + standard = sansSerif.name; + }; - fonts = { - default_family = sansSerif.name; - default_size = "${toString sizes.applications}pt"; - - web = { - family = { - cursive = serif.name; - fantasy = serif.name; - fixed = monospace.name; - sans_serif = sansSerif.name; - serif = serif.name; - standard = sansSerif.name; + # TODO: Use the pixel unit: + # https://github.com/danth/stylix/issues/251. + size.default = builtins.floor (sizes.applications * 4 / 3 + 0.5); + }; }; - # TODO: Use the pixel unit: - # https://github.com/danth/stylix/issues/251. - size.default = builtins.floor (sizes.applications * 4 / 3 + 0.5); + hints.border = background; }; }; - - hints.border = background; - }; - }; } diff --git a/modules/rofi/hm.nix b/modules/rofi/hm.nix index d13d7ad9f..a08ffa13e 100644 --- a/modules/rofi/hm.nix +++ b/modules/rofi/hm.nix @@ -4,21 +4,22 @@ with config.stylix.fonts; let inherit (config.lib.formats.rasi) mkLiteral; - mkRgba = opacity: color: + mkRgba = + opacity: color: let c = config.lib.stylix.colors; r = c."${color}-rgb-r"; g = c."${color}-rgb-g"; b = c."${color}-rgb-b"; in - mkLiteral - "rgba ( ${r}, ${g}, ${b}, ${opacity} % )"; + mkLiteral "rgba ( ${r}, ${g}, ${b}, ${opacity} % )"; mkRgb = mkRgba "100"; - rofiOpacity = builtins.toString (builtins.ceil (config.stylix.opacity.popups * 100)); + rofiOpacity = builtins.toString ( + builtins.ceil (config.stylix.opacity.popups * 100) + ); in { - options.stylix.targets.rofi.enable = - config.lib.stylix.mkEnableTarget "Rofi" true; + options.stylix.targets.rofi.enable = config.lib.stylix.mkEnableTarget "Rofi" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.rofi.enable) { programs.rofi = { diff --git a/modules/sway/hm.nix b/modules/sway/hm.nix index 1da892e2b..33b06a262 100644 --- a/modules/sway/hm.nix +++ b/modules/sway/hm.nix @@ -13,46 +13,48 @@ let size = config.stylix.fonts.sizes.desktop + 0.0; }; -in { - options.stylix.targets.sway.enable = - config.lib.stylix.mkEnableTarget "Sway" true; +in +{ + options.stylix.targets.sway.enable = config.lib.stylix.mkEnableTarget "Sway" true; config = lib.mkMerge [ (lib.mkIf (config.stylix.enable && config.stylix.targets.sway.enable) { wayland.windowManager.sway.config = { inherit fonts; - colors = let - background = base00; - indicator = base0B; - in { - inherit background; - urgent = { - inherit background indicator text; - border = urgent; - childBorder = urgent; + colors = + let + background = base00; + indicator = base0B; + in + { + inherit background; + urgent = { + inherit background indicator text; + border = urgent; + childBorder = urgent; + }; + focused = { + inherit background indicator text; + border = focused; + childBorder = focused; + }; + focusedInactive = { + inherit background indicator text; + border = unfocused; + childBorder = unfocused; + }; + unfocused = { + inherit background indicator text; + border = unfocused; + childBorder = unfocused; + }; + placeholder = { + inherit background indicator text; + border = unfocused; + childBorder = unfocused; + }; }; - focused = { - inherit background indicator text; - border = focused; - childBorder = focused; - }; - focusedInactive = { - inherit background indicator text; - border = unfocused; - childBorder = unfocused; - }; - unfocused = { - inherit background indicator text; - border = unfocused; - childBorder = unfocused; - }; - placeholder = { - inherit background indicator text; - border = unfocused; - childBorder = unfocused; - }; - }; output."*".bg = "${config.stylix.image} ${config.stylix.imageScalingMode}"; @@ -67,34 +69,36 @@ in { lib.stylix.sway.bar = { inherit fonts; - colors = let - background = base01; - border = background; - in { - inherit background; - statusline = text; - separator = base03; - focusedWorkspace = { - inherit text border; - background = focused; + colors = + let + background = base01; + border = background; + in + { + inherit background; + statusline = text; + separator = base03; + focusedWorkspace = { + inherit text border; + background = focused; + }; + activeWorkspace = { + inherit text border; + background = unfocused; + }; + inactiveWorkspace = { + inherit text border; + background = unfocused; + }; + urgentWorkspace = { + inherit text border; + background = urgent; + }; + bindingMode = { + inherit text border; + background = urgent; + }; }; - activeWorkspace = { - inherit text border; - background = unfocused; - }; - inactiveWorkspace = { - inherit text border; - background = unfocused; - }; - urgentWorkspace = { - inherit text border; - background = urgent; - }; - bindingMode = { - inherit text border; - background = urgent; - }; - }; }; } ]; diff --git a/modules/swaylock/hm.nix b/modules/swaylock/hm.nix index 7bde8960f..9f6481383 100644 --- a/modules/swaylock/hm.nix +++ b/modules/swaylock/hm.nix @@ -1,4 +1,10 @@ -{ pkgs, options, config, lib, ... }: +{ + pkgs, + options, + config, + lib, + ... +}: with config.lib.stylix.colors; @@ -10,7 +16,8 @@ let positive = base0B-hex; negative = base08-hex; -in { +in +{ options.stylix.targets.swaylock = { enable = config.lib.stylix.mkEnableTarget "Swaylock" true; useImage = lib.mkOption { @@ -23,33 +30,42 @@ in { }; }; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.swaylock.enable && pkgs.stdenv.hostPlatform.isLinux) { - programs.swaylock.settings = { - color = outside; - scaling = "fill"; - inside-color = inside; - inside-clear-color = inside; - inside-caps-lock-color = inside; - inside-ver-color = inside; - inside-wrong-color = inside; - key-hl-color = positive; - layout-bg-color = inside; - layout-border-color = ring; - layout-text-color = text; - line-uses-inside = true; - ring-color = ring; - ring-clear-color = negative; - ring-caps-lock-color = ring; - ring-ver-color = positive; - ring-wrong-color = negative; - separator-color = "00000000"; - text-color = text; - text-clear-color = text; - text-caps-lock-color = text; - text-ver-color = text; - text-wrong-color = text; - } // lib.optionalAttrs config.stylix.targets.swaylock.useImage { - image = "${config.stylix.image}"; - }; - }; + config = + lib.mkIf + ( + config.stylix.enable + && config.stylix.targets.swaylock.enable + && pkgs.stdenv.hostPlatform.isLinux + ) + { + programs.swaylock.settings = + { + color = outside; + scaling = "fill"; + inside-color = inside; + inside-clear-color = inside; + inside-caps-lock-color = inside; + inside-ver-color = inside; + inside-wrong-color = inside; + key-hl-color = positive; + layout-bg-color = inside; + layout-border-color = ring; + layout-text-color = text; + line-uses-inside = true; + ring-color = ring; + ring-clear-color = negative; + ring-caps-lock-color = ring; + ring-ver-color = positive; + ring-wrong-color = negative; + separator-color = "00000000"; + text-color = text; + text-clear-color = text; + text-caps-lock-color = text; + text-ver-color = text; + text-wrong-color = text; + } + // lib.optionalAttrs config.stylix.targets.swaylock.useImage { + image = "${config.stylix.image}"; + }; + }; } diff --git a/modules/sxiv/hm.nix b/modules/sxiv/hm.nix index a1695030c..ccd8d8b11 100644 --- a/modules/sxiv/hm.nix +++ b/modules/sxiv/hm.nix @@ -3,9 +3,9 @@ let inherit (config.lib.stylix) colors; inherit (config.stylix) fonts; -in { - options.stylix.targets.sxiv.enable = - config.lib.stylix.mkEnableTarget "Sxiv" true; +in +{ + options.stylix.targets.sxiv.enable = config.lib.stylix.mkEnableTarget "Sxiv" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.sxiv.enable) { xresources = { diff --git a/modules/tmux/hm.nix b/modules/tmux/hm.nix index 16d839c87..f156b72a1 100644 --- a/modules/tmux/hm.nix +++ b/modules/tmux/hm.nix @@ -5,13 +5,13 @@ let templateRepo = config.lib.stylix.templates.base16-tmux; }; -in { - options.stylix.targets.tmux.enable = - config.lib.stylix.mkEnableTarget "Tmux" true; +in +{ + options.stylix.targets.tmux.enable = config.lib.stylix.mkEnableTarget "Tmux" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.tmux.enable) { programs.tmux.extraConfig = '' - source-file ${theme} + source-file ${theme} ''; }; } diff --git a/modules/tofi/hm.nix b/modules/tofi/hm.nix index ce7e4f67c..e03e08895 100644 --- a/modules/tofi/hm.nix +++ b/modules/tofi/hm.nix @@ -1,16 +1,19 @@ -{ config -, lib -, ... +{ + config, + lib, + ... }: with config.stylix.fonts; -with config.lib.stylix.colors.withHashtag; { - options.stylix.targets.tofi.enable = - config.lib.stylix.mkEnableTarget "Tofi" true; +with config.lib.stylix.colors.withHashtag; +{ + options.stylix.targets.tofi.enable = config.lib.stylix.mkEnableTarget "Tofi" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.tofi.enable) { programs.tofi.settings = let - opacity = lib.toHexString (((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100); + opacity = lib.toHexString ( + ((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100 + ); background = base00 + opacity; foreground = base05; darkForeground = base04 + opacity; diff --git a/modules/vesktop/hm.nix b/modules/vesktop/hm.nix index 81241a734..3ff577c5a 100644 --- a/modules/vesktop/hm.nix +++ b/modules/vesktop/hm.nix @@ -8,9 +8,11 @@ in { options.stylix.targets.vesktop.enable = config.lib.stylix.mkEnableTarget "Vesktop" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.vesktop.enable) { - home.file."${config.xdg.configHome}/vesktop/themes/stylix.theme.css" = { - source = themeFile; - }; - }; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.vesktop.enable) + { + home.file."${config.xdg.configHome}/vesktop/themes/stylix.theme.css" = { + source = themeFile; + }; + }; } diff --git a/modules/vim/hm.nix b/modules/vim/hm.nix index 4e23ba432..601b3f4b0 100644 --- a/modules/vim/hm.nix +++ b/modules/vim/hm.nix @@ -1,4 +1,9 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let themeFile = config.lib.stylix.colors { @@ -17,41 +22,45 @@ let ''; }; - vimOptions = let - inherit (config.stylix) fonts; - in { - plugins = [ themePlugin ]; - extraConfig = with config.lib.stylix.colors.withHashtag; '' - set termguicolors - colorscheme base16-stylix - unlet g:colors_name - - let g:stylix_colors = { - \ 'base00': '${base00}', - \ 'base01': '${base01}', - \ 'base02': '${base02}', - \ 'base03': '${base03}', - \ 'base04': '${base04}', - \ 'base05': '${base05}', - \ 'base06': '${base06}', - \ 'base07': '${base07}', - \ 'base08': '${base08}', - \ 'base09': '${base09}', - \ 'base0A': '${base0A}', - \ 'base0B': '${base0B}', - \ 'base0C': '${base0C}', - \ 'base0D': '${base0D}', - \ 'base0E': '${base0E}', - \ 'base0F': '${base0F}', - \ } - - set guifont=${lib.escape [" "] fonts.monospace.name}:h${toString fonts.sizes.terminal} - ''; - }; + vimOptions = + let + inherit (config.stylix) fonts; + in + { + plugins = [ themePlugin ]; + extraConfig = with config.lib.stylix.colors.withHashtag; '' + set termguicolors + colorscheme base16-stylix + unlet g:colors_name + + let g:stylix_colors = { + \ 'base00': '${base00}', + \ 'base01': '${base01}', + \ 'base02': '${base02}', + \ 'base03': '${base03}', + \ 'base04': '${base04}', + \ 'base05': '${base05}', + \ 'base06': '${base06}', + \ 'base07': '${base07}', + \ 'base08': '${base08}', + \ 'base09': '${base09}', + \ 'base0A': '${base0A}', + \ 'base0B': '${base0B}', + \ 'base0C': '${base0C}', + \ 'base0D': '${base0D}', + \ 'base0E': '${base0E}', + \ 'base0F': '${base0F}', + \ } + + set guifont=${ + lib.escape [ " " ] fonts.monospace.name + }:h${toString fonts.sizes.terminal} + ''; + }; -in { - options.stylix.targets.vim.enable = - config.lib.stylix.mkEnableTarget "Vim" true; +in +{ + options.stylix.targets.vim.enable = config.lib.stylix.mkEnableTarget "Vim" true; config = lib.mkIf (config.stylix.enable && config.stylix.targets.vim.enable) { programs.vim = vimOptions; diff --git a/modules/vscode/hm.nix b/modules/vscode/hm.nix index 51d6626fb..eea61adc8 100644 --- a/modules/vscode/hm.nix +++ b/modules/vscode/hm.nix @@ -1,4 +1,9 @@ -{pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: with config.stylix.fonts; @@ -8,29 +13,33 @@ let extension = ".json"; }; - themeExtension = pkgs.runCommandLocal "stylix-vscode" { - vscodeExtUniqueId = "stylix.stylix"; - vscodeExtPublisher = "stylix"; - version = "0.0.0"; - } '' - mkdir -p "$out/share/vscode/extensions/$vscodeExtUniqueId/themes" - ln -s ${./package.json} "$out/share/vscode/extensions/$vscodeExtUniqueId/package.json" - ln -s ${themeFile} "$out/share/vscode/extensions/$vscodeExtUniqueId/themes/stylix.json" - ''; + themeExtension = + pkgs.runCommandLocal "stylix-vscode" + { + vscodeExtUniqueId = "stylix.stylix"; + vscodeExtPublisher = "stylix"; + version = "0.0.0"; + } + '' + mkdir -p "$out/share/vscode/extensions/$vscodeExtUniqueId/themes" + ln -s ${./package.json} "$out/share/vscode/extensions/$vscodeExtUniqueId/package.json" + ln -s ${themeFile} "$out/share/vscode/extensions/$vscodeExtUniqueId/themes/stylix.json" + ''; -in { - options.stylix.targets.vscode.enable = - config.lib.stylix.mkEnableTarget "VSCode" true; +in +{ + options.stylix.targets.vscode.enable = config.lib.stylix.mkEnableTarget "VSCode" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.vscode.enable) { - programs.vscode = { - extensions = [ themeExtension ]; - userSettings = { - "workbench.colorTheme" = "Stylix"; - "terminal.integrated.fontFamily" = "'${monospace.name}'"; - "editor.fontFamily" = "'${monospace.name}'"; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.vscode.enable) + { + programs.vscode = { + extensions = [ themeExtension ]; + userSettings = { + "workbench.colorTheme" = "Stylix"; + "terminal.integrated.fontFamily" = "'${monospace.name}'"; + "editor.fontFamily" = "'${monospace.name}'"; + }; + }; }; - }; - }; } - diff --git a/modules/waybar/hm.nix b/modules/waybar/hm.nix index c39f83fa1..6bbf0b120 100644 --- a/modules/waybar/hm.nix +++ b/modules/waybar/hm.nix @@ -32,31 +32,51 @@ in }; }; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.waybar.enable) { - programs.waybar.style = '' - @define-color base00 ${base00}; @define-color base01 ${base01}; @define-color base02 ${base02}; @define-color base03 ${base03}; - @define-color base04 ${base04}; @define-color base05 ${base05}; @define-color base06 ${base06}; @define-color base07 ${base07}; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.waybar.enable) + { + programs.waybar.style = + '' + @define-color base00 ${base00}; @define-color base01 ${base01}; @define-color base02 ${base02}; @define-color base03 ${base03}; + @define-color base04 ${base04}; @define-color base05 ${base05}; @define-color base06 ${base06}; @define-color base07 ${base07}; - @define-color base08 ${base08}; @define-color base09 ${base09}; @define-color base0A ${base0A}; @define-color base0B ${base0B}; - @define-color base0C ${base0C}; @define-color base0D ${base0D}; @define-color base0E ${base0E}; @define-color base0F ${base0F}; + @define-color base08 ${base08}; @define-color base09 ${base09}; @define-color base0A ${base0A}; @define-color base0B ${base0B}; + @define-color base0C ${base0C}; @define-color base0D ${base0D}; @define-color base0E ${base0E}; @define-color base0F ${base0F}; - * { - font-family: "${sansSerif.name}"; - font-size: ${builtins.toString sizes.desktop}pt; - } + * { + font-family: "${sansSerif.name}"; + font-size: ${builtins.toString sizes.desktop}pt; + } - window#waybar, tooltip { - background: alpha(@base00, ${with config.stylix.opacity; builtins.toString desktop}); - color: @base05; - } + window#waybar, tooltip { + background: alpha(@base00, ${ + with config.stylix.opacity; builtins.toString desktop + }); + color: @base05; + } - tooltip { - border-color: @base0D; - } - '' - + (builtins.readFile ./base.css) - + (if config.stylix.targets.waybar.enableLeftBackColors then (import ./colors.nix "left") else colorlessModules "left") - + (if config.stylix.targets.waybar.enableCenterBackColors then (import ./colors.nix "center") else colorlessModules "center") - + (if config.stylix.targets.waybar.enableRightBackColors then (import ./colors.nix "right") else colorlessModules "right"); - }; + tooltip { + border-color: @base0D; + } + '' + + (builtins.readFile ./base.css) + + ( + if config.stylix.targets.waybar.enableLeftBackColors then + (import ./colors.nix "left") + else + colorlessModules "left" + ) + + ( + if config.stylix.targets.waybar.enableCenterBackColors then + (import ./colors.nix "center") + else + colorlessModules "center" + ) + + ( + if config.stylix.targets.waybar.enableRightBackColors then + (import ./colors.nix "right") + else + colorlessModules "right" + ); + }; } diff --git a/modules/wezterm/hm.nix b/modules/wezterm/hm.nix index 230613e88..0c1bfdba9 100644 --- a/modules/wezterm/hm.nix +++ b/modules/wezterm/hm.nix @@ -1,99 +1,124 @@ { config, lib, ... }: -let colors = config.lib.stylix.colors.withHashtag; -in { - options.stylix.targets.wezterm.enable = - config.lib.stylix.mkEnableTarget "wezterm" true; +let + colors = config.lib.stylix.colors.withHashtag; +in +{ + options.stylix.targets.wezterm.enable = config.lib.stylix.mkEnableTarget "wezterm" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.wezterm.enable && config.programs.wezterm.enable) { + config = + lib.mkIf + ( + config.stylix.enable + && config.stylix.targets.wezterm.enable + && config.programs.wezterm.enable + ) + { - programs.wezterm.colorSchemes.stylix = with colors; { - ansi = [ base00 base08 base0B base0A base0D base0E base0C base05 ]; - brights = [ base03 base08 base0B base0A base0D base0E base0C base07 ]; - background = base00; - cursor_bg = base05; - cursor_fg = base00; - compose_cursor = base06; - foreground = base05; - scrollbar_thumb = base01; - selection_bg = base05; - selection_fg = base00; - split = base03; - visual_bell = base09; - tab_bar = { - background = base01; - inactive_tab_edge = base01; - active_tab = { - bg_color = base00; - fg_color = base05; + programs.wezterm.colorSchemes.stylix = with colors; { + ansi = [ + base00 + base08 + base0B + base0A + base0D + base0E + base0C + base05 + ]; + brights = [ + base03 + base08 + base0B + base0A + base0D + base0E + base0C + base07 + ]; + background = base00; + cursor_bg = base05; + cursor_fg = base00; + compose_cursor = base06; + foreground = base05; + scrollbar_thumb = base01; + selection_bg = base05; + selection_fg = base00; + split = base03; + visual_bell = base09; + tab_bar = { + background = base01; + inactive_tab_edge = base01; + active_tab = { + bg_color = base00; + fg_color = base05; + }; + inactive_tab = { + bg_color = base03; + fg_color = base05; + }; + inactive_tab_hover = { + bg_color = base05; + fg_color = base00; + }; + new_tab = { + bg_color = base03; + fg_color = base05; + }; + new_tab_hover = { + bg_color = base05; + fg_color = base00; + }; + }; }; - inactive_tab = { - bg_color = base03; - fg_color = base05; - }; - inactive_tab_hover = { - bg_color = base05; - fg_color = base00; - }; - new_tab = { - bg_color = base03; - fg_color = base05; - }; - new_tab_hover = { - bg_color = base05; - fg_color = base00; - }; - }; - }; - xdg.configFile."wezterm/wezterm.lua".text = with colors; - with config.stylix.fonts; - lib.mkForce '' - -- Generated by Stylix - local wezterm = require("wezterm") - wezterm.add_to_config_reload_watch_list(wezterm.config_dir) - local function stylix_wrapped_config() - ${config.programs.wezterm.extraConfig} - end - local stylix_base_config = wezterm.config_builder() - local stylix_user_config = stylix_wrapped_config() - stylix_base_config = { - -- Set due to the default fancy tabs not respecting colorschemes - -- See https://github.com/wez/wezterm/issues/2615 - use_fancy_tab_bar = false, - color_scheme = "stylix", - font = wezterm.font_with_fallback { - "${monospace.name}", - "${emoji.name}", - }, - font_size = ${builtins.toString sizes.terminal}, - window_background_opacity = ${ - builtins.toString config.stylix.opacity.terminal - }, - window_frame = { - active_titlebar_bg = "${base03}", - active_titlebar_fg = "${base05}", - active_titlebar_border_bottom = "${base03}", - border_left_color = "${base01}", - border_right_color = "${base01}", - border_bottom_color = "${base01}", - border_top_color = "${base01}", - button_bg = "${base01}", - button_fg = "${base05}", - button_hover_bg = "${base05}", - button_hover_fg = "${base03}", - inactive_titlebar_bg = "${base01}", - inactive_titlebar_fg = "${base05}", - inactive_titlebar_border_bottom = "${base03}", - }, - command_palette_bg_color = "${base01}", - command_palette_fg_color = "${base05}", - command_palette_font_size = ${builtins.toString sizes.popups}, - } - for key, value in pairs(stylix_user_config) do - stylix_base_config[key] = value - end - return stylix_base_config - ''; - }; + xdg.configFile."wezterm/wezterm.lua".text = + with colors; + with config.stylix.fonts; + lib.mkForce '' + -- Generated by Stylix + local wezterm = require("wezterm") + wezterm.add_to_config_reload_watch_list(wezterm.config_dir) + local function stylix_wrapped_config() + ${config.programs.wezterm.extraConfig} + end + local stylix_base_config = wezterm.config_builder() + local stylix_user_config = stylix_wrapped_config() + stylix_base_config = { + -- Set due to the default fancy tabs not respecting colorschemes + -- See https://github.com/wez/wezterm/issues/2615 + use_fancy_tab_bar = false, + color_scheme = "stylix", + font = wezterm.font_with_fallback { + "${monospace.name}", + "${emoji.name}", + }, + font_size = ${builtins.toString sizes.terminal}, + window_background_opacity = ${builtins.toString config.stylix.opacity.terminal}, + window_frame = { + active_titlebar_bg = "${base03}", + active_titlebar_fg = "${base05}", + active_titlebar_border_bottom = "${base03}", + border_left_color = "${base01}", + border_right_color = "${base01}", + border_bottom_color = "${base01}", + border_top_color = "${base01}", + button_bg = "${base01}", + button_fg = "${base05}", + button_hover_bg = "${base05}", + button_hover_fg = "${base03}", + inactive_titlebar_bg = "${base01}", + inactive_titlebar_fg = "${base05}", + inactive_titlebar_border_bottom = "${base03}", + }, + command_palette_bg_color = "${base01}", + command_palette_fg_color = "${base05}", + command_palette_font_size = ${builtins.toString sizes.popups}, + } + for key, value in pairs(stylix_user_config) do + stylix_base_config[key] = value + end + return stylix_base_config + ''; + }; } diff --git a/modules/wofi/hm.nix b/modules/wofi/hm.nix index f8268fc15..d6bbffb1a 100644 --- a/modules/wofi/hm.nix +++ b/modules/wofi/hm.nix @@ -3,11 +3,12 @@ lib, ... }: -with config.stylix.fonts; let +with config.stylix.fonts; +let colors = config.lib.stylix.colors.withHashtag; -in { - options.stylix.targets.wofi.enable = - config.lib.stylix.mkEnableTarget "wofi" config.programs.wofi.enable; +in +{ + options.stylix.targets.wofi.enable = config.lib.stylix.mkEnableTarget "wofi" config.programs.wofi.enable; config = lib.mkIf (config.stylix.enable && config.stylix.targets.wofi.enable) { programs.wofi.style = with colors; '' diff --git a/modules/wpaperd/hm.nix b/modules/wpaperd/hm.nix index 7008593ad..818a99473 100644 --- a/modules/wpaperd/hm.nix +++ b/modules/wpaperd/hm.nix @@ -3,7 +3,9 @@ { options.stylix.targets.wpaperd.enable = config.lib.stylix.mkEnableTarget "wpaperd" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.wpaperd.enable) { - programs.wpaperd.settings.any.path = "${config.stylix.image}"; - }; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.wpaperd.enable) + { + programs.wpaperd.settings.any.path = "${config.stylix.image}"; + }; } diff --git a/modules/xfce/hm.nix b/modules/xfce/hm.nix index 4c8a4389c..7c596fcad 100644 --- a/modules/xfce/hm.nix +++ b/modules/xfce/hm.nix @@ -2,8 +2,7 @@ { # Disabled by default due to https://github.com/danth/stylix/issues/180 - options.stylix.targets.xfce.enable = - config.lib.stylix.mkEnableTarget "Xfce" false; + options.stylix.targets.xfce.enable = config.lib.stylix.mkEnableTarget "Xfce" false; config = lib.mkIf (config.stylix.enable && config.stylix.targets.xfce.enable) { xfconf.settings = with config.stylix.fonts; { diff --git a/modules/xresources/hm.nix b/modules/xresources/hm.nix index 47bce0bd9..ce2a5ee81 100644 --- a/modules/xresources/hm.nix +++ b/modules/xresources/hm.nix @@ -1,33 +1,37 @@ { config, lib, ... }: { - options.stylix.targets.xresources.enable = - config.lib.stylix.mkEnableTarget "Xresources" true; + options.stylix.targets.xresources.enable = config.lib.stylix.mkEnableTarget "Xresources" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.xresources.enable) { - xresources.properties = with config.lib.stylix.colors.withHashtag; with config.stylix.fonts; { - "*.faceName" = monospace.name; - "*.faceSize" = sizes.terminal; - "*.renderFont" = true; - "*foreground" = base05; - "*background" = base00; - "*cursorColor" = base05; - "*color0" = base00; - "*color1" = base08; - "*color2" = base0B; - "*color3" = base0A; - "*color4" = base0D; - "*color5" = base0E; - "*color6" = base0C; - "*color7" = base05; - "*color8" = base03; - "*color9" = base09; - "*color10" = base01; - "*color11" = base02; - "*color12" = base04; - "*color13" = base06; - "*color14" = base0F; - "*color15" = base07; - }; - }; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.xresources.enable) + { + xresources.properties = + with config.lib.stylix.colors.withHashtag; + with config.stylix.fonts; + { + "*.faceName" = monospace.name; + "*.faceSize" = sizes.terminal; + "*.renderFont" = true; + "*foreground" = base05; + "*background" = base00; + "*cursorColor" = base05; + "*color0" = base00; + "*color1" = base08; + "*color2" = base0B; + "*color3" = base0A; + "*color4" = base0D; + "*color5" = base0E; + "*color6" = base0C; + "*color7" = base05; + "*color8" = base03; + "*color9" = base09; + "*color10" = base01; + "*color11" = base02; + "*color12" = base04; + "*color13" = base06; + "*color14" = base0F; + "*color15" = base07; + }; + }; } diff --git a/modules/yazi/hm.nix b/modules/yazi/hm.nix index 7cfe115d9..d8c1117a1 100644 --- a/modules/yazi/hm.nix +++ b/modules/yazi/hm.nix @@ -3,120 +3,136 @@ config, lib, ... -}: { +}: +{ options.stylix.targets.yazi = { enable = config.lib.stylix.mkEnableTarget "Yazi" true; }; config = lib.mkIf (config.stylix.enable && config.stylix.targets.yazi.enable) { - programs.yazi.theme = with config.lib.stylix.colors.withHashtag; let - mkFg = fg: {inherit fg;}; - mkBg = bg: {inherit bg;}; - mkBoth = fg: bg: {inherit fg bg;}; - mkSame = c: (mkBoth c c); - in { - manager = rec { - # Reusing bat themes, since it's suggested in the stying guide - # https://yazi-rs.github.io/docs/configuration/theme#manager - syntect_theme = config.lib.stylix.colors { - template = ../bat/base16-stylix.mustache; - extension = ".tmTheme"; - }; + programs.yazi.theme = + with config.lib.stylix.colors.withHashtag; + let + mkFg = fg: { inherit fg; }; + mkBg = bg: { inherit bg; }; + mkBoth = fg: bg: { inherit fg bg; }; + mkSame = c: (mkBoth c c); + in + { + manager = rec { + # Reusing bat themes, since it's suggested in the stying guide + # https://yazi-rs.github.io/docs/configuration/theme#manager + syntect_theme = config.lib.stylix.colors { + template = ../bat/base16-stylix.mustache; + extension = ".tmTheme"; + }; - cwd = mkFg base0C; - hovered = (mkBoth base05 base03) // {bold = true;}; - preview_hovered = hovered; - find_keyword = (mkFg base0B) // {bold = true;}; - find_position = mkFg base05; - marker_selected = mkSame base0B; - marker_copied = mkSame base0A; - marker_cut = mkSame base08; - tab_active = mkBoth base00 base0D; - tab_inactive = mkBoth base05 base01; - border_style = mkFg base04; - }; + cwd = mkFg base0C; + hovered = (mkBoth base05 base03) // { + bold = true; + }; + preview_hovered = hovered; + find_keyword = (mkFg base0B) // { + bold = true; + }; + find_position = mkFg base05; + marker_selected = mkSame base0B; + marker_copied = mkSame base0A; + marker_cut = mkSame base08; + tab_active = mkBoth base00 base0D; + tab_inactive = mkBoth base05 base01; + border_style = mkFg base04; + }; - status = { - separator_style = mkSame base01; - mode_normal = (mkBoth base00 base0D) // {bold = true;}; - mode_select = (mkBoth base00 base0B) // {bold = true;}; - mode_unset = (mkBoth base00 base0F) // {bold = true;}; - progress_label = mkBoth base05 base00; - progress_normal = mkBoth base05 base00; - progress_error = mkBoth base08 base00; - permissions_t = mkFg base0D; - permissions_r = mkFg base0A; - permissions_w = mkFg base08; - permissions_x = mkFg base0B; - permissions_s = mkFg base0C; - }; + status = { + separator_style = mkSame base01; + mode_normal = (mkBoth base00 base0D) // { + bold = true; + }; + mode_select = (mkBoth base00 base0B) // { + bold = true; + }; + mode_unset = (mkBoth base00 base0F) // { + bold = true; + }; + progress_label = mkBoth base05 base00; + progress_normal = mkBoth base05 base00; + progress_error = mkBoth base08 base00; + permissions_t = mkFg base0D; + permissions_r = mkFg base0A; + permissions_w = mkFg base08; + permissions_x = mkFg base0B; + permissions_s = mkFg base0C; + }; - select = { - border = mkFg base0D; - active = mkFg base0E; - inactive = mkFg base05; - }; + select = { + border = mkFg base0D; + active = mkFg base0E; + inactive = mkFg base05; + }; - input = { - border = mkFg base0D; - title = mkFg base05; - value = mkFg base05; - selected = mkBg base03; - }; + input = { + border = mkFg base0D; + title = mkFg base05; + value = mkFg base05; + selected = mkBg base03; + }; - completion = { - border = mkFg base0D; - active = mkBoth base0E base03; - inactive = mkFg base05; - }; + completion = { + border = mkFg base0D; + active = mkBoth base0E base03; + inactive = mkFg base05; + }; - tasks = { - border = mkFg base0D; - title = mkFg base05; - hovered = mkBoth base05 base03; - }; + tasks = { + border = mkFg base0D; + title = mkFg base05; + hovered = mkBoth base05 base03; + }; - which = { - mask = mkBg base02; - cand = mkFg base0C; - rest = mkFg base0F; - desc = mkFg base05; - separator_style = mkFg base04; - }; + which = { + mask = mkBg base02; + cand = mkFg base0C; + rest = mkFg base0F; + desc = mkFg base05; + separator_style = mkFg base04; + }; - help = { - on = mkFg base0E; - run = mkFg base0C; - desc = mkFg base05; - hovered = mkBoth base05 base03; - footer = mkFg base05; - }; + help = { + on = mkFg base0E; + run = mkFg base0C; + desc = mkFg base05; + hovered = mkBoth base05 base03; + footer = mkFg base05; + }; - # https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/theme.toml - filetype.rules = let - mkRule = mime: fg: {inherit mime fg;}; - in [ - (mkRule "image/*" base0C) - (mkRule "video/*" base0A) - (mkRule "audio/*" base0A) + # https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/theme.toml + filetype.rules = + let + mkRule = mime: fg: { inherit mime fg; }; + in + [ + (mkRule "image/*" base0C) + (mkRule "video/*" base0A) + (mkRule "audio/*" base0A) - (mkRule "application/zip" base0E) - (mkRule "application/gzip" base0E) - (mkRule "application/x-tar" base0E) - (mkRule "application/x-bzip" base0E) - (mkRule "application/x-bzip2" base0E) - (mkRule "application/x-7z-compressed" base0E) - (mkRule "application/x-rar" base0E) - (mkRule "application/xz" base0E) + (mkRule "application/zip" base0E) + (mkRule "application/gzip" base0E) + (mkRule "application/x-tar" base0E) + (mkRule "application/x-bzip" base0E) + (mkRule "application/x-bzip2" base0E) + (mkRule "application/x-7z-compressed" base0E) + (mkRule "application/x-rar" base0E) + (mkRule "application/xz" base0E) - (mkRule "application/doc" base0B) - (mkRule "application/pdf" base0B) - (mkRule "application/rtf" base0B) - (mkRule "application/vnd.*" base0B) + (mkRule "application/doc" base0B) + (mkRule "application/pdf" base0B) + (mkRule "application/rtf" base0B) + (mkRule "application/vnd.*" base0B) - ((mkRule "inode/directory" base0D) // {bold = true;}) - (mkRule "*" base05) - ]; - }; + ((mkRule "inode/directory" base0D) // { bold = true; }) + (mkRule "*" base05) + ]; + }; }; } diff --git a/modules/zathura/hm.nix b/modules/zathura/hm.nix index 35124deef..f27f5148e 100644 --- a/modules/zathura/hm.nix +++ b/modules/zathura/hm.nix @@ -1,38 +1,46 @@ { config, lib, ... }: { - options.stylix.targets.zathura.enable = - config.lib.stylix.mkEnableTarget "Zathura" true; + options.stylix.targets.zathura.enable = config.lib.stylix.mkEnableTarget "Zathura" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.zathura.enable) { - programs.zathura.options = let - highlightTransparency = "0.5"; - getColorCh = colorName: channel: config.lib.stylix.colors."${colorName}-rgb-${channel}"; - rgb = color: ''rgb(${getColorCh color "r"}, ${getColorCh color "g"}, ${getColorCh color "b"})''; - rgba = color: ''rgba(${getColorCh color "r"}, ${getColorCh color "g"}, ${getColorCh color "b"}, ${highlightTransparency})''; - in { - # Taken from here: - # https://github.com/doenerkebap/base16-zathura - default-bg = rgb "base00"; - default-fg = rgb "base01"; - statusbar-fg = rgb "base04"; - statusbar-bg = rgb "base02"; - inputbar-bg = rgb "base00"; - inputbar-fg = rgb "base07"; - notification-bg = rgb "base00"; - notification-fg = rgb "base07"; - notification-error-bg = rgb "base00"; - notification-error-fg = rgb "base08"; - notification-warning-bg = rgb "base00"; - notification-warning-fg = rgb "base08"; - highlight-color = rgba "base0A"; - highlight-active-color = rgba "base0D"; - completion-bg = rgb "base01"; - completion-fg = rgb "base0D"; - completion-highlight-fg = rgb "base07"; - completion-highlight-bg = rgb "base0D"; - recolor-lightcolor = rgb "base00"; - recolor-darkcolor = rgb "base06"; - }; - }; + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.zathura.enable) + { + programs.zathura.options = + let + highlightTransparency = "0.5"; + getColorCh = + colorName: channel: config.lib.stylix.colors."${colorName}-rgb-${channel}"; + rgb = + color: + ''rgb(${getColorCh color "r"}, ${getColorCh color "g"}, ${getColorCh color "b"})''; + rgba = + color: + ''rgba(${getColorCh color "r"}, ${getColorCh color "g"}, ${getColorCh color "b"}, ${highlightTransparency})''; + in + { + # Taken from here: + # https://github.com/doenerkebap/base16-zathura + default-bg = rgb "base00"; + default-fg = rgb "base01"; + statusbar-fg = rgb "base04"; + statusbar-bg = rgb "base02"; + inputbar-bg = rgb "base00"; + inputbar-fg = rgb "base07"; + notification-bg = rgb "base00"; + notification-fg = rgb "base07"; + notification-error-bg = rgb "base00"; + notification-error-fg = rgb "base08"; + notification-warning-bg = rgb "base00"; + notification-warning-fg = rgb "base08"; + highlight-color = rgba "base0A"; + highlight-active-color = rgba "base0D"; + completion-bg = rgb "base01"; + completion-fg = rgb "base0D"; + completion-highlight-fg = rgb "base07"; + completion-highlight-bg = rgb "base0D"; + recolor-lightcolor = rgb "base00"; + recolor-darkcolor = rgb "base06"; + }; + }; } diff --git a/modules/zellij/hm.nix b/modules/zellij/hm.nix index 886603dc3..3c914a968 100644 --- a/modules/zellij/hm.nix +++ b/modules/zellij/hm.nix @@ -1,13 +1,14 @@ { config, lib, ... }: { - options.stylix.targets.zellij.enable = - config.lib.stylix.mkEnableTarget "zellij" true; + options.stylix.targets.zellij.enable = config.lib.stylix.mkEnableTarget "zellij" true; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.zellij.enable) { - programs.zellij.settings = { - theme = "stylix"; - themes.stylix = with config.lib.stylix.colors.withHashtag; { + config = + lib.mkIf (config.stylix.enable && config.stylix.targets.zellij.enable) + { + programs.zellij.settings = { + theme = "stylix"; + themes.stylix = with config.lib.stylix.colors.withHashtag; { bg = base03; fg = base05; red = base08; @@ -19,8 +20,8 @@ cyan = base0C; black = base00; white = base07; + }; }; - }; - }; + }; } diff --git a/palette-generator/default.nix b/palette-generator/default.nix index 0bde88779..6a07c37f7 100644 --- a/palette-generator/default.nix +++ b/palette-generator/default.nix @@ -1,12 +1,14 @@ { haskellPackages, stdenvNoCC }: let - ghc = haskellPackages.ghcWithPackages (ps: with ps; [ - JuicyPixels - json - random - vector-algorithms - ]); + ghc = haskellPackages.ghcWithPackages ( + ps: with ps; [ + JuicyPixels + json + random + vector-algorithms + ] + ); # `nix build .#palette-generator.passthru.docs` and open in a web browser docs = stdenvNoCC.mkDerivation { @@ -22,7 +24,8 @@ let dontFixup = true; }; -in stdenvNoCC.mkDerivation { +in +stdenvNoCC.mkDerivation { name = "palette-generator"; src = ./.; @@ -35,5 +38,7 @@ in stdenvNoCC.mkDerivation { install -D Stylix/Main $out/bin/palette-generator ''; - passthru = { inherit docs; }; + passthru = { + inherit docs; + }; } diff --git a/stylix/autoload.nix b/stylix/autoload.nix index bfb2fe687..b1ec53f80 100644 --- a/stylix/autoload.nix +++ b/stylix/autoload.nix @@ -3,12 +3,15 @@ # string -> [ path ] # List include path for either nixos modules or hm modules for: - builtins.concatLists - (lib.mapAttrsToList - (path: kind: - if kind == "directory" - then let - file = "${../modules}/${path}/${for}.nix"; - in if builtins.pathExists file then [ file ] else [ ] - else [ ]) - (builtins.readDir ../modules)) +builtins.concatLists ( + lib.mapAttrsToList ( + path: kind: + if kind == "directory" then + let + file = "${../modules}/${path}/${for}.nix"; + in + if builtins.pathExists file then [ file ] else [ ] + else + [ ] + ) (builtins.readDir ../modules) +) diff --git a/stylix/cursor.nix b/stylix/cursor.nix index fadbd3670..412cf6782 100644 --- a/stylix/cursor.nix +++ b/stylix/cursor.nix @@ -1,21 +1,21 @@ { pkgs, lib, ... }: { - options.stylix.cursor = { - name = lib.mkOption { - description = "The cursor name within the package."; - type = lib.types.str; - default = "Vanilla-DMZ"; - }; - package = lib.mkOption { - description = "Package providing the cursor theme."; - type = lib.types.package; - default = pkgs.vanilla-dmz; - }; - size = lib.mkOption { - description = "The cursor size."; - type = lib.types.int; - default = 32; - }; + options.stylix.cursor = { + name = lib.mkOption { + description = "The cursor name within the package."; + type = lib.types.str; + default = "Vanilla-DMZ"; }; + package = lib.mkOption { + description = "Package providing the cursor theme."; + type = lib.types.package; + default = pkgs.vanilla-dmz; + }; + size = lib.mkOption { + description = "The cursor size."; + type = lib.types.int; + default = 32; + }; + }; } diff --git a/stylix/darwin/default.nix b/stylix/darwin/default.nix index 19e7c6e12..fae88e060 100644 --- a/stylix/darwin/default.nix +++ b/stylix/darwin/default.nix @@ -1,10 +1,15 @@ inputs: -{ palette-generator, base16, homeManagerModule }: +{ + palette-generator, + base16, + homeManagerModule, +}: { lib, ... }: let autoload = import ../autoload.nix { inherit lib; } "darwin"; -in { +in +{ imports = [ ../pixel.nix ../target.nix diff --git a/stylix/darwin/fonts.nix b/stylix/darwin/fonts.nix index eff55ea30..ed72158ff 100644 --- a/stylix/darwin/fonts.nix +++ b/stylix/darwin/fonts.nix @@ -2,7 +2,8 @@ let cfg = config.stylix.fonts; -in { +in +{ imports = [ ../fonts.nix ]; config.fonts = lib.mkIf config.stylix.enable { inherit (cfg) packages; diff --git a/stylix/fonts.nix b/stylix/fonts.nix index 07e10c54b..b85062c46 100644 --- a/stylix/fonts.nix +++ b/stylix/fonts.nix @@ -1,4 +1,9 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let cfg = config.stylix.fonts; @@ -17,7 +22,8 @@ let }; }; -in { +in +{ options.stylix.fonts = { serif = lib.mkOption { description = "Serif font."; diff --git a/stylix/hm/cursor.nix b/stylix/hm/cursor.nix index dd2794710..a8217427a 100644 --- a/stylix/hm/cursor.nix +++ b/stylix/hm/cursor.nix @@ -1,9 +1,15 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let cfg = config.stylix.cursor; -in { +in +{ imports = [ ../cursor.nix ]; config = lib.mkIf (config.stylix.enable && pkgs.stdenv.hostPlatform.isLinux) { diff --git a/stylix/hm/default.nix b/stylix/hm/default.nix index a5cae1774..41ff73bdd 100644 --- a/stylix/hm/default.nix +++ b/stylix/hm/default.nix @@ -4,7 +4,8 @@ inputs: let autoload = import ../autoload.nix { inherit lib; } "hm"; -in { +in +{ imports = [ ../pixel.nix ../target.nix diff --git a/stylix/hm/fonts.nix b/stylix/hm/fonts.nix index 98f572c57..a7b46e6f2 100644 --- a/stylix/hm/fonts.nix +++ b/stylix/hm/fonts.nix @@ -2,7 +2,8 @@ let cfg = config.stylix.fonts; -in { +in +{ imports = [ ../fonts.nix ]; config = lib.mkIf config.stylix.enable { fonts.fontconfig.enable = true; diff --git a/stylix/home-manager-integration.nix b/stylix/home-manager-integration.nix index 5afe202b1..eb4a3bb02 100644 --- a/stylix/home-manager-integration.nix +++ b/stylix/home-manager-integration.nix @@ -1,46 +1,183 @@ homeManagerModule: -{ lib, config, options, ... }: +{ + lib, + config, + options, + ... +}: let - copyModules = builtins.map - ( - { path, condition ? lib.const true }: - { config, osConfig, ... }: - lib.mkIf (condition config) - (lib.setAttrByPath path (lib.mkDefault (lib.getAttrFromPath path osConfig))) - ) - [ - { path = [ "stylix" "autoEnable" ]; } - { - path = [ "stylix" "base16Scheme" ]; - condition = homeConfig: config.stylix.image == homeConfig.stylix.image; - } - { path = [ "stylix" "cursor" "name" ]; } - { path = [ "stylix" "cursor" "package" ]; } - { path = [ "stylix" "cursor" "size" ]; } - { path = [ "stylix" "enable" ]; } - { path = [ "stylix" "fonts" "serif" ]; } - { path = [ "stylix" "fonts" "sansSerif" ]; } - { path = [ "stylix" "fonts" "monospace" ]; } - { path = [ "stylix" "fonts" "emoji" ]; } - { path = [ "stylix" "fonts" "sizes" "desktop" ]; } - { path = [ "stylix" "fonts" "sizes" "applications" ]; } - { path = [ "stylix" "fonts" "sizes" "terminal" ]; } - { path = [ "stylix" "fonts" "sizes" "popups" ]; } - { path = [ "stylix" "image" ]; } - { path = [ "stylix" "imageScalingMode" ]; } - { path = [ "stylix" "opacity" "desktop" ]; } - { path = [ "stylix" "opacity" "applications" ]; } - { path = [ "stylix" "opacity" "terminal" ]; } - { path = [ "stylix" "opacity" "popups" ]; } - { - path = [ "stylix" "override" ]; - condition = homeConfig: config.stylix.base16Scheme == homeConfig.stylix.base16Scheme; - } - { path = [ "stylix" "polarity" ]; } - ]; + copyModules = + builtins.map + ( + { + path, + condition ? lib.const true, + }: + { config, osConfig, ... }: + lib.mkIf (condition config) ( + lib.setAttrByPath path (lib.mkDefault (lib.getAttrFromPath path osConfig)) + ) + ) + [ + { + path = [ + "stylix" + "autoEnable" + ]; + } + { + path = [ + "stylix" + "base16Scheme" + ]; + condition = homeConfig: config.stylix.image == homeConfig.stylix.image; + } + { + path = [ + "stylix" + "cursor" + "name" + ]; + } + { + path = [ + "stylix" + "cursor" + "package" + ]; + } + { + path = [ + "stylix" + "cursor" + "size" + ]; + } + { + path = [ + "stylix" + "enable" + ]; + } + { + path = [ + "stylix" + "fonts" + "serif" + ]; + } + { + path = [ + "stylix" + "fonts" + "sansSerif" + ]; + } + { + path = [ + "stylix" + "fonts" + "monospace" + ]; + } + { + path = [ + "stylix" + "fonts" + "emoji" + ]; + } + { + path = [ + "stylix" + "fonts" + "sizes" + "desktop" + ]; + } + { + path = [ + "stylix" + "fonts" + "sizes" + "applications" + ]; + } + { + path = [ + "stylix" + "fonts" + "sizes" + "terminal" + ]; + } + { + path = [ + "stylix" + "fonts" + "sizes" + "popups" + ]; + } + { + path = [ + "stylix" + "image" + ]; + } + { + path = [ + "stylix" + "imageScalingMode" + ]; + } + { + path = [ + "stylix" + "opacity" + "desktop" + ]; + } + { + path = [ + "stylix" + "opacity" + "applications" + ]; + } + { + path = [ + "stylix" + "opacity" + "terminal" + ]; + } + { + path = [ + "stylix" + "opacity" + "popups" + ]; + } + { + path = [ + "stylix" + "override" + ]; + condition = + homeConfig: config.stylix.base16Scheme == homeConfig.stylix.base16Scheme; + } + { + path = [ + "stylix" + "polarity" + ]; + } + ]; -in { +in +{ options.stylix.homeManagerIntegration = { followSystem = lib.mkOption { description = '' @@ -69,11 +206,11 @@ in { }; }; - config = - lib.optionalAttrs (options ? home-manager) - (lib.mkIf config.stylix.homeManagerIntegration.autoImport { + config = lib.optionalAttrs (options ? home-manager) ( + lib.mkIf config.stylix.homeManagerIntegration.autoImport { home-manager.sharedModules = - [ homeManagerModule ] ++ - (lib.optionals config.stylix.homeManagerIntegration.followSystem copyModules); - }); + [ homeManagerModule ] + ++ (lib.optionals config.stylix.homeManagerIntegration.followSystem copyModules); + } + ); } diff --git a/stylix/nixos/cursor.nix b/stylix/nixos/cursor.nix index bc200e4a0..576ad544a 100644 --- a/stylix/nixos/cursor.nix +++ b/stylix/nixos/cursor.nix @@ -2,7 +2,8 @@ let cfg = config.stylix.cursor; -in { +in +{ imports = [ ../cursor.nix ]; config = lib.mkIf config.stylix.enable { environment.variables.XCURSOR_SIZE = toString cfg.size; diff --git a/stylix/nixos/default.nix b/stylix/nixos/default.nix index 56c4741b5..627e15826 100644 --- a/stylix/nixos/default.nix +++ b/stylix/nixos/default.nix @@ -1,10 +1,15 @@ inputs: -{ palette-generator, base16, homeManagerModule }: +{ + palette-generator, + base16, + homeManagerModule, +}: { lib, ... }: let autoload = import ../autoload.nix { inherit lib; } "nixos"; -in { +in +{ imports = [ ../pixel.nix ../target.nix diff --git a/stylix/nixos/fonts.nix b/stylix/nixos/fonts.nix index 495c842cd..571a527b7 100644 --- a/stylix/nixos/fonts.nix +++ b/stylix/nixos/fonts.nix @@ -2,7 +2,8 @@ let cfg = config.stylix.fonts; -in { +in +{ imports = [ ../fonts.nix ]; config.fonts = lib.mkIf config.stylix.enable { inherit (cfg) packages; diff --git a/stylix/opacity.nix b/stylix/opacity.nix index 88d68392a..5fe4871ab 100644 --- a/stylix/opacity.nix +++ b/stylix/opacity.nix @@ -1,26 +1,26 @@ { lib, ... }: { - options.stylix.opacity = { - desktop = lib.mkOption { - description = "The opacity of the windows of bars/widgets, the amount of applications supported is currently limited"; - type = lib.types.float; - default = 1.0; - }; - applications = lib.mkOption { - description = "The opacity of the windows of applications, the amount of applications supported is currently limited"; - type = lib.types.float; - default = 1.0; - }; - terminal = lib.mkOption { - description = "The opacity of the windows of terminals, this works across all terminals supported by stylix"; - type = lib.types.float; - default = 1.0; - }; - popups = lib.mkOption { - description = "The opacity of the windows of notifications/popups, the amount of applications supported is currently limited"; - type = lib.types.float; - default = 1.0; - }; + options.stylix.opacity = { + desktop = lib.mkOption { + description = "The opacity of the windows of bars/widgets, the amount of applications supported is currently limited"; + type = lib.types.float; + default = 1.0; }; + applications = lib.mkOption { + description = "The opacity of the windows of applications, the amount of applications supported is currently limited"; + type = lib.types.float; + default = 1.0; + }; + terminal = lib.mkOption { + description = "The opacity of the windows of terminals, this works across all terminals supported by stylix"; + type = lib.types.float; + default = 1.0; + }; + popups = lib.mkOption { + description = "The opacity of the windows of notifications/popups, the amount of applications supported is currently limited"; + type = lib.types.float; + default = 1.0; + }; + }; } diff --git a/stylix/palette.nix b/stylix/palette.nix index a6ae3da13..f7987ba2c 100644 --- a/stylix/palette.nix +++ b/stylix/palette.nix @@ -1,80 +1,156 @@ { palette-generator, base16 }: -{ pkgs, lib, config, ... }: +{ + pkgs, + lib, + config, + ... +}: let cfg = config.stylix; - paletteJSON = let - generatedJSON = pkgs.runCommand "palette.json" { } '' - ${palette-generator}/bin/palette-generator \ - "${cfg.polarity}" \ - ${lib.escapeShellArg "${cfg.image}"} \ - "$out" - ''; - palette = lib.importJSON generatedJSON; - scheme = base16.mkSchemeAttrs palette; - json = scheme { - template = ./palette.json.mustache; - extension = ".json"; - }; - in json; + paletteJSON = + let + generatedJSON = pkgs.runCommand "palette.json" { } '' + ${palette-generator}/bin/palette-generator \ + "${cfg.polarity}" \ + ${lib.escapeShellArg "${cfg.image}"} \ + "$out" + ''; + palette = lib.importJSON generatedJSON; + scheme = base16.mkSchemeAttrs palette; + json = scheme { + template = ./palette.json.mustache; + extension = ".json"; + }; + in + json; generatedScheme = lib.importJSON paletteJSON; -in { +in +{ # TODO link to doc on how to do instead imports = [ # Added: 2023-02-02 - (lib.mkRemovedOptionModule [ "stylix" "palette" "base00" ] "Using stylix.palette to override scheme is not supported anymore") + (lib.mkRemovedOptionModule [ + "stylix" + "palette" + "base00" + ] "Using stylix.palette to override scheme is not supported anymore") # Added: 2023-02-02 - (lib.mkRemovedOptionModule [ "stylix" "palette" "base01" ] "Using stylix.palette to override scheme is not supported anymore") + (lib.mkRemovedOptionModule [ + "stylix" + "palette" + "base01" + ] "Using stylix.palette to override scheme is not supported anymore") # Added: 2023-02-02 - (lib.mkRemovedOptionModule [ "stylix" "palette" "base02" ] "Using stylix.palette to override scheme is not supported anymore") + (lib.mkRemovedOptionModule [ + "stylix" + "palette" + "base02" + ] "Using stylix.palette to override scheme is not supported anymore") # Added: 2023-02-02 - (lib.mkRemovedOptionModule [ "stylix" "palette" "base03" ] "Using stylix.palette to override scheme is not supported anymore") + (lib.mkRemovedOptionModule [ + "stylix" + "palette" + "base03" + ] "Using stylix.palette to override scheme is not supported anymore") # Added: 2023-02-02 - (lib.mkRemovedOptionModule [ "stylix" "palette" "base04" ] "Using stylix.palette to override scheme is not supported anymore") + (lib.mkRemovedOptionModule [ + "stylix" + "palette" + "base04" + ] "Using stylix.palette to override scheme is not supported anymore") # Added: 2023-02-02 - (lib.mkRemovedOptionModule [ "stylix" "palette" "base05" ] "Using stylix.palette to override scheme is not supported anymore") + (lib.mkRemovedOptionModule [ + "stylix" + "palette" + "base05" + ] "Using stylix.palette to override scheme is not supported anymore") # Added: 2023-02-02 - (lib.mkRemovedOptionModule [ "stylix" "palette" "base06" ] "Using stylix.palette to override scheme is not supported anymore") + (lib.mkRemovedOptionModule [ + "stylix" + "palette" + "base06" + ] "Using stylix.palette to override scheme is not supported anymore") # Added: 2023-02-02 - (lib.mkRemovedOptionModule [ "stylix" "palette" "base07" ] "Using stylix.palette to override scheme is not supported anymore") + (lib.mkRemovedOptionModule [ + "stylix" + "palette" + "base07" + ] "Using stylix.palette to override scheme is not supported anymore") # Added: 2023-02-02 - (lib.mkRemovedOptionModule [ "stylix" "palette" "base08" ] "Using stylix.palette to override scheme is not supported anymore") + (lib.mkRemovedOptionModule [ + "stylix" + "palette" + "base08" + ] "Using stylix.palette to override scheme is not supported anymore") # Added: 2023-02-02 - (lib.mkRemovedOptionModule [ "stylix" "palette" "base09" ] "Using stylix.palette to override scheme is not supported anymore") + (lib.mkRemovedOptionModule [ + "stylix" + "palette" + "base09" + ] "Using stylix.palette to override scheme is not supported anymore") # Added: 2023-02-02 - (lib.mkRemovedOptionModule [ "stylix" "palette" "base0A" ] "Using stylix.palette to override scheme is not supported anymore") + (lib.mkRemovedOptionModule [ + "stylix" + "palette" + "base0A" + ] "Using stylix.palette to override scheme is not supported anymore") # Added: 2023-02-02 - (lib.mkRemovedOptionModule [ "stylix" "palette" "base0B" ] "Using stylix.palette to override scheme is not supported anymore") + (lib.mkRemovedOptionModule [ + "stylix" + "palette" + "base0B" + ] "Using stylix.palette to override scheme is not supported anymore") # Added: 2023-02-02 - (lib.mkRemovedOptionModule [ "stylix" "palette" "base0C" ] "Using stylix.palette to override scheme is not supported anymore") + (lib.mkRemovedOptionModule [ + "stylix" + "palette" + "base0C" + ] "Using stylix.palette to override scheme is not supported anymore") # Added: 2023-02-02 - (lib.mkRemovedOptionModule [ "stylix" "palette" "base0D" ] "Using stylix.palette to override scheme is not supported anymore") + (lib.mkRemovedOptionModule [ + "stylix" + "palette" + "base0D" + ] "Using stylix.palette to override scheme is not supported anymore") # Added: 2023-02-02 - (lib.mkRemovedOptionModule [ "stylix" "palette" "base0E" ] "Using stylix.palette to override scheme is not supported anymore") + (lib.mkRemovedOptionModule [ + "stylix" + "palette" + "base0E" + ] "Using stylix.palette to override scheme is not supported anymore") # Added: 2023-02-02 - (lib.mkRemovedOptionModule [ "stylix" "palette" "base0F" ] "Using stylix.palette to override scheme is not supported anymore") + (lib.mkRemovedOptionModule [ + "stylix" + "palette" + "base0F" + ] "Using stylix.palette to override scheme is not supported anymore") ]; options.stylix = { polarity = lib.mkOption { - type = lib.types.enum [ "either" "light" "dark" ]; + type = lib.types.enum [ + "either" + "light" + "dark" + ]; default = "either"; description = '' Use this option to force a light or dark theme. @@ -96,7 +172,13 @@ in { }; imageScalingMode = lib.mkOption { - type = lib.types.enum [ "stretch" "fill" "fit" "center" "tile" ]; + type = lib.types.enum [ + "stretch" + "fill" + "fit" + "center" + "tile" + ]; default = "fill"; description = '' Wallpaper scaling mode; @@ -137,7 +219,13 @@ in { This can be a path to a file, a string of YAML, or an attribute set. ''; - type = with lib.types; oneOf [ path lines attrs ]; + type = + with lib.types; + oneOf [ + path + lines + attrs + ]; default = generatedScheme; defaultText = lib.literalMD '' The colors used in the theming. @@ -156,7 +244,7 @@ in { to override. ''; type = lib.types.attrs; - default = {}; + default = { }; }; }; diff --git a/stylix/pixel.nix b/stylix/pixel.nix index 7c1049286..212933fe6 100644 --- a/stylix/pixel.nix +++ b/stylix/pixel.nix @@ -2,7 +2,8 @@ { # Generate a PNG image containing a named color - config.lib.stylix.pixel = color: + config.lib.stylix.pixel = + color: pkgs.runCommand "${color}-pixel.png" { color = config.lib.stylix.colors.withHashtag.${color}; } "${pkgs.imagemagick}/bin/convert xc:$color png32:$out"; diff --git a/stylix/target.nix b/stylix/target.nix index c1908da82..a3d5056e4 100644 --- a/stylix/target.nix +++ b/stylix/target.nix @@ -31,18 +31,17 @@ }; }; - config.lib.stylix.mkEnableTarget = let - cfg = config.stylix; - in - humanName: - autoEnable: - lib.mkEnableOption - "theming for ${humanName}" - // { - default = cfg.enable && cfg.autoEnable && autoEnable; - example = !autoEnable; - } - // lib.optionalAttrs autoEnable { - defaultText = lib.literalMD "same as [`stylix.autoEnable`](#stylixautoenable)"; - }; + config.lib.stylix.mkEnableTarget = + let + cfg = config.stylix; + in + humanName: autoEnable: + lib.mkEnableOption "theming for ${humanName}" + // { + default = cfg.enable && cfg.autoEnable && autoEnable; + example = !autoEnable; + } + // lib.optionalAttrs autoEnable { + defaultText = lib.literalMD "same as [`stylix.autoEnable`](#stylixautoenable)"; + }; } diff --git a/stylix/templates.nix b/stylix/templates.nix index 8b8b9b159..176288731 100644 --- a/stylix/templates.nix +++ b/stylix/templates.nix @@ -1,5 +1,4 @@ -inputs: -{ +inputs: { config.lib.stylix.templates = { inherit (inputs) base16-fish diff --git a/stylix/testbed.nix b/stylix/testbed.nix index 4cd6c7c86..1097c5eda 100644 --- a/stylix/testbed.nix +++ b/stylix/testbed.nix @@ -1,41 +1,49 @@ -{ pkgs, inputs, lib, ... }: +{ + pkgs, + inputs, + lib, + ... +}: let username = "guest"; - commonModule = { config, ... }: { - users.users.${username} = { - description = "Guest"; - hashedPassword = ""; - isNormalUser = true; - extraGroups = [ "wheel" ]; - }; + commonModule = + { config, ... }: + { + users.users.${username} = { + description = "Guest"; + hashedPassword = ""; + isNormalUser = true; + extraGroups = [ "wheel" ]; + }; - security.sudo.wheelNeedsPassword = false; + security.sudo.wheelNeedsPassword = false; - # The state version can safely track the latest release because the disk - # image is ephemeral. - system.stateVersion = config.system.nixos.release; - home-manager.users.${username}.home.stateVersion = config.system.nixos.release; + # The state version can safely track the latest release because the disk + # image is ephemeral. + system.stateVersion = config.system.nixos.release; + home-manager.users.${username}.home.stateVersion = config.system.nixos.release; - virtualisation.vmVariant.virtualisation = { - # This is a maximum limit; the VM should still work if the host has fewer cores. - cores = 4; - memorySize = lib.mkDefault 2048; + virtualisation.vmVariant.virtualisation = { + # This is a maximum limit; the VM should still work if the host has fewer cores. + cores = 4; + memorySize = lib.mkDefault 2048; + }; }; - }; - autoload = builtins.concatLists - (lib.mapAttrsToList - (name: _: - let testbed = { + autoload = builtins.concatLists ( + lib.mapAttrsToList ( + name: _: + let + testbed = { inherit name; module = "${../modules}/${name}/testbed.nix"; }; - in - lib.optional (builtins.pathExists testbed.module) testbed - ) - (builtins.readDir ../modules)); + in + lib.optional (builtins.pathExists testbed.module) testbed + ) (builtins.readDir ../modules) + ); makeTestbed = testbed: stylix: @@ -77,31 +85,33 @@ let ''; }; in - lib.nameValuePair name script; + lib.nameValuePair name script; # This generates a copy of each testbed for each of the following themes. - makeTestbeds = testbed: map (makeTestbed testbed) [ - { - enable = true; - image = pkgs.fetchurl { - name = "three-bicycles.jpg"; - url = "https://unsplash.com/photos/hwLAI5lRhdM/download?ixid=M3wxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNzE2MzYxNDcwfA&force=true"; - hash = "sha256-S0MumuBGJulUekoGI2oZfUa/50Jw0ZzkqDDu1nRkFUA="; - }; - base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-latte.yaml"; - polarity = "light"; - } - { - enable = true; - image = pkgs.fetchurl { - name = "mountains.jpg"; - url = "https://unsplash.com/photos/ZqLeQDjY6fY/download?ixid=M3wxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNzE2MzY1NDY4fA&force=true"; - hash = "sha256-Dm/0nKiTFOzNtSiARnVg7zM0J1o+EuIdUQ3OAuasM58="; - }; - base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-macchiato.yaml"; - polarity = "dark"; - } - ]; + makeTestbeds = + testbed: + map (makeTestbed testbed) [ + { + enable = true; + image = pkgs.fetchurl { + name = "three-bicycles.jpg"; + url = "https://unsplash.com/photos/hwLAI5lRhdM/download?ixid=M3wxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNzE2MzYxNDcwfA&force=true"; + hash = "sha256-S0MumuBGJulUekoGI2oZfUa/50Jw0ZzkqDDu1nRkFUA="; + }; + base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-latte.yaml"; + polarity = "light"; + } + { + enable = true; + image = pkgs.fetchurl { + name = "mountains.jpg"; + url = "https://unsplash.com/photos/ZqLeQDjY6fY/download?ixid=M3wxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNzE2MzY1NDY4fA&force=true"; + hash = "sha256-Dm/0nKiTFOzNtSiARnVg7zM0J1o+EuIdUQ3OAuasM58="; + }; + base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-macchiato.yaml"; + polarity = "dark"; + } + ]; in - lib.listToAttrs (lib.flatten (map makeTestbeds autoload)) +lib.listToAttrs (lib.flatten (map makeTestbeds autoload))