1
Fork 0

feat: better theming system with wallpaper support

This commit is contained in:
Matei Adriel 2022-03-13 12:46:00 +02:00
parent a27b90af9e
commit 9f7861cbc8
17 changed files with 65 additions and 65 deletions

View file

@ -1,26 +1,12 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let let
themes = pkgs.myThemes; theme = pkgs.myThemes.current;
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;
in in
{ {
imports = [ imports = [
{ {
home-manager.users.adrielus = createThemeConfigs; # Load theme
home-manager.users.adrielus.programs.alacritty.settings = theme.alacritty.settings;
} }
]; ];

View file

@ -1,6 +1,6 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let let
themes = pkgs.myThemes; theme = pkgs.myThemes.current;
# config-nvim = "/etc/nixos/configuration/dotfiles/neovim"; # config-nvim = "/etc/nixos/configuration/dotfiles/neovim";
config-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix { config-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix {
@ -8,23 +8,19 @@ let
src = ../../dotfiles/neovim; src = ../../dotfiles/neovim;
}; };
themePlugins = lib.lists.concatMap (theme: theme.neovim.plugins) themes; # Lua code for importing a theme
loadTheme = (theme: '' loadTheme = (theme: ''
if currentTheme == "${theme.name}" then ${theme.neovim.theme}
${theme.neovim.theme}
vim.g.lualineTheme = ${theme.neovim.lualineTheme} vim.g.lualineTheme = ${theme.neovim.lualineTheme}
end
''); '');
loadThemes = '' # Wrap a piece of lua code
lua = (code: ''
lua << EOF lua << EOF
local currentTheme = os.getenv("THEME"); ${code}
${pkgs.myHelpers.mergeLines (lib.lists.forEach themes loadTheme)};
EOF EOF
''; '');
in in
{ {
home-manager.users.adrielus.programs.neovim = { home-manager.users.adrielus.programs.neovim = {
@ -32,7 +28,7 @@ in
package = pkgs.neovim-nightly; package = pkgs.neovim-nightly;
extraConfig = '' extraConfig = ''
${loadThemes} ${lua (loadTheme theme)}
luafile ${config-nvim}/init.lua luafile ${config-nvim}/init.lua
''; '';
@ -58,7 +54,7 @@ in
]; ];
plugins = with pkgs.vimPlugins; 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 config-nvim # my neovim config
nvim-lspconfig # configures lsps for me nvim-lspconfig # configures lsps for me
nvim-autopairs # close pairs for me nvim-autopairs # close pairs for me

View file

@ -23,6 +23,4 @@
# Render git repo using gource # Render git repo using gource
"git-render" = "gource -f -s 1 -c 4 --key"; "git-render" = "gource -f -s 1 -c 4 --key";
alacritty = "alacritty --config-file ~/.config/alacritty/themes/$THEME.yml";
} }

View file

@ -9,12 +9,6 @@ let
# Sets neovim as default editor # Sets neovim as default editor
EDITOR = "nvim"; 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 in
{ {

View file

@ -1,10 +1,6 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let let
sourceTmuxTheme = (theme: '' theme = pkgs.myThemes.current;
# 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);
in in
{ {
home-manager.users.adrielus.programs = { home-manager.users.adrielus.programs = {
@ -24,11 +20,11 @@ in
]; ];
extraConfig = '' extraConfig = ''
# Load every theme available # Load current theme
${tmuxThemes} source ${theme.tmux.path}
# load the rest of the config # load the rest of the config
source-file ${../../dotfiles/tmux/tmux.conf} source ${../../dotfiles/tmux/tmux.conf}
''; '';
}; };
}; };

View file

@ -75,9 +75,6 @@ main =
manageWorkspaces manageWorkspaces
] ]
spawnTerminal = do
spawn "fish -c 'alacritty --config-file ~/.config/alacritty/themes/$THEME.yml'"
myTerminal = "alacritty" myTerminal = "alacritty"
myBrowser = "google-chrome-stable" myBrowser = "google-chrome-stable"
@ -85,7 +82,6 @@ main =
keymap = keymap =
[ ("M-p", spawn "rofi -show run"), [ ("M-p", spawn "rofi -show run"),
("M-g", spawn myBrowser), ("M-g", spawn myBrowser),
("M-s", spawnTerminal),
("M-d", spawn "Discord") ("M-d", spawn "Discord")
] ]
@ -101,9 +97,6 @@ main =
startup :: X () startup :: X ()
startup = do startup = do
spawn "xwallpaper --zoom ./background.jpg" -- The file is dynamically set in wallpaper.nix
spawn "xwallpaper --zoom ~/.config/wallpaper"
-- spawn "Discord"
-- spawn "google-chrome-stable"
-- spawn "alacritty"

View file

@ -1,8 +1,10 @@
{ pkgs, ... }: { { pkgs, lib, ... }: {
nixpkgs.overlays = [ nixpkgs.overlays = [
(import ./tweakSources.nix) (import ./tweakSources.nix)
(import ./myPackages.nix)
(import ./npm.nix) (import ./npm.nix)
((import ./myPackages.nix) {
inherit lib;
}) # Requires lib access
# I hope this works (spoiler: it did not) # I hope this works (spoiler: it did not)
# (import ./edopro) # (import ./edopro)

View file

@ -1,5 +1,22 @@
{ lib, ... }:
self: super: self: super:
let
allThemes = self.callPackage (import ../themes/themes.nix) { };
currentTheme = "github-dark";
in
with self; { with self; {
myHelpers = self.callPackage (import ../helpers.nix) { }; 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;
};
} }

View file

@ -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
];
}

View file

@ -1,8 +1,10 @@
{ variant, transparency ? 1 }: { pkgs, ... }: { variant, transparency ? 1, wallpaper }: { pkgs, ... }:
let let
githubTheme = pkgs.myVimPlugins.githubNvimTheme; # github theme for neovim githubTheme = pkgs.myVimPlugins.githubNvimTheme; # github theme for neovim
in in
{ {
inherit wallpaper;
name = "github-${variant}"; name = "github-${variant}";
neovim = { neovim = {
plugins = [ pkgs.vimExtraPlugins.github-nvim-theme ]; plugins = [ pkgs.vimExtraPlugins.github-nvim-theme ];

View file

@ -1,2 +0,0 @@

View file

@ -2,6 +2,14 @@
let githubVariant = import ./githubVariant.nix; let githubVariant = import ./githubVariant.nix;
in in
lib.lists.map (theme: pkgs.callPackage theme { }) [ lib.lists.map (theme: pkgs.callPackage theme { }) [
(githubVariant { variant = "light"; }) (githubVariant {
(githubVariant { variant = "dark"; transparency = 0.8; }) variant = "light";
wallpaper = ./wallpapers/wall.png;
transparency = 0.8;
})
(githubVariant {
variant = "dark";
wallpaper = ./wallpapers/spaceship.jpg;
transparency = 0.8;
})
] ]

View file

@ -0,0 +1,5 @@
{ pkgs, ... }: {
home-manager.users.adrielus = {
xdg.configFile.wallpaper.source = pkgs.myThemes.current.wallpaper;
};
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 763 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 KiB