From 07484604d48f55e845efc796448badd045ab1a34 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Thu, 18 Aug 2022 21:15:03 +0200 Subject: [PATCH] feat: configure theme globally --- flake.nix | 7 ++++--- home-manager/bat.nix | 7 +++++-- home-manager/kitty.nix | 7 +++++-- home-manager/neovim/default.nix | 5 ++++- home-manager/neovim/themes.lua | 1 - home-manager/zsh.nix | 8 +++++--- home-mandlm.nix | 18 +++++++++--------- 7 files changed, 32 insertions(+), 21 deletions(-) diff --git a/flake.nix b/flake.nix index b64d4c0..7afdb8c 100644 --- a/flake.nix +++ b/flake.nix @@ -11,6 +11,7 @@ outputs = inputs @ { self, nixpkgs, home-manager, ... }: let user = "mandlm"; + theme = "dark"; # dark or light in { nixosConfigurations = { @@ -27,7 +28,7 @@ { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; - home-manager.extraSpecialArgs = { inherit user nixpkgs; }; + home-manager.extraSpecialArgs = { inherit user theme; }; home-manager.users.${user} = { imports = [ ./home-${user}.nix ]; }; @@ -48,7 +49,7 @@ { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; - home-manager.extraSpecialArgs = { inherit user; }; + home-manager.extraSpecialArgs = { inherit user theme; }; home-manager.users.${user} = { imports = [ ./home-${user}.nix @@ -72,7 +73,7 @@ { home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; - home-manager.extraSpecialArgs = { inherit user; }; + home-manager.extraSpecialArgs = { inherit user theme; }; home-manager.users.${user} = { imports = [ ./home-${user}.nix diff --git a/home-manager/bat.nix b/home-manager/bat.nix index 16947b9..35d9a1f 100644 --- a/home-manager/bat.nix +++ b/home-manager/bat.nix @@ -1,10 +1,13 @@ -{ config, lib, pkgs, user, ... }: +{ config, lib, pkgs, theme, ... }: +let + theme_name = "Solarized (${theme})"; +in { programs = { bat = { enable = true; - config.theme = "Solarized (dark)"; + config.theme = theme_name; }; }; } diff --git a/home-manager/kitty.nix b/home-manager/kitty.nix index 49eac2a..c9eb4ea 100644 --- a/home-manager/kitty.nix +++ b/home-manager/kitty.nix @@ -1,10 +1,13 @@ -{ config, lib, pkgs, user, ... }: +{ config, lib, pkgs, user, theme, ... }: +let + theme_name = if theme == "light" then "Solarized Light" else "Solarized Dark"; +in { programs = { kitty = { enable = true; - theme = "Solarized Dark"; + theme = theme_name; font = { name = "DejaVu Sans Mono"; }; diff --git a/home-manager/neovim/default.nix b/home-manager/neovim/default.nix index 41c3f74..0365ce1 100644 --- a/home-manager/neovim/default.nix +++ b/home-manager/neovim/default.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, user, ... }: +{ config, lib, pkgs, user, theme, ... }: let cmp-nvim-lsp-signature-help = pkgs.vimUtils.buildVimPlugin { @@ -141,7 +141,10 @@ in ${builtins.readFile ./luasnip.lua } ${builtins.readFile ./nvim-cmp.lua } ${builtins.readFile ./telescope.lua } + ${builtins.readFile ./themes.lua } + vim.opt.background = '${theme}' + ${builtins.readFile ./project-nvim.lua } EOF ''; diff --git a/home-manager/neovim/themes.lua b/home-manager/neovim/themes.lua index 3101cab..8d0b48e 100644 --- a/home-manager/neovim/themes.lua +++ b/home-manager/neovim/themes.lua @@ -1,2 +1 @@ -vim.opt.background = 'dark' vim.cmd("colorscheme solarized") diff --git a/home-manager/zsh.nix b/home-manager/zsh.nix index f9274d1..8d9d4da 100644 --- a/home-manager/zsh.nix +++ b/home-manager/zsh.nix @@ -1,5 +1,7 @@ -{ config, lib, pkgs, user, ... }: - +{ config, lib, pkgs, user, theme, ... }: +let + zsh_autosuggest_highlight_style = if theme == "light" then "fg=180" else "fg=10"; +in { programs.zsh = { enable = true; @@ -8,7 +10,7 @@ history.size = 10000; sessionVariables = { - ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE = "fg=10"; + ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE = zsh_autosuggest_highlight_style; }; shellAliases = { diff --git a/home-mandlm.nix b/home-mandlm.nix index d51a140..37b4cf5 100644 --- a/home-mandlm.nix +++ b/home-mandlm.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, user, ... }: +{ config, lib, pkgs, user, theme, ... }: { home = { @@ -36,14 +36,14 @@ programs.home-manager.enable = true; imports = [ - home-manager/fzf.nix - home-manager/git.nix - home-manager/kitty.nix - home-manager/neovim - home-manager/gpg - home-manager/zsh.nix - home-manager/starship.nix - home-manager/i3 + ./home-manager/fzf.nix + ./home-manager/git.nix + ./home-manager/kitty.nix + ./home-manager/neovim + ./home-manager/gpg + ./home-manager/zsh.nix + ./home-manager/starship.nix + ./home-manager/i3 ./home-manager/rofi.nix ./home-manager/direnv.nix ./home-manager/bat.nix