Made a distinct variable for the color scheme name in flake.nix, made a script 'chscheme' that allows one to easily change said variable
This commit is contained in:
40
flake.nix
40
flake.nix
@@ -42,26 +42,28 @@
|
||||
system = "x86_64-linux";
|
||||
username = "pagedmov";
|
||||
wallpaper = "${self}/media/wallpapers/cabin-2.jpg";
|
||||
base16scheme = "chalk"; # can be easily changed with the chscheme script
|
||||
|
||||
# Base 16 scheme for system colors
|
||||
scheme = {
|
||||
"base00" = "151515";
|
||||
"base01" = "202020";
|
||||
"base02" = "303030";
|
||||
"base03" = "505050";
|
||||
"base04" = "b0b0b0";
|
||||
"base05" = "d0d0d0";
|
||||
"base06" = "e0e0e0";
|
||||
"base07" = "f5f5f5";
|
||||
"base08" = "fb9fb1";
|
||||
"base09" = "eda987";
|
||||
"base0A" = "ddb26f";
|
||||
"base0B" = "acc267";
|
||||
"base0C" = "12cfc0";
|
||||
"base0D" = "6fc2ef";
|
||||
"base0E" = "e1a3ee";
|
||||
"base0F" = "deaf8f";
|
||||
};
|
||||
# Map colors from yaml to attribute set
|
||||
# Extracting colors into a set here allows them to be propagated across the entire config
|
||||
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 {
|
||||
nixosConfigurations = {
|
||||
oganesson = nixpkgs.lib.nixosSystem {
|
||||
|
||||
@@ -102,6 +102,9 @@
|
||||
self = self;
|
||||
pkgs = pkgs;
|
||||
};
|
||||
chscheme = import ./nix/chscheme.nix {
|
||||
pkgs = pkgs;
|
||||
};
|
||||
nixcommit = import ./nix/nixcommit.nix {
|
||||
host = host;
|
||||
self = self;
|
||||
@@ -114,6 +117,7 @@
|
||||
in {
|
||||
home.packages = [
|
||||
compress
|
||||
chscheme
|
||||
passhelper
|
||||
crs
|
||||
extract
|
||||
|
||||
5
modules/home/scripts/nix/chscheme.nix
Normal file
5
modules/home/scripts/nix/chscheme.nix
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
pkgs,
|
||||
}:
|
||||
pkgs.writeShellScriptBin "chscheme" (builtins.readFile ./chscheme.sh)
|
||||
|
||||
23
modules/home/scripts/nix/chscheme.sh
Executable file
23
modules/home/scripts/nix/chscheme.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
/usr/bin/env ls "$(nix-build '<nixpkgs>' -A base16-schemes)"/share/themes | \
|
||||
sed 's/\.yaml//g' | \
|
||||
fzf --preview 'cat $(nix-build "<nixpkgs>" -A base16-schemes)/share/themes/{}.yaml | \
|
||||
while IFS=": " read -r key value; do \
|
||||
if [[ $key =~ base0[0-9A-F] ]]; then \
|
||||
clean_value=$(echo $value | tr -d "\""); \
|
||||
r=$((16#${clean_value:0:2})); \
|
||||
g=$((16#${clean_value:2:2})); \
|
||||
b=$((16#${clean_value:4:2})); \
|
||||
printf "\033[48;2;%d;%d;%dm %-20s %s \033[0m\n" $r $g $b $key $clean_value; \
|
||||
fi; \
|
||||
done' | xargs -I {} sed -i '/base16scheme \=/s/\".*\"/\"{}\"/' "$HOME"/.sysflake/flake.nix && \
|
||||
echo "Successfully changed system color scheme. Rebuild now?" && \
|
||||
select choice in "Yes" "No"; do
|
||||
case $choice in
|
||||
"Yes")
|
||||
rebuild;exit 0;;
|
||||
"No")
|
||||
echo "Exiting...";exit 0;;
|
||||
esac
|
||||
done
|
||||
@@ -19,7 +19,7 @@
|
||||
grub.enable = true;
|
||||
gtk.enable = true;
|
||||
nixos-icons.enable = true;
|
||||
nixvim.enable = true;
|
||||
nixvim.enable = false;
|
||||
};
|
||||
cursor = {
|
||||
package = pkgs.bibata-cursors;
|
||||
|
||||
Reference in New Issue
Block a user