dotfiles
My PC Dotfiles & Websitegit clone https://github.com/maydayv7/dotfiles
commit bfb7b0a524e187307e922920e90e7098cc3c23d3 parent c9b210aeadda4ccb79f7699277df84b98b23ffd1 Author: maydayv7 <maydayv7@gmail.com> Date: Thu, 18 Apr 2024 19:11:30 +0530 feat: Add `lib.build.color`
Diffstat:
| M | files/hyprland/greeter.conf | | | 2 | +- |
| M | lib/README.md | | | 1 | + |
| M | lib/build.nix | | | 10 | ++++++++-- |
| M | modules/gui/desktop/hyprland/apps/default.nix | | | 7 | ++----- |
| M | modules/gui/desktop/hyprland/default.nix | | | 5 | +++-- |
5 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/files/hyprland/greeter.conf b/files/hyprland/greeter.conf @@ -7,5 +7,5 @@ misc { force_default_wallpaper = 0 disable_hyprland_logo = true disable_splash_rendering = true - background_color = rgb(@color) + background_color = rgb(@base00) } diff --git a/lib/README.md b/lib/README.md @@ -9,6 +9,7 @@ The `lib` directory contains custom-made utility functions (exposed as `util`), - `device`: Main system configuration building function, used to build the entire configuration for devices (`nixosConfigurations`) as per provided parameters - `mime`: Builds and sets `mimetype` values according to specified application and types - `script`: Builds script from specified file by removing `shebangs` and exporting as a _string_ + - `color`: Builds specified file by replacing placeholders with respective Base16 colors from provided scheme - [`map`](./map.nix): Mapping functions primarily aimed at shortening code complexity - diff --git a/lib/build.nix b/lib/build.nix @@ -1,7 +1,7 @@ lib: let - inherit (lib) flatten hasPrefix mapAttrsToList nameValuePair splitString; + inherit (lib) flatten hasPrefix mapAttrsToList nameValuePair replaceStrings splitString; inherit (builtins) concatStringsSep filter hasAttr listToAttrs map readFile; -in rec { +in { ## Builder Functions ## # Mime Types Handler mime = values: option: @@ -16,4 +16,10 @@ in rec { concatStringsSep "\n" ((filter (line: line != "" && !(hasPrefix "#!" line))) (splitString "\n" (readFile file))); + + # Base16 Color Substituter + color = colors: file: + replaceStrings ["@base00" "@base01" "@base02" "@base03" "@base04" "@base05" "@base06" "@base07" "@base08" "@base09" "@base0A" "@base0B" "@base0C" "@base0D" "@base0E" "@base0F"] + (with colors; [base00 base01 base02 base03 base04 base05 base06 base07 base08 base09 base0A base0B base0C base0D base0E base0F]) + file; } diff --git a/modules/gui/desktop/hyprland/apps/default.nix b/modules/gui/desktop/hyprland/apps/default.nix @@ -7,7 +7,7 @@ ... }: with files; let - inherit (lib) getExe mkIf replaceStrings; + inherit (lib) getExe mkIf; inherit (config.gui) wallpaper; inherit (config.lib.stylix) colors; exists = app: builtins.elem app config.apps.list; @@ -278,10 +278,7 @@ in { ''; # Clipboard Manager - ".config/clipse/custom_theme.json".text = - replaceStrings ["@base01" "@base05" "@base07" "@base08" "@base0B" "@base0D" "@base0E" "@base0F"] - (with colors; [base01 base05 base07 base08 base0B base0D base0E base0F]) - hyprland.clipse; + ".config/clipse/custom_theme.json".text = util.build.color colors hyprland.clipse; # Wallpaper ".config/hypr/hyprpaper.conf".text = '' diff --git a/modules/gui/desktop/hyprland/default.nix b/modules/gui/desktop/hyprland/default.nix @@ -1,6 +1,7 @@ { config, lib, + util, pkgs, files, ... @@ -46,8 +47,8 @@ in { services.greetd.settings.default_session.command = with programs; mkForce "${getExe hyprland.package} --config ${ pkgs.writeText "greeter.conf" - (replaceStrings ["@color" "@greeter"] [config.lib.stylix.colors.base00 (getExe regreet.package)] - files.hyprland.greeter) + (replaceStrings ["@greeter"] [(getExe regreet.package)] + (util.build.color config.lib.stylix.colors files.hyprland.greeter)) } &> /dev/null"; }