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";
|
system = "x86_64-linux";
|
||||||
username = "pagedmov";
|
username = "pagedmov";
|
||||||
wallpaper = "${self}/media/wallpapers/cabin-2.jpg";
|
wallpaper = "${self}/media/wallpapers/cabin-2.jpg";
|
||||||
|
base16scheme = "chalk"; # can be easily changed with the chscheme script
|
||||||
|
|
||||||
# Base 16 scheme for system colors
|
# Map colors from yaml to attribute set
|
||||||
scheme = {
|
# Extracting colors into a set here allows them to be propagated across the entire config
|
||||||
"base00" = "151515";
|
lib = nixpkgs.lib;
|
||||||
"base01" = "202020";
|
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||||
"base02" = "303030";
|
scheme_path = "${pkgs.base16-schemes}/share/themes/${base16scheme}.yaml";
|
||||||
"base03" = "505050";
|
scheme_string = builtins.readFile scheme_path;
|
||||||
"base04" = "b0b0b0";
|
scheme_list = lib.splitString "\n" "${scheme_string}";
|
||||||
"base05" = "d0d0d0";
|
colors = lib.filter (line: builtins.match "^ *base[0-9A-F]{2}: .*" line != null) scheme_list;
|
||||||
"base06" = "e0e0e0";
|
scheme = lib.lists.foldl' (acc: line:
|
||||||
"base07" = "f5f5f5";
|
let
|
||||||
"base08" = "fb9fb1";
|
splitLine = lib.splitString ": " line;
|
||||||
"base09" = "eda987";
|
key = builtins.elemAt splitLine 0;
|
||||||
"base0A" = "ddb26f";
|
value = builtins.elemAt splitLine 1;
|
||||||
"base0B" = "acc267";
|
trimmedKey = lib.trim key;
|
||||||
"base0C" = "12cfc0";
|
cleanValue_step1 = lib.splitString " " value;
|
||||||
"base0D" = "6fc2ef";
|
cleanValue_step2 = builtins.elemAt cleanValue_step1 0;
|
||||||
"base0E" = "e1a3ee";
|
cleanValue_final = builtins.substring 1 (builtins.stringLength cleanValue_step2 - 2) cleanValue_step2;
|
||||||
"base0F" = "deaf8f";
|
in
|
||||||
};
|
acc // { "${trimmedKey}" = cleanValue_final; }
|
||||||
|
) {} colors;
|
||||||
in {
|
in {
|
||||||
nixosConfigurations = {
|
nixosConfigurations = {
|
||||||
oganesson = nixpkgs.lib.nixosSystem {
|
oganesson = nixpkgs.lib.nixosSystem {
|
||||||
|
|||||||
@@ -102,6 +102,9 @@
|
|||||||
self = self;
|
self = self;
|
||||||
pkgs = pkgs;
|
pkgs = pkgs;
|
||||||
};
|
};
|
||||||
|
chscheme = import ./nix/chscheme.nix {
|
||||||
|
pkgs = pkgs;
|
||||||
|
};
|
||||||
nixcommit = import ./nix/nixcommit.nix {
|
nixcommit = import ./nix/nixcommit.nix {
|
||||||
host = host;
|
host = host;
|
||||||
self = self;
|
self = self;
|
||||||
@@ -114,6 +117,7 @@
|
|||||||
in {
|
in {
|
||||||
home.packages = [
|
home.packages = [
|
||||||
compress
|
compress
|
||||||
|
chscheme
|
||||||
passhelper
|
passhelper
|
||||||
crs
|
crs
|
||||||
extract
|
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;
|
grub.enable = true;
|
||||||
gtk.enable = true;
|
gtk.enable = true;
|
||||||
nixos-icons.enable = true;
|
nixos-icons.enable = true;
|
||||||
nixvim.enable = true;
|
nixvim.enable = false;
|
||||||
};
|
};
|
||||||
cursor = {
|
cursor = {
|
||||||
package = pkgs.bibata-cursors;
|
package = pkgs.bibata-cursors;
|
||||||
|
|||||||
Reference in New Issue
Block a user