From fbad7b1b0c37c83b3b9c7dfb76eb761ed26974c0 Mon Sep 17 00:00:00 2001 From: DwarfMaster Date: Mon, 30 Jan 2023 22:56:57 +0100 Subject: [PATCH] Refactor modules to separate nixos from hm code --- flake.nix | 23 -- modules/{alacritty.nix => alacritty/hm.nix} | 16 +- modules/{bemenu.nix => bemenu/hm.nix} | 4 +- modules/{chromium.nix => chromium/nixos.nix} | 0 modules/{console.nix => console/nixos.nix} | 0 modules/dunst.nix | 38 ---- modules/dunst/hm.nix | 36 ++++ modules/{feh.nix => feh/nixos.nix} | 0 modules/fish.nix | 29 --- modules/fish/hm.nix | 10 + modules/fish/nixos.nix | 10 + modules/fish/prompt.nix | 15 ++ modules/gedit/{default.nix => hm.nix} | 8 +- modules/gnome/hm.nix | 27 +++ modules/gnome/{default.nix => nixos.nix} | 19 -- modules/{grub.nix => grub/nixos.nix} | 0 modules/gtk/default.nix | 33 --- modules/gtk/hm.nix | 29 +++ modules/gtk/nixos.nix | 11 + modules/{helix.nix => helix/hm.nix} | 10 +- modules/{i3.nix => i3/hm.nix} | 68 +++--- modules/k9s.nix | 129 ----------- modules/k9s/hm.nix | 126 +++++++++++ modules/kitty.nix | 48 ----- modules/kitty/hm.nix | 46 ++++ modules/{lightdm.nix => lightdm/nixos.nix} | 0 modules/{mako.nix => mako/hm.nix} | 4 +- modules/plymouth/{default.nix => nixos.nix} | 0 modules/qutebrowser.nix | 215 ------------------- modules/qutebrowser/hm.nix | 213 ++++++++++++++++++ modules/{sway.nix => sway/hm.nix} | 70 +++--- modules/swaylock.nix | 64 ------ modules/swaylock/hm.nix | 58 +++++ modules/{vim.nix => vim/hm.nix} | 6 +- modules/vscode/{default.nix => hm.nix} | 10 +- stylix/autoload.nix | 14 ++ stylix/hm/default.nix | 3 +- stylix/nixos/default.nix | 5 +- 38 files changed, 695 insertions(+), 702 deletions(-) rename modules/{alacritty.nix => alacritty/hm.nix} (69%) rename modules/{bemenu.nix => bemenu/hm.nix} (93%) rename modules/{chromium.nix => chromium/nixos.nix} (100%) rename modules/{console.nix => console/nixos.nix} (100%) delete mode 100644 modules/dunst.nix create mode 100644 modules/dunst/hm.nix rename modules/{feh.nix => feh/nixos.nix} (100%) delete mode 100644 modules/fish.nix create mode 100644 modules/fish/hm.nix create mode 100644 modules/fish/nixos.nix create mode 100644 modules/fish/prompt.nix rename modules/gedit/{default.nix => hm.nix} (71%) create mode 100644 modules/gnome/hm.nix rename modules/gnome/{default.nix => nixos.nix} (66%) rename modules/{grub.nix => grub/nixos.nix} (100%) delete mode 100644 modules/gtk/default.nix create mode 100644 modules/gtk/hm.nix create mode 100644 modules/gtk/nixos.nix rename modules/{helix.nix => helix/hm.nix} (93%) rename modules/{i3.nix => i3/hm.nix} (59%) delete mode 100644 modules/k9s.nix create mode 100644 modules/k9s/hm.nix delete mode 100644 modules/kitty.nix create mode 100644 modules/kitty/hm.nix rename modules/{lightdm.nix => lightdm/nixos.nix} (100%) rename modules/{mako.nix => mako/hm.nix} (89%) rename modules/plymouth/{default.nix => nixos.nix} (100%) delete mode 100644 modules/qutebrowser.nix create mode 100644 modules/qutebrowser/hm.nix rename modules/{sway.nix => sway/hm.nix} (58%) delete mode 100644 modules/swaylock.nix create mode 100644 modules/swaylock/hm.nix rename modules/{vim.nix => vim/hm.nix} (89%) rename modules/vscode/{default.nix => hm.nix} (87%) create mode 100644 stylix/autoload.nix diff --git a/flake.nix b/flake.nix index 3e06cc3b..2bb29f0f 100644 --- a/flake.nix +++ b/flake.nix @@ -63,29 +63,6 @@ inherit (self.packages.${pkgs.system}) palette-generator; base16 = base16.lib args; }) - ./modules/alacritty.nix - ./modules/bemenu.nix - ./modules/chromium.nix - ./modules/console.nix - ./modules/dunst.nix - ./modules/feh.nix - ./modules/fish.nix - ./modules/gedit - ./modules/gnome - ./modules/grub.nix - ./modules/gtk - ./modules/helix.nix - ./modules/i3.nix - ./modules/k9s.nix - ./modules/kitty.nix - ./modules/lightdm.nix - ./modules/mako.nix - ./modules/plymouth - ./modules/qutebrowser.nix - ./modules/sway.nix - ./modules/swaylock.nix - ./modules/vim.nix - ./modules/vscode/default.nix ]; }; diff --git a/modules/alacritty.nix b/modules/alacritty/hm.nix similarity index 69% rename from modules/alacritty.nix rename to modules/alacritty/hm.nix index 43892388..f118c489 100644 --- a/modules/alacritty.nix +++ b/modules/alacritty/hm.nix @@ -17,16 +17,14 @@ in config.lib.stylix.mkEnableTarget "Alacritty" true; config = lib.mkIf config.stylix.targets.alacritty.enable { - home-manager.sharedModules = [{ - programs.alacritty.settings = { - font = { - normal = { - family = monospace.name; - style = "Regular"; - }; + programs.alacritty.settings = { + font = { + normal = { + family = monospace.name; + style = "Regular"; }; - import = [ themeFile ]; }; - }]; + import = [ themeFile ]; + }; }; } diff --git a/modules/bemenu.nix b/modules/bemenu/hm.nix similarity index 93% rename from modules/bemenu.nix rename to modules/bemenu/hm.nix index d506ff76..ed76be60 100644 --- a/modules/bemenu.nix +++ b/modules/bemenu/hm.nix @@ -12,7 +12,7 @@ with config.stylix.fonts; alternate = lib.mkOption { type = lib.types.bool; default = false; }; }; - config.home-manager.sharedModules = lib.mkIf config.stylix.targets.bemenu.enable [{ + config = lib.mkIf config.stylix.targets.bemenu.enable { home.sessionVariables.BEMENU_OPTS = with config.stylix.targets.bemenu; builtins.concatStringsSep " " [ # Inspired from https://git.sr.ht/~h4n1/base16-bemenu_opts "--tb '${base01}'" @@ -33,5 +33,5 @@ with config.stylix.fonts; "--fn '${sansSerif.name} ${lib.optionalString (fontSize != null) (builtins.toString fontSize)}'" ]; - }]; + }; } diff --git a/modules/chromium.nix b/modules/chromium/nixos.nix similarity index 100% rename from modules/chromium.nix rename to modules/chromium/nixos.nix diff --git a/modules/console.nix b/modules/console/nixos.nix similarity index 100% rename from modules/console.nix rename to modules/console/nixos.nix diff --git a/modules/dunst.nix b/modules/dunst.nix deleted file mode 100644 index ccd88655..00000000 --- a/modules/dunst.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ config, lib, ... }: - -with config.lib.stylix.colors.withHashtag; -with config.stylix.fonts; - -{ - options.stylix.targets.dunst.enable = - config.lib.stylix.mkEnableTarget "Dunst" true; - - config = lib.mkIf config.stylix.targets.dunst.enable { - home-manager.sharedModules = [{ - services.dunst.settings = { - global = { - separator_color = base02; - font = sansSerif.name; - }; - - urgency_low = { - background = base01; - foreground = base05; - frame_color = base0B; - }; - - urgency_normal = { - background = base01; - foreground = base05; - frame_color = base0E; - }; - - urgency_critical = { - background = base01; - foreground = base05; - frame_color = base08; - }; - }; - }]; - }; -} diff --git a/modules/dunst/hm.nix b/modules/dunst/hm.nix new file mode 100644 index 00000000..f3bd11b4 --- /dev/null +++ b/modules/dunst/hm.nix @@ -0,0 +1,36 @@ +{ config, lib, ... }: + +with config.lib.stylix.colors.withHashtag; +with config.stylix.fonts; + +{ + options.stylix.targets.dunst.enable = + config.lib.stylix.mkEnableTarget "Dunst" true; + + config = lib.mkIf config.stylix.targets.dunst.enable { + services.dunst.settings = { + global = { + separator_color = base02; + font = sansSerif.name; + }; + + urgency_low = { + background = base01; + foreground = base05; + frame_color = base0B; + }; + + urgency_normal = { + background = base01; + foreground = base05; + frame_color = base0E; + }; + + urgency_critical = { + background = base01; + foreground = base05; + frame_color = base08; + }; + }; + }; +} diff --git a/modules/feh.nix b/modules/feh/nixos.nix similarity index 100% rename from modules/feh.nix rename to modules/feh/nixos.nix diff --git a/modules/fish.nix b/modules/fish.nix deleted file mode 100644 index 784b38b9..00000000 --- a/modules/fish.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ pkgs, config, lib, ... }: - -let - theme = config.lib.stylix.colors { - templateRepo = pkgs.fetchFromGitHub { - owner = "tomyun"; - repo = "base16-fish"; - rev = "7f647967fddedaf803191bc9113b13d2071dc3cf"; - sha256 = "IGUbLjsmmAvB9UKGkR7oqdpjeVEfzt83GpyBkrZf2O4="; - }; - }; - - promptInit = '' - source ${theme} - base16-${config.lib.stylix.colors.slug} - ''; - -in { - options.stylix.targets.fish.enable = - config.lib.stylix.mkEnableTarget "Fish" true; - - config = lib.mkIf config.stylix.targets.fish.enable { - programs.fish.promptInit = promptInit; - - home-manager.sharedModules = [{ - programs.fish.interactiveShellInit = promptInit; - }]; - }; -} diff --git a/modules/fish/hm.nix b/modules/fish/hm.nix new file mode 100644 index 00000000..f5c28b39 --- /dev/null +++ b/modules/fish/hm.nix @@ -0,0 +1,10 @@ +{ pkgs, config, lib, ... }: + +{ + options.stylix.targets.fish.enable = + config.lib.stylix.mkEnableTarget "Fish" true; + + config = lib.mkIf config.stylix.targets.fish.enable { + programs.fish.interactiveShellInit = import ./prompt.nix { inherit pkgs config; }; + }; +} diff --git a/modules/fish/nixos.nix b/modules/fish/nixos.nix new file mode 100644 index 00000000..a315ebce --- /dev/null +++ b/modules/fish/nixos.nix @@ -0,0 +1,10 @@ +{ pkgs, config, lib, ... }: + +{ + options.stylix.targets.fish.enable = + config.lib.stylix.mkEnableTarget "Fish" true; + + config = lib.mkIf config.stylix.targets.fish.enable { + programs.fish.promptInit = import ./prompt.nix { inherit pkgs config; }; + }; +} diff --git a/modules/fish/prompt.nix b/modules/fish/prompt.nix new file mode 100644 index 00000000..6198a49b --- /dev/null +++ b/modules/fish/prompt.nix @@ -0,0 +1,15 @@ +{ pkgs, config }: + +let + theme = config.lib.stylix.colors { + templateRepo = pkgs.fetchFromGitHub { + owner = "tomyun"; + repo = "base16-fish"; + rev = "7f647967fddedaf803191bc9113b13d2071dc3cf"; + sha256 = "IGUbLjsmmAvB9UKGkR7oqdpjeVEfzt83GpyBkrZf2O4="; + }; + }; +in '' + source ${theme} + base16-${config.lib.stylix.colors.slug} +'' diff --git a/modules/gedit/default.nix b/modules/gedit/hm.nix similarity index 71% rename from modules/gedit/default.nix rename to modules/gedit/hm.nix index e60af4f9..a08a83cf 100644 --- a/modules/gedit/default.nix +++ b/modules/gedit/hm.nix @@ -11,10 +11,8 @@ in { config.lib.stylix.mkEnableTarget "GEdit" true; config = lib.mkIf config.stylix.targets.gedit.enable { - home-manager.sharedModules = [{ - xdg.dataFile = { - "gedit/styles/stylix.xml".source = style; - }; - }]; + xdg.dataFile = { + "gedit/styles/stylix.xml".source = style; + }; }; } diff --git a/modules/gnome/hm.nix b/modules/gnome/hm.nix new file mode 100644 index 00000000..717ec29e --- /dev/null +++ b/modules/gnome/hm.nix @@ -0,0 +1,27 @@ +{ pkgs, config, lib, ... }: + +with lib; + +{ + options.stylix.targets.gnome.enable = + config.lib.stylix.mkEnableTarget "GNOME" true; + + config = mkIf config.stylix.targets.gnome.enable { + dconf.settings = { + "org/gnome/desktop/background" = { + color-shading-type = "solid"; + picture-options = "zoom"; + picture-uri = "file://${config.stylix.image}"; + picture-uri-dark = "file://${config.stylix.image}"; + }; + + # We show the same colours regardless of this setting, and the quick + # settings tile is removed. The value is still used by Epiphany to + # request dark mode for websites which support it. + "org/gnome/desktop/interface".color-scheme = + if config.stylix.polarity == "dark" + then "prefer-dark" + else "default"; + }; + }; +} diff --git a/modules/gnome/default.nix b/modules/gnome/nixos.nix similarity index 66% rename from modules/gnome/default.nix rename to modules/gnome/nixos.nix index c0db7438..973034c7 100644 --- a/modules/gnome/default.nix +++ b/modules/gnome/nixos.nix @@ -7,25 +7,6 @@ with lib; config.lib.stylix.mkEnableTarget "GNOME" config.services.xserver.desktopManager.gnome.enable; config = mkIf config.stylix.targets.gnome.enable { - home-manager.sharedModules = [({ lib, ... }: { - dconf.settings = { - "org/gnome/desktop/background" = { - color-shading-type = "solid"; - picture-options = "zoom"; - picture-uri = "file://${config.stylix.image}"; - picture-uri-dark = "file://${config.stylix.image}"; - }; - - # We show the same colours regardless of this setting, and the quick - # settings tile is removed. The value is still used by Epiphany to - # request dark mode for websites which support it. - "org/gnome/desktop/interface".color-scheme = - if config.stylix.polarity == "dark" - then "prefer-dark" - else "default"; - }; - })]; - # 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 diff --git a/modules/grub.nix b/modules/grub/nixos.nix similarity index 100% rename from modules/grub.nix rename to modules/grub/nixos.nix diff --git a/modules/gtk/default.nix b/modules/gtk/default.nix deleted file mode 100644 index fd492ad7..00000000 --- a/modules/gtk/default.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ pkgs, config, lib, ... }: - -let - css = config.lib.stylix.colors { - template = builtins.readFile ./gtk.mustache; - extension = "css"; - }; - -in { - options.stylix.targets.gtk.enable = - config.lib.stylix.mkEnableTarget "all GTK3, GTK4 and Libadwaita apps" true; - - config = lib.mkIf config.stylix.targets.gtk.enable { - # Required for Home Manager's GTK settings to work - programs.dconf.enable = true; - - home-manager.sharedModules = [{ - gtk = { - enable = true; - font = config.stylix.fonts.sansSerif; - theme = { - package = pkgs.adw-gtk3; - name = "adw-gtk3"; - }; - }; - - xdg.configFile = { - "gtk-3.0/gtk.css".source = css; - "gtk-4.0/gtk.css".source = css; - }; - }]; - }; -} diff --git a/modules/gtk/hm.nix b/modules/gtk/hm.nix new file mode 100644 index 00000000..71729d10 --- /dev/null +++ b/modules/gtk/hm.nix @@ -0,0 +1,29 @@ +{ pkgs, config, lib, ... }: + +let + css = config.lib.stylix.colors { + template = builtins.readFile ./gtk.mustache; + extension = "css"; + }; + +in { + options.stylix.targets.gtk.enable = + config.lib.stylix.mkEnableTarget "all GTK3, GTK4 and Libadwaita apps" true; + + config = lib.mkIf config.stylix.targets.gtk.enable { + # programs.dconf.enable = true; required in system config + gtk = { + enable = true; + font = config.stylix.fonts.sansSerif; + theme = { + package = pkgs.adw-gtk3; + name = "adw-gtk3"; + }; + }; + + xdg.configFile = { + "gtk-3.0/gtk.css".source = css; + "gtk-4.0/gtk.css".source = css; + }; + }; +} diff --git a/modules/gtk/nixos.nix b/modules/gtk/nixos.nix new file mode 100644 index 00000000..73babc8f --- /dev/null +++ b/modules/gtk/nixos.nix @@ -0,0 +1,11 @@ +{ pkgs, config, lib, ... }: + +{ + options.stylix.targets.gtk.enable = + config.lib.stylix.mkEnableTarget "all GTK3, GTK4 and Libadwaita apps" true; + + config = lib.mkIf config.stylix.targets.gtk.enable { + # Required for Home Manager's GTK settings to work + programs.dconf.enable = true; + }; +} diff --git a/modules/helix.nix b/modules/helix/hm.nix similarity index 93% rename from modules/helix.nix rename to modules/helix/hm.nix index 20753d84..e80867bc 100644 --- a/modules/helix.nix +++ b/modules/helix/hm.nix @@ -103,11 +103,9 @@ in { config.lib.stylix.mkEnableTarget "Helix" true; config = lib.mkIf config.stylix.targets.helix.enable { - home-manager.sharedModules = [{ - programs.helix = { - settings.theme = "stylix"; - themes.stylix = theme; - }; - }]; + programs.helix = { + settings.theme = "stylix"; + themes.stylix = theme; + }; }; } diff --git a/modules/i3.nix b/modules/i3/hm.nix similarity index 59% rename from modules/i3.nix rename to modules/i3/hm.nix index f1e6145b..f93ebc73 100644 --- a/modules/i3.nix +++ b/modules/i3/hm.nix @@ -16,8 +16,8 @@ in { options.stylix.targets.i3.enable = config.lib.stylix.mkEnableTarget "i3" true; - config = { - home-manager.sharedModules = lib.mkIf config.stylix.targets.i3.enable [{ + config = lib.mkMerge [ + (lib.mkIf config.stylix.targets.i3.enable { xsession.windowManager.i3.config = { inherit fonts; @@ -55,39 +55,41 @@ in { # output."*".bg = "${config.stylix.image} fill"; }; - }]; + }) - # Merge this with your bar configuration using //config.lib.stylix.i3.bar - lib.stylix.i3.bar = { - inherit fonts; + { + # Merge this with your bar configuration using //config.lib.stylix.i3.bar + 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.nix b/modules/k9s.nix deleted file mode 100644 index fc26cbd8..00000000 --- a/modules/k9s.nix +++ /dev/null @@ -1,129 +0,0 @@ -{ pkgs, config, lib, ... }: - -with config.lib.stylix.colors.withHashtag; - -{ - options.stylix.targets.k9s.enable = - config.lib.stylix.mkEnableTarget "k9s" true; - - config = lib.mkIf config.stylix.targets.k9s.enable { - - home-manager.sharedModules = [{ - programs.k9s.skin = { - k9s = { - body = { - fgColor = base05-hex; - bgColor = "default"; - logoColor = base0C-hex; - }; - - prompt = { - fgColor = base05-hex; - bgColor = base00-hex; - suggestColor = base0A-hex; - }; - - info = { - fgColor = base0B-hex; - sectionColor = base05-hex; - }; - - dialog = { - fgColor = base05-hex; - bgColor = "default"; - buttonFgColor = base05-hex; - buttonBgColor = base0C-hex; - buttonFocusFgColor = base0E-hex; - buttonFocusBgColor = base0B-hex; - labelFgColor = base0A-hex; - fieldFgColor = base05-hex; - }; - - frame = { - border = { - fgColor = base02-hex; - focusColor = base01-hex; - }; - - menu = { - fgColor = base05-hex; - keyColor = base0B-hex; - numKeyColor = base0B-hex; - }; - - crumbs = { - fgColor = base05-hex; - bgColor = base01-hex; - activeColor = base01-hex; - }; - - status = { - newColor = base08-hex; - modifyColor = base0C-hex; - addColor = base09-hex; - errorColor = base0D-hex; - highlightcolor = base0A-hex; - killColor = base03-hex; - completedColor = base03-hex; - }; - - title = { - fgColor = base05-hex; - bgColor = base01-hex; - highlightColor = base0A-hex; - counterColor = base0C-hex; - filterColor = base0B-hex; - }; - }; - - views = { - charts = { - bgColor = "default"; - defaultDialColors = [ base0C-hex base0D-hex ]; - defaultChartColors = [ base0C-hex base0D-hex ]; - }; - - table = { - fgColor = base05-hex; - bgColor = "default"; - header = { - fgColor = base05-hex; - bgColor = "default"; - sorterColor = base08-hex; - }; - }; - - xray = { - fgColor = base05-hex; - bgColor = "default"; - cursorColor = base01-hex; - graphicColor = base0C-hex; - showIcons = false; - }; - - yaml = { - keyColor = base0B-hex; - colonColor = base0C-hex; - valueColor = base05-hex; - }; - - logs = { - fgColor = base05-hex; - bgColor = "default"; - indicator = { - fgColor = base05-hex; - bgColor = base0C-hex; - }; - }; - - help = { - fgColor = base05-hex; - bgColor = base00-hex; - indicator.fgColor = base0D-hex; - }; - }; - }; - }; - }]; - }; -} diff --git a/modules/k9s/hm.nix b/modules/k9s/hm.nix new file mode 100644 index 00000000..d3d5a39e --- /dev/null +++ b/modules/k9s/hm.nix @@ -0,0 +1,126 @@ +{ pkgs, config, lib, ... }: + +with config.lib.stylix.colors.withHashtag; + +{ + options.stylix.targets.k9s.enable = + config.lib.stylix.mkEnableTarget "k9s" true; + + config = lib.mkIf config.stylix.targets.k9s.enable { + programs.k9s.skin = { + k9s = { + body = { + fgColor = base05-hex; + bgColor = "default"; + logoColor = base0C-hex; + }; + + prompt = { + fgColor = base05-hex; + bgColor = base00-hex; + suggestColor = base0A-hex; + }; + + info = { + fgColor = base0B-hex; + sectionColor = base05-hex; + }; + + dialog = { + fgColor = base05-hex; + bgColor = "default"; + buttonFgColor = base05-hex; + buttonBgColor = base0C-hex; + buttonFocusFgColor = base0E-hex; + buttonFocusBgColor = base0B-hex; + labelFgColor = base0A-hex; + fieldFgColor = base05-hex; + }; + + frame = { + border = { + fgColor = base02-hex; + focusColor = base01-hex; + }; + + menu = { + fgColor = base05-hex; + keyColor = base0B-hex; + numKeyColor = base0B-hex; + }; + + crumbs = { + fgColor = base05-hex; + bgColor = base01-hex; + activeColor = base01-hex; + }; + + status = { + newColor = base08-hex; + modifyColor = base0C-hex; + addColor = base09-hex; + errorColor = base0D-hex; + highlightcolor = base0A-hex; + killColor = base03-hex; + completedColor = base03-hex; + }; + + title = { + fgColor = base05-hex; + bgColor = base01-hex; + highlightColor = base0A-hex; + counterColor = base0C-hex; + filterColor = base0B-hex; + }; + }; + + views = { + charts = { + bgColor = "default"; + defaultDialColors = [ base0C-hex base0D-hex ]; + defaultChartColors = [ base0C-hex base0D-hex ]; + }; + + table = { + fgColor = base05-hex; + bgColor = "default"; + header = { + fgColor = base05-hex; + bgColor = "default"; + sorterColor = base08-hex; + }; + }; + + xray = { + fgColor = base05-hex; + bgColor = "default"; + cursorColor = base01-hex; + graphicColor = base0C-hex; + showIcons = false; + }; + + yaml = { + keyColor = base0B-hex; + colonColor = base0C-hex; + valueColor = base05-hex; + }; + + logs = { + fgColor = base05-hex; + bgColor = "default"; + indicator = { + fgColor = base05-hex; + bgColor = base0C-hex; + }; + }; + + help = { + fgColor = base05-hex; + bgColor = base00-hex; + indicator.fgColor = base0D-hex; + }; + }; + }; + }; + }; +} diff --git a/modules/kitty.nix b/modules/kitty.nix deleted file mode 100644 index 192066c2..00000000 --- a/modules/kitty.nix +++ /dev/null @@ -1,48 +0,0 @@ -{ config, lib, ... }: - -{ - options.stylix.targets.kitty.enable = - config.lib.stylix.mkEnableTarget "Kitty" true; - - config = lib.mkIf config.stylix.targets.kitty.enable { - home-manager.sharedModules = [{ - programs.kitty = { - font = config.stylix.fonts.monospace; - - settings = with config.lib.stylix.colors.withHashtag; { - # Based on https://github.com/kdrag0n/base16-kitty/ - active_border_color = base03; - active_tab_background = base00; - active_tab_foreground = base05; - background = base00; - cursor = base05; - foreground = base05; - inactive_border_color = base01; - inactive_tab_background = base01; - inactive_tab_foreground = base04; - selection_background = base05; - selection_foreground = base00; - tab_bar_background = base01; - url_color = base04; - - 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/kitty/hm.nix b/modules/kitty/hm.nix new file mode 100644 index 00000000..86e6a409 --- /dev/null +++ b/modules/kitty/hm.nix @@ -0,0 +1,46 @@ +{ config, lib, ... }: + +{ + options.stylix.targets.kitty.enable = + config.lib.stylix.mkEnableTarget "Kitty" true; + + config = lib.mkIf config.stylix.targets.kitty.enable { + programs.kitty = { + font = config.stylix.fonts.monospace; + + settings = with config.lib.stylix.colors.withHashtag; { + # Based on https://github.com/kdrag0n/base16-kitty/ + active_border_color = base03; + active_tab_background = base00; + active_tab_foreground = base05; + background = base00; + cursor = base05; + foreground = base05; + inactive_border_color = base01; + inactive_tab_background = base01; + inactive_tab_foreground = base04; + selection_background = base05; + selection_foreground = base00; + tab_bar_background = base01; + url_color = base04; + + 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/lightdm.nix b/modules/lightdm/nixos.nix similarity index 100% rename from modules/lightdm.nix rename to modules/lightdm/nixos.nix diff --git a/modules/mako.nix b/modules/mako/hm.nix similarity index 89% rename from modules/mako.nix rename to modules/mako/hm.nix index a356edb1..0d95b24f 100644 --- a/modules/mako.nix +++ b/modules/mako/hm.nix @@ -7,7 +7,7 @@ with config.stylix.fonts; config.lib.stylix.mkEnableTarget "Mako" true; # Referenced https://github.com/stacyharper/base16-mako - config.home-manager.sharedModules = lib.mkIf config.stylix.targets.mako.enable [{ + config = lib.mkIf config.stylix.targets.mako.enable { programs.mako = { backgroundColor = base00; borderColor = base0D; @@ -27,5 +27,5 @@ with config.stylix.fonts; text-color=${base08} ''; }; - }]; + }; } diff --git a/modules/plymouth/default.nix b/modules/plymouth/nixos.nix similarity index 100% rename from modules/plymouth/default.nix rename to modules/plymouth/nixos.nix diff --git a/modules/qutebrowser.nix b/modules/qutebrowser.nix deleted file mode 100644 index e22c94ce..00000000 --- a/modules/qutebrowser.nix +++ /dev/null @@ -1,215 +0,0 @@ -{ config, lib, ... }: - -with config.stylix.fonts; -with config.lib.stylix.colors.withHashtag; - -let - background = base00; - secondary-background = base01; - selection-background = base03; - foreground = base05; - inverted-foreground = base00; - info = base0B; - secondary-info = base0C; - warning = base0E; - error = base08; - -in { - options.stylix.targets.qutebrowser.enable = - config.lib.stylix.mkEnableTarget "Qutebrowser" true; - - config = lib.mkIf config.stylix.targets.qutebrowser.enable { - home-manager.sharedModules = [{ - programs.qutebrowser.settings = { - hints.border = background; - colors = { - completion = { - fg = foreground; - odd.bg = secondary-background; - even.bg = background; - match.fg = info; - category = { - fg = info; - bg = background; - border.top = background; - border.bottom = background; - }; - item.selected = { - fg = foreground; - bg = selection-background; - border.top = selection-background; - border.bottom = selection-background; - }; - scrollbar = { - fg = foreground; - bg = background; - }; - }; - contextmenu = { - disabled = { - fg = inverted-foreground; - bg = secondary-background; - }; - menu = { - bg = background; - fg = foreground; - }; - selected = { - bg = selection-background; - fg = foreground; - }; - }; - downloads = { - bar.bg = background; - start = { - fg = inverted-foreground; - bg = info; - }; - stop = { - fg = inverted-foreground; - bg = secondary-info; - }; - error = { - fg = inverted-foreground; - bg = error; - }; - }; - hints = { - fg = foreground; - bg = secondary-background; - match.fg = info; - }; - keyhint = { - fg = foreground; - bg = background; - suffix.fg = foreground; - }; - messages = { - error = { - fg = inverted-foreground; - bg = error; - border = error; - }; - warning = { - fg = inverted-foreground; - bg = warning; - border = warning; - }; - info = { - fg = inverted-foreground; - bg = info; - border = info; - }; - }; - prompts = { - fg = foreground; - bg = background; - border = background; - selected.bg = secondary-background; - }; - statusbar = { - normal = { - fg = foreground; - bg = background; - }; - insert = { - fg = inverted-foreground; - bg = info; - }; - passthrough = { - fg = inverted-foreground; - bg = secondary-info; - }; - private = { - fg = foreground; - bg = secondary-background; - }; - command = { - fg = foreground; - bg = background; - private = { - fg = foreground; - bg = secondary-background; - }; - }; - caret = { - fg = foreground; - bg = selection-background; - selection = { - fg = foreground; - bg = selection-background; - }; - }; - progress.bg = info; - url = { - fg = foreground; - error.fg = error; - hover.fg = foreground; - success.http.fg = secondary-info; - success.https.fg = info; - warn.fg = warning; - }; - }; - tabs = { - bar.bg = background; - indicator = { - start = secondary-info; - stop = info; - error = error; - }; - odd = { - fg = foreground; - bg = background; - }; - even = { - fg = foreground; - bg = secondary-background; - }; - pinned = { - even = { - fg = inverted-foreground; - bg = info; - }; - odd = { - fg = inverted-foreground; - bg = secondary-info; - }; - selected = { - even = { - fg = foreground; - bg = selection-background; - }; - odd = { - fg = foreground; - bg = selection-background; - }; - }; - }; - selected = { - even = { - fg = foreground; - bg = selection-background; - }; - odd = { - fg = foreground; - bg = selection-background; - }; - }; - }; - }; - - fonts = { - default_family = sansSerif.name; - web.family = { - cursive = serif.name; - fantasy = serif.name; - fixed = monospace.name; - sans_serif = sansSerif.name; - serif = serif.name; - standard = sansSerif.name; - }; - }; - }; - }]; - }; -} diff --git a/modules/qutebrowser/hm.nix b/modules/qutebrowser/hm.nix new file mode 100644 index 00000000..4fa8d1bb --- /dev/null +++ b/modules/qutebrowser/hm.nix @@ -0,0 +1,213 @@ +{ config, lib, ... }: + +with config.stylix.fonts; +with config.lib.stylix.colors.withHashtag; + +let + background = base00; + secondary-background = base01; + selection-background = base03; + foreground = base05; + inverted-foreground = base00; + info = base0B; + secondary-info = base0C; + warning = base0E; + error = base08; + +in { + options.stylix.targets.qutebrowser.enable = + config.lib.stylix.mkEnableTarget "Qutebrowser" true; + + config = lib.mkIf config.stylix.targets.qutebrowser.enable { + programs.qutebrowser.settings = { + hints.border = background; + colors = { + completion = { + fg = foreground; + odd.bg = secondary-background; + even.bg = background; + match.fg = info; + category = { + fg = info; + bg = background; + border.top = background; + border.bottom = background; + }; + item.selected = { + fg = foreground; + bg = selection-background; + border.top = selection-background; + border.bottom = selection-background; + }; + scrollbar = { + fg = foreground; + bg = background; + }; + }; + contextmenu = { + disabled = { + fg = inverted-foreground; + bg = secondary-background; + }; + menu = { + bg = background; + fg = foreground; + }; + selected = { + bg = selection-background; + fg = foreground; + }; + }; + downloads = { + bar.bg = background; + start = { + fg = inverted-foreground; + bg = info; + }; + stop = { + fg = inverted-foreground; + bg = secondary-info; + }; + error = { + fg = inverted-foreground; + bg = error; + }; + }; + hints = { + fg = foreground; + bg = secondary-background; + match.fg = info; + }; + keyhint = { + fg = foreground; + bg = background; + suffix.fg = foreground; + }; + messages = { + error = { + fg = inverted-foreground; + bg = error; + border = error; + }; + warning = { + fg = inverted-foreground; + bg = warning; + border = warning; + }; + info = { + fg = inverted-foreground; + bg = info; + border = info; + }; + }; + prompts = { + fg = foreground; + bg = background; + border = background; + selected.bg = secondary-background; + }; + statusbar = { + normal = { + fg = foreground; + bg = background; + }; + insert = { + fg = inverted-foreground; + bg = info; + }; + passthrough = { + fg = inverted-foreground; + bg = secondary-info; + }; + private = { + fg = foreground; + bg = secondary-background; + }; + command = { + fg = foreground; + bg = background; + private = { + fg = foreground; + bg = secondary-background; + }; + }; + caret = { + fg = foreground; + bg = selection-background; + selection = { + fg = foreground; + bg = selection-background; + }; + }; + progress.bg = info; + url = { + fg = foreground; + error.fg = error; + hover.fg = foreground; + success.http.fg = secondary-info; + success.https.fg = info; + warn.fg = warning; + }; + }; + tabs = { + bar.bg = background; + indicator = { + start = secondary-info; + stop = info; + error = error; + }; + odd = { + fg = foreground; + bg = background; + }; + even = { + fg = foreground; + bg = secondary-background; + }; + pinned = { + even = { + fg = inverted-foreground; + bg = info; + }; + odd = { + fg = inverted-foreground; + bg = secondary-info; + }; + selected = { + even = { + fg = foreground; + bg = selection-background; + }; + odd = { + fg = foreground; + bg = selection-background; + }; + }; + }; + selected = { + even = { + fg = foreground; + bg = selection-background; + }; + odd = { + fg = foreground; + bg = selection-background; + }; + }; + }; + }; + + fonts = { + default_family = sansSerif.name; + web.family = { + cursive = serif.name; + fantasy = serif.name; + fixed = monospace.name; + sans_serif = sansSerif.name; + serif = serif.name; + standard = sansSerif.name; + }; + }; + }; + }; +} diff --git a/modules/sway.nix b/modules/sway/hm.nix similarity index 58% rename from modules/sway.nix rename to modules/sway/hm.nix index 8f1ea0e5..0465ae55 100644 --- a/modules/sway.nix +++ b/modules/sway/hm.nix @@ -17,8 +17,8 @@ in { options.stylix.targets.sway.enable = config.lib.stylix.mkEnableTarget "Sway" true; - config = { - home-manager.sharedModules = lib.mkIf config.stylix.targets.sway.enable [{ + config = lib.mkMerge [ + (lib.mkIf config.stylix.targets.sway.enable { wayland.windowManager.sway.config = { inherit fonts; @@ -56,40 +56,42 @@ in { output."*".bg = "${config.stylix.image} fill"; }; - }]; + }) - # Merge this with your bar configuration using //config.lib.stylix.sway.bar - lib.stylix.sway.bar = { - inherit fonts; + { + # Merge this with your bar configuration using //config.lib.stylix.sway.bar + 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; - }; - activeWorkspace = { - inherit text border; - background = unfocused; - }; - inactiveWorkspace = { - inherit text border; - background = unfocused; - }; - urgentWorkspace = { - inherit text border; - background = urgent; - }; - bindingMode = { - inherit text border; - background = urgent; + 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; + }; }; }; - }; - }; + } + ]; } diff --git a/modules/swaylock.nix b/modules/swaylock.nix deleted file mode 100644 index 9c060be4..00000000 --- a/modules/swaylock.nix +++ /dev/null @@ -1,64 +0,0 @@ -{ config, lib, ... }: - -with config.lib.stylix.colors; - -let - inside = base01-hex; - outside = base01-hex; - ring = base05-hex; - text = base05-hex; - positive = base0B-hex; - negative = base08-hex; - -in { - options.stylix.targets.swaylock = { - enable = config.lib.stylix.mkEnableTarget "Swaylock" true; - useImage = lib.mkOption { - description = '' - Whether to use your wallpaper image for the Swaylock background. - If this is disabled, a plain color will be used instead. - ''; - type = lib.types.bool; - default = true; - }; - }; - - config = lib.mkIf config.stylix.targets.swaylock.enable { - home-manager.sharedModules = [( - { options, ... }: - { - # See https://github.com/danth/stylix/issues/8#issuecomment-1194484544 - # This check can be removed when programs.swaylock is in a stable release - config = lib.optionalAttrs (options.programs ? swaylock) { - 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/swaylock/hm.nix b/modules/swaylock/hm.nix new file mode 100644 index 00000000..21bde6c8 --- /dev/null +++ b/modules/swaylock/hm.nix @@ -0,0 +1,58 @@ +{ options, config, lib, ... }: + +with config.lib.stylix.colors; + +let + inside = base01-hex; + outside = base01-hex; + ring = base05-hex; + text = base05-hex; + positive = base0B-hex; + negative = base08-hex; + +in { + options.stylix.targets.swaylock = { + enable = config.lib.stylix.mkEnableTarget "Swaylock" true; + useImage = lib.mkOption { + description = '' + Whether to use your wallpaper image for the Swaylock background. + If this is disabled, a plain color will be used instead. + ''; + type = lib.types.bool; + default = true; + }; + }; + + config = lib.mkIf config.stylix.targets.swaylock.enable + # See https://github.com/danth/stylix/issues/8#issuecomment-1194484544 + # This check can be removed when programs.swaylock is in a stable release + (lib.optionalAttrs (options.programs ? swaylock) { + 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/vim.nix b/modules/vim/hm.nix similarity index 89% rename from modules/vim.nix rename to modules/vim/hm.nix index d298d770..eaaf8797 100644 --- a/modules/vim.nix +++ b/modules/vim/hm.nix @@ -38,9 +38,7 @@ in { config.lib.stylix.mkEnableTarget "Vim and/or Neovim" true; config = lib.mkIf config.stylix.targets.vim.enable { - home-manager.sharedModules = [{ - programs.vim = vimOptions; - programs.neovim = vimOptions; - }]; + programs.vim = vimOptions; + programs.neovim = vimOptions; }; } diff --git a/modules/vscode/default.nix b/modules/vscode/hm.nix similarity index 87% rename from modules/vscode/default.nix rename to modules/vscode/hm.nix index 35c293bf..b244ce66 100644 --- a/modules/vscode/default.nix +++ b/modules/vscode/hm.nix @@ -37,12 +37,10 @@ in { config.lib.stylix.mkEnableTarget "VSCode" true; config = lib.mkIf config.stylix.targets.vscode.enable { - home-manager.sharedModules = [{ - programs.vscode = { - extensions = [ themeExtension ]; - userSettings."workbench.colorTheme" = "Stylix"; - }; - }]; + programs.vscode = { + extensions = [ themeExtension ]; + userSettings."workbench.colorTheme" = "Stylix"; + }; }; } diff --git a/stylix/autoload.nix b/stylix/autoload.nix new file mode 100644 index 00000000..1b7f373c --- /dev/null +++ b/stylix/autoload.nix @@ -0,0 +1,14 @@ +{ lib }: + +# 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)) diff --git a/stylix/hm/default.nix b/stylix/hm/default.nix index 5b5351f0..a3cbdc61 100644 --- a/stylix/hm/default.nix +++ b/stylix/hm/default.nix @@ -5,13 +5,14 @@ let inherit (lib) types; from-nixos = mod-args ? "osConfig"; system-theme = config.stylix.useSystemTheme; + autoload = import ../autoload.nix { inherit lib; } "hm"; in { imports = [ ../pixel.nix ../target.nix ./fonts.nix (import ./palette.nix { inherit palette-generator base16; }) - ]; + ] ++ autoload; options.stylix = { useSystemTheme = lib.mkOption { diff --git a/stylix/nixos/default.nix b/stylix/nixos/default.nix index 3c3834df..833a5d68 100644 --- a/stylix/nixos/default.nix +++ b/stylix/nixos/default.nix @@ -1,15 +1,16 @@ -{ palette-generator, base16 }@args: +{ palette-generator, base16 }: { config, lib, ... }: let cfg = config.stylix.home-manager; + autoload = import ../autoload.nix { inherit lib; } "nixos"; in { imports = [ ../pixel.nix ../target.nix ./fonts.nix (import ./palette.nix { inherit palette-generator base16; }) - ]; + ] ++ autoload; options.stylix.home-manager = { enable = lib.mkEnableOption "home-manager support";