From e4369939f41f7cfc7c0a870ed14c5a152a041911 Mon Sep 17 00:00:00 2001 From: pagedmov Date: Sun, 3 Nov 2024 15:55:36 -0500 Subject: [PATCH] finally caved and removed my redundant color scheme definition in the flake.nix file to use stylix's built-in color scheme definition --- flake.nix | 31 ++----------- hosts/desktop/home.nix | 4 +- hosts/laptop/home.nix | 4 +- hosts/server/home.nix | 3 +- modules/home/environment/spicetify.nix | 3 +- modules/home/environment/stylix.nix | 2 +- modules/home/environment/waybar.nix | 8 ++-- modules/home/files.nix | 61 +++++++++++++------------ modules/home/programs/kitty.nix | 2 +- modules/sys/environment/stylix.nix | 18 ++++++-- modules/sys/software/nixvim/options.nix | 8 +++- 11 files changed, 65 insertions(+), 79 deletions(-) diff --git a/flake.nix b/flake.nix index 7887e8c..5ccc0a4 100755 --- a/flake.nix +++ b/flake.nix @@ -41,31 +41,6 @@ } @ inputs: let system = "x86_64-linux"; username = "pagedmov"; - wallpaper = "${self}/assets/wallpapers/sleeping-blackmetal.png"; - base16scheme = "black-metal-immortal"; # can be easily changed with the chscheme script - - # Map colors from yaml to attribute set - # Extracting colors into a set here allows them to be propagated across the entire config, with or without stylix - lib = nixpkgs.lib; - pkgs = import nixpkgs {system = "x86_64-linux";}; - scheme_path = "${pkgs.base16-schemes}/share/themes/${base16scheme}.yaml"; - scheme_string = builtins.readFile scheme_path; - scheme_list = lib.splitString "\n" "${scheme_string}"; - colors = lib.filter (line: builtins.match "^ *base[0-9A-F]{2}: .*" line != null) scheme_list; - scheme = - lib.lists.foldl' ( - acc: line: let - splitLine = lib.splitString ": " line; - key = builtins.elemAt splitLine 0; - value = builtins.elemAt splitLine 1; - trimmedKey = lib.trim key; - cleanValue_step1 = lib.splitString " " value; - cleanValue_step2 = builtins.elemAt cleanValue_step1 0; - cleanValue_final = builtins.substring 1 (builtins.stringLength cleanValue_step2 - 2) cleanValue_step2; - in - acc // {"${trimmedKey}" = cleanValue_final;} - ) {} - colors; in { homeManagerModules.default = ./modules/home; @@ -73,7 +48,7 @@ oganesson = nixpkgs.lib.nixosSystem { specialArgs = { host = "oganesson"; - inherit self inputs scheme wallpaper username; + inherit self inputs username; }; inherit system; modules = [ @@ -88,7 +63,7 @@ mercury = nixpkgs.lib.nixosSystem { specialArgs = { host = "mercury"; - inherit self inputs scheme wallpaper username; + inherit self inputs username; }; modules = [ ./hosts/laptop/config.nix @@ -102,7 +77,7 @@ xenon = nixpkgs.lib.nixosSystem { specialArgs = { host = "xenon"; - inherit self inputs scheme username; + inherit self inputs username; }; modules = [ ./hosts/server/config.nix diff --git a/hosts/desktop/home.nix b/hosts/desktop/home.nix index 96fc04e..7049d08 100755 --- a/hosts/desktop/home.nix +++ b/hosts/desktop/home.nix @@ -4,9 +4,7 @@ self, inputs, username, - wallpaper, lib, - scheme ? {}, config, ... }: let @@ -17,7 +15,7 @@ in { useUserPackages = true; useGlobalPkgs = true; backupFileExtension = "backup"; - extraSpecialArgs = {inherit self inputs host wallpaper scheme username nur;}; + extraSpecialArgs = {inherit self inputs host username nur;}; users = { ${username} = { programs.home-manager.enable = true; diff --git a/hosts/laptop/home.nix b/hosts/laptop/home.nix index 96fc04e..7049d08 100755 --- a/hosts/laptop/home.nix +++ b/hosts/laptop/home.nix @@ -4,9 +4,7 @@ self, inputs, username, - wallpaper, lib, - scheme ? {}, config, ... }: let @@ -17,7 +15,7 @@ in { useUserPackages = true; useGlobalPkgs = true; backupFileExtension = "backup"; - extraSpecialArgs = {inherit self inputs host wallpaper scheme username nur;}; + extraSpecialArgs = {inherit self inputs host username nur;}; users = { ${username} = { programs.home-manager.enable = true; diff --git a/hosts/server/home.nix b/hosts/server/home.nix index 76e40ba..9b11b9d 100755 --- a/hosts/server/home.nix +++ b/hosts/server/home.nix @@ -4,7 +4,6 @@ self, inputs, lib, - scheme, username, config, ... @@ -17,7 +16,7 @@ in { useUserPackages = true; useGlobalPkgs = true; backupFileExtension = "backup"; - extraSpecialArgs = { inherit self inputs scheme host username nur; }; + extraSpecialArgs = { inherit self inputs host username nur; }; users = { ${username} = { programs.home-manager.enable = true; diff --git a/modules/home/environment/spicetify.nix b/modules/home/environment/spicetify.nix index 1ff34d8..04b6d65 100755 --- a/modules/home/environment/spicetify.nix +++ b/modules/home/environment/spicetify.nix @@ -1,5 +1,6 @@ -{lib, config, pkgs, inputs, scheme ? {}, ... }: let +{lib, config, pkgs, inputs, ... }: let spicePkgs = inputs.spicetify-nix.legacyPackages.${pkgs.system}; + scheme = config.lib.stylix.colors; in { imports = [inputs.spicetify-nix.homeManagerModules.default]; options = { diff --git a/modules/home/environment/stylix.nix b/modules/home/environment/stylix.nix index cc6b70b..15324f4 100755 --- a/modules/home/environment/stylix.nix +++ b/modules/home/environment/stylix.nix @@ -1,4 +1,4 @@ -{lib, config, pkgs, scheme ? {}, wallpaper, ... }: { +{lib, config, pkgs, ... }: { options = { stylixHomeConfig.enable = lib.mkEnableOption "enables my stylix Home-Manager options"; }; diff --git a/modules/home/environment/waybar.nix b/modules/home/environment/waybar.nix index 3759326..6fe995b 100755 --- a/modules/home/environment/waybar.nix +++ b/modules/home/environment/waybar.nix @@ -1,4 +1,4 @@ -{pkgs, scheme ? {}, host, lib, config, ...}: +{pkgs, host, lib, config, ...}: let desktop = host == "oganesson"; @@ -22,6 +22,8 @@ let "eDP-1" = [1 2 3 4]; }; }; + + scheme = config.lib.stylix.colors; bg = { darkester = scheme.base00; darkest = scheme.base01; @@ -435,7 +437,7 @@ in { } #custom-power { - color: #${colors.color0}; + color: #${colors.color2}; font-size: 18px; } @@ -445,7 +447,7 @@ in { } #custom-reboot { - color: #${colors.color2}; + color: #${colors.color0}; font-size: 18px; } diff --git a/modules/home/files.nix b/modules/home/files.nix index 734847c..b253d94 100755 --- a/modules/home/files.nix +++ b/modules/home/files.nix @@ -1,10 +1,11 @@ -{pkgs, scheme, lib, self, config, ... }: +{pkgs, lib, self, config, ... }: # This folder is for programs that do not have existing configuration modules in NixOS. # Basically a to-do list for stuff I need to write my own modules for. let # Custom theme that activates in ssh ssh_base16 = "atelier-cave"; + def_scheme = config.lib.stylix.colors; scheme_path = "${pkgs.base16-schemes}/share/themes/${ssh_base16}.yaml"; scheme_string = builtins.readFile scheme_path; @@ -140,39 +141,39 @@ in ''; ".config/kitty/default-theme.conf".text = '' - background #${scheme.base00} - foreground #${scheme.base05} - selection_background #${scheme.base05} - selection_foreground #${scheme.base00} - url_color #${scheme.base04} - cursor #${scheme.base05} - active_border_color #${scheme.base03} - inactive_border_color #${scheme.base01} - active_tab_background #${scheme.base00} - active_tab_foreground #${scheme.base05} - inactive_tab_background #${scheme.base01} - inactive_tab_foreground #${scheme.base04} - tab_bar_background #${scheme.base01} + background #${def_scheme.base00} + foreground #${def_scheme.base05} + selection_background #${def_scheme.base05} + selection_foreground #${def_scheme.base00} + url_color #${def_scheme.base04} + cursor #${def_scheme.base05} + active_border_color #${def_scheme.base03} + inactive_border_color #${def_scheme.base01} + active_tab_background #${def_scheme.base00} + active_tab_foreground #${def_scheme.base05} + inactive_tab_background #${def_scheme.base01} + inactive_tab_foreground #${def_scheme.base04} + tab_bar_background #${def_scheme.base01} # normal - color0 #${scheme.base01} - color1 #${scheme.base08} - color2 #${scheme.base0B} - color3 #${scheme.base0A} - color4 #${scheme.base0D} - color5 #${scheme.base0E} - color6 #${scheme.base0C} - color7 #${scheme.base05} + color0 #${def_scheme.base01} + color1 #${def_scheme.base08} + color2 #${def_scheme.base0B} + color3 #${def_scheme.base0A} + color4 #${def_scheme.base0D} + color5 #${def_scheme.base0E} + color6 #${def_scheme.base0C} + color7 #${def_scheme.base05} # bright - color8 #${scheme.base03} - color9 #${scheme.base09} - color10 #${scheme.base01} - color11 #${scheme.base02} - color12 #${scheme.base04} - color13 #${scheme.base06} - color14 #${scheme.base0F} - color15 #${scheme.base07} + color8 #${def_scheme.base03} + color9 #${def_scheme.base09} + color10 #${def_scheme.base01} + color11 #${def_scheme.base02} + color12 #${def_scheme.base04} + color13 #${def_scheme.base06} + color14 #${def_scheme.base0F} + color15 #${def_scheme.base07} ''; ".config/kitty/ssh-theme.conf".text = '' background #${ssh_scheme.base00} diff --git a/modules/home/programs/kitty.nix b/modules/home/programs/kitty.nix index 18e406b..a17eebd 100755 --- a/modules/home/programs/kitty.nix +++ b/modules/home/programs/kitty.nix @@ -1,4 +1,4 @@ -{lib, config, pkgs, scheme ? {}, ... }: { +{lib, config, pkgs, ... }: { options = { kittyConfig.enable = lib.mkEnableOption "enables my kitty configuration"; }; diff --git a/modules/sys/environment/stylix.nix b/modules/sys/environment/stylix.nix index 04e114b..afdd364 100755 --- a/modules/sys/environment/stylix.nix +++ b/modules/sys/environment/stylix.nix @@ -1,19 +1,27 @@ { pkgs, - scheme ? {}, - wallpaper, + self, lib, config, ... -}: { +}: + +let + scheme = "black-metal-venom"; +in +{ options = { stylixConfig.enable = lib.mkEnableOption "enables custom stylix options"; }; config = lib.mkIf config.stylixConfig.enable { stylix = { enable = true; - base16Scheme = scheme; - image = wallpaper; + base16Scheme = "${pkgs.base16-schemes}/share/themes/${scheme}.yaml"; + image = "${self}/assets/wallpapers/sleeping-blackmetal.png"; + homeManagerIntegration = { + autoImport = true; + followSystem = true; + }; polarity = "dark"; autoEnable = true; opacity.terminal = 0.5; diff --git a/modules/sys/software/nixvim/options.nix b/modules/sys/software/nixvim/options.nix index 652a31b..c2d4f99 100755 --- a/modules/sys/software/nixvim/options.nix +++ b/modules/sys/software/nixvim/options.nix @@ -1,8 +1,12 @@ { - scheme ? {}, config, ... -}: { +}: + +let + scheme = config.lib.stylix.colors; +in +{ programs.nixvim = { colorschemes.base16 = { enable = true;