diff --git a/modules/applications/alacritty.nix b/modules/applications/alacritty.nix index c70e482..a6f344c 100644 --- a/modules/applications/alacritty.nix +++ b/modules/applications/alacritty.nix @@ -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; } ]; diff --git a/modules/applications/neovim.nix b/modules/applications/neovim.nix index 8d0677b..8e87ee6 100644 --- a/modules/applications/neovim.nix +++ b/modules/applications/neovim.nix @@ -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} + ${theme.neovim.theme} - vim.g.lualineTheme = ${theme.neovim.lualineTheme} - end + vim.g.lualineTheme = ${theme.neovim.lualineTheme} ''); - 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 diff --git a/modules/applications/shells/aliases.nix b/modules/applications/shells/aliases.nix index a87623e..3534f35 100644 --- a/modules/applications/shells/aliases.nix +++ b/modules/applications/shells/aliases.nix @@ -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"; } diff --git a/modules/applications/shells/sessionVariables.nix b/modules/applications/shells/sessionVariables.nix index bf37c1e..0ff2c2c 100644 --- a/modules/applications/shells/sessionVariables.nix +++ b/modules/applications/shells/sessionVariables.nix @@ -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 { diff --git a/modules/applications/tmux.nix b/modules/applications/tmux.nix index ed4d35a..92081ff 100644 --- a/modules/applications/tmux.nix +++ b/modules/applications/tmux.nix @@ -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} ''; }; }; diff --git a/modules/applications/xmonad/Main.hs b/modules/applications/xmonad/Main.hs index 6a80614..9b0144a 100644 --- a/modules/applications/xmonad/Main.hs +++ b/modules/applications/xmonad/Main.hs @@ -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" diff --git a/modules/overlays/default.nix b/modules/overlays/default.nix index 8e78ff4..e6ef153 100644 --- a/modules/overlays/default.nix +++ b/modules/overlays/default.nix @@ -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) diff --git a/modules/overlays/myPackages.nix b/modules/overlays/myPackages.nix index 982ffa3..c5fc305 100644 --- a/modules/overlays/myPackages.nix +++ b/modules/overlays/myPackages.nix @@ -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; + }; } + diff --git a/modules/themes/default.nix b/modules/themes/default.nix index f6b7acc..575bd8b 100644 --- a/modules/themes/default.nix +++ b/modules/themes/default.nix @@ -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 + ]; +} diff --git a/modules/themes/githubVariant.nix b/modules/themes/githubVariant.nix index b9d44cc..8948577 100644 --- a/modules/themes/githubVariant.nix +++ b/modules/themes/githubVariant.nix @@ -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 ]; diff --git a/modules/themes/theme.nix b/modules/themes/theme.nix deleted file mode 100644 index 139597f..0000000 --- a/modules/themes/theme.nix +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/modules/themes/themes.nix b/modules/themes/themes.nix index 7cd8460..b51ad6c 100644 --- a/modules/themes/themes.nix +++ b/modules/themes/themes.nix @@ -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; + }) ] diff --git a/modules/themes/wallpaper.nix b/modules/themes/wallpaper.nix new file mode 100644 index 0000000..e6da9a9 --- /dev/null +++ b/modules/themes/wallpaper.nix @@ -0,0 +1,5 @@ +{ pkgs, ... }: { + home-manager.users.adrielus = { + xdg.configFile.wallpaper.source = pkgs.myThemes.current.wallpaper; + }; +} diff --git a/modules/themes/wallpapers/eye.png b/modules/themes/wallpapers/eye.png new file mode 100644 index 0000000..5933943 Binary files /dev/null and b/modules/themes/wallpapers/eye.png differ diff --git a/modules/themes/wallpapers/spaceship.jpg b/modules/themes/wallpapers/spaceship.jpg new file mode 100644 index 0000000..f8d3353 Binary files /dev/null and b/modules/themes/wallpapers/spaceship.jpg differ diff --git a/modules/themes/wallpapers/tree.jpg b/modules/themes/wallpapers/tree.jpg new file mode 100644 index 0000000..29afd1d Binary files /dev/null and b/modules/themes/wallpapers/tree.jpg differ diff --git a/modules/themes/wallpapers/wall.png b/modules/themes/wallpapers/wall.png new file mode 100644 index 0000000..394fc9c Binary files /dev/null and b/modules/themes/wallpapers/wall.png differ