feat: better theming system with wallpaper support
This commit is contained in:
parent
a27b90af9e
commit
9f7861cbc8
|
@ -1,26 +1,12 @@
|
|||
{ pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
themes = pkgs.myThemes;
|
||||
|
||||
createTheme = (theme: {
|
||||
xdg.configFile."alacritty/themes/${theme.name}.yml".text =
|
||||
builtins.toJSON
|
||||
(lib.attrsets.recursiveUpdate theme.alacritty.settings {
|
||||
import = theme.alacritty.settings.import ++ [ "~/.config/alacritty/alacritty.yml" ];
|
||||
});
|
||||
});
|
||||
|
||||
createThemeConfigs = lib.lists.foldr
|
||||
(theme: acc: lib.attrsets.recursiveUpdate acc (createTheme theme)
|
||||
)
|
||||
{ }
|
||||
themes;
|
||||
theme = pkgs.myThemes.current;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
{
|
||||
home-manager.users.adrielus = createThemeConfigs;
|
||||
# Load theme
|
||||
home-manager.users.adrielus.programs.alacritty.settings = theme.alacritty.settings;
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{ pkgs, lib, ... }:
|
||||
let
|
||||
themes = pkgs.myThemes;
|
||||
theme = pkgs.myThemes.current;
|
||||
|
||||
# config-nvim = "/etc/nixos/configuration/dotfiles/neovim";
|
||||
config-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix {
|
||||
|
@ -8,23 +8,19 @@ let
|
|||
src = ../../dotfiles/neovim;
|
||||
};
|
||||
|
||||
themePlugins = lib.lists.concatMap (theme: theme.neovim.plugins) themes;
|
||||
|
||||
# Lua code for importing a theme
|
||||
loadTheme = (theme: ''
|
||||
if currentTheme == "${theme.name}" then
|
||||
${theme.neovim.theme}
|
||||
|
||||
vim.g.lualineTheme = ${theme.neovim.lualineTheme}
|
||||
end
|
||||
'');
|
||||
|
||||
loadThemes = ''
|
||||
# Wrap a piece of lua code
|
||||
lua = (code: ''
|
||||
lua << EOF
|
||||
local currentTheme = os.getenv("THEME");
|
||||
|
||||
${pkgs.myHelpers.mergeLines (lib.lists.forEach themes loadTheme)};
|
||||
${code}
|
||||
EOF
|
||||
'';
|
||||
'');
|
||||
in
|
||||
{
|
||||
home-manager.users.adrielus.programs.neovim = {
|
||||
|
@ -32,7 +28,7 @@ in
|
|||
package = pkgs.neovim-nightly;
|
||||
|
||||
extraConfig = ''
|
||||
${loadThemes}
|
||||
${lua (loadTheme theme)}
|
||||
luafile ${config-nvim}/init.lua
|
||||
'';
|
||||
|
||||
|
@ -58,7 +54,7 @@ in
|
|||
];
|
||||
|
||||
plugins = with pkgs.vimPlugins;
|
||||
with pkgs.vimExtraPlugins; with pkgs.myVimPlugins; themePlugins ++ [
|
||||
with pkgs.vimExtraPlugins; with pkgs.myVimPlugins; theme.neovim.plugins ++ [
|
||||
config-nvim # my neovim config
|
||||
nvim-lspconfig # configures lsps for me
|
||||
nvim-autopairs # close pairs for me
|
||||
|
|
|
@ -23,6 +23,4 @@
|
|||
|
||||
# Render git repo using gource
|
||||
"git-render" = "gource -f -s 1 -c 4 --key";
|
||||
|
||||
alacritty = "alacritty --config-file ~/.config/alacritty/themes/$THEME.yml";
|
||||
}
|
||||
|
|
|
@ -9,12 +9,6 @@ let
|
|||
|
||||
# Sets neovim as default editor
|
||||
EDITOR = "nvim";
|
||||
|
||||
# Sets the current theme used by all programs
|
||||
THEME = theme;
|
||||
|
||||
# Common command for launching alacritty with the correct theme
|
||||
# LAUNCH_ALACRITTY = "alacritty --config-file ~/.config/alacritty/themes/$THEME.yml";
|
||||
};
|
||||
in
|
||||
{
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
{ pkgs, lib, ... }:
|
||||
let
|
||||
sourceTmuxTheme = (theme: ''
|
||||
# Only load this theme if it's the current one
|
||||
if '[[ "$THEME" =~ ${theme.name} ]]' 'source ${theme.tmux.path}'
|
||||
'');
|
||||
tmuxThemes = pkgs.myHelpers.mergeLines (lib.lists.forEach pkgs.myThemes sourceTmuxTheme);
|
||||
theme = pkgs.myThemes.current;
|
||||
in
|
||||
{
|
||||
home-manager.users.adrielus.programs = {
|
||||
|
@ -24,11 +20,11 @@ in
|
|||
];
|
||||
|
||||
extraConfig = ''
|
||||
# Load every theme available
|
||||
${tmuxThemes}
|
||||
# Load current theme
|
||||
source ${theme.tmux.path}
|
||||
|
||||
# load the rest of the config
|
||||
source-file ${../../dotfiles/tmux/tmux.conf}
|
||||
source ${../../dotfiles/tmux/tmux.conf}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
|
@ -75,9 +75,6 @@ main =
|
|||
manageWorkspaces
|
||||
]
|
||||
|
||||
spawnTerminal = do
|
||||
spawn "fish -c 'alacritty --config-file ~/.config/alacritty/themes/$THEME.yml'"
|
||||
|
||||
myTerminal = "alacritty"
|
||||
myBrowser = "google-chrome-stable"
|
||||
|
||||
|
@ -85,7 +82,6 @@ main =
|
|||
keymap =
|
||||
[ ("M-p", spawn "rofi -show run"),
|
||||
("M-g", spawn myBrowser),
|
||||
("M-s", spawnTerminal),
|
||||
("M-d", spawn "Discord")
|
||||
]
|
||||
|
||||
|
@ -101,9 +97,6 @@ main =
|
|||
|
||||
startup :: X ()
|
||||
startup = do
|
||||
spawn "xwallpaper --zoom ./background.jpg"
|
||||
|
||||
-- spawn "Discord"
|
||||
-- spawn "google-chrome-stable"
|
||||
-- spawn "alacritty"
|
||||
-- The file is dynamically set in wallpaper.nix
|
||||
spawn "xwallpaper --zoom ~/.config/wallpaper"
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
{ pkgs, ... }: {
|
||||
{ pkgs, lib, ... }: {
|
||||
nixpkgs.overlays = [
|
||||
(import ./tweakSources.nix)
|
||||
(import ./myPackages.nix)
|
||||
(import ./npm.nix)
|
||||
((import ./myPackages.nix) {
|
||||
inherit lib;
|
||||
}) # Requires lib access
|
||||
|
||||
# I hope this works (spoiler: it did not)
|
||||
# (import ./edopro)
|
||||
|
|
|
@ -1,5 +1,22 @@
|
|||
{ lib, ... }:
|
||||
self: super:
|
||||
let
|
||||
allThemes = self.callPackage (import ../themes/themes.nix) { };
|
||||
currentTheme = "github-dark";
|
||||
in
|
||||
with self; {
|
||||
myHelpers = self.callPackage (import ../helpers.nix) { };
|
||||
myThemes = self.callPackage (import ../themes/themes.nix) { };
|
||||
myThemes = {
|
||||
all = allThemes;
|
||||
current = lib.lists.findFirst (theme: theme.name == currentTheme)
|
||||
(throw ''
|
||||
Theme "${currentTheme}" not found.
|
||||
Available themes are:
|
||||
${lib.lists.foldr (current: prev: if prev == ""
|
||||
then current.name
|
||||
else "${current.name}, ${prev}") "" allThemes}
|
||||
'')
|
||||
allThemes;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1,6 @@
|
|||
{ ... }: { imports = [ ./fonts.nix ]; }
|
||||
{ ... }: {
|
||||
imports = [
|
||||
./fonts.nix # Installs fonts and stuff (TODO: consider moving this into the individual themes which require these fonts?)
|
||||
./wallpaper.nix # Sets the wallpaper required by the current theme
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
{ variant, transparency ? 1 }: { pkgs, ... }:
|
||||
{ variant, transparency ? 1, wallpaper }: { pkgs, ... }:
|
||||
let
|
||||
githubTheme = pkgs.myVimPlugins.githubNvimTheme; # github theme for neovim
|
||||
in
|
||||
{
|
||||
inherit wallpaper;
|
||||
|
||||
name = "github-${variant}";
|
||||
neovim = {
|
||||
plugins = [ pkgs.vimExtraPlugins.github-nvim-theme ];
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
|
||||
|
|
@ -2,6 +2,14 @@
|
|||
let githubVariant = import ./githubVariant.nix;
|
||||
in
|
||||
lib.lists.map (theme: pkgs.callPackage theme { }) [
|
||||
(githubVariant { variant = "light"; })
|
||||
(githubVariant { variant = "dark"; transparency = 0.8; })
|
||||
(githubVariant {
|
||||
variant = "light";
|
||||
wallpaper = ./wallpapers/wall.png;
|
||||
transparency = 0.8;
|
||||
})
|
||||
(githubVariant {
|
||||
variant = "dark";
|
||||
wallpaper = ./wallpapers/spaceship.jpg;
|
||||
transparency = 0.8;
|
||||
})
|
||||
]
|
||||
|
|
5
modules/themes/wallpaper.nix
Normal file
5
modules/themes/wallpaper.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
{ pkgs, ... }: {
|
||||
home-manager.users.adrielus = {
|
||||
xdg.configFile.wallpaper.source = pkgs.myThemes.current.wallpaper;
|
||||
};
|
||||
}
|
BIN
modules/themes/wallpapers/eye.png
Normal file
BIN
modules/themes/wallpapers/eye.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 MiB |
BIN
modules/themes/wallpapers/spaceship.jpg
Normal file
BIN
modules/themes/wallpapers/spaceship.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 763 KiB |
BIN
modules/themes/wallpapers/tree.jpg
Normal file
BIN
modules/themes/wallpapers/tree.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 206 KiB |
BIN
modules/themes/wallpapers/wall.png
Normal file
BIN
modules/themes/wallpapers/wall.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 288 KiB |
Loading…
Reference in a new issue