diff --git a/flake.nix b/flake.nix index ccce216..3ee6e56 100644 --- a/flake.nix +++ b/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 { diff --git a/modules/home/scripts/default.nix b/modules/home/scripts/default.nix index c25a980..8294126 100644 --- a/modules/home/scripts/default.nix +++ b/modules/home/scripts/default.nix @@ -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 diff --git a/modules/home/scripts/nix/chscheme.nix b/modules/home/scripts/nix/chscheme.nix new file mode 100644 index 0000000..bfe24d0 --- /dev/null +++ b/modules/home/scripts/nix/chscheme.nix @@ -0,0 +1,5 @@ +{ + pkgs, +}: +pkgs.writeShellScriptBin "chscheme" (builtins.readFile ./chscheme.sh) + diff --git a/modules/home/scripts/nix/chscheme.sh b/modules/home/scripts/nix/chscheme.sh new file mode 100755 index 0000000..75def15 --- /dev/null +++ b/modules/home/scripts/nix/chscheme.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +/usr/bin/env ls "$(nix-build '' -A base16-schemes)"/share/themes | \ + sed 's/\.yaml//g' | \ + fzf --preview 'cat $(nix-build "" -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 diff --git a/modules/sys/environment/stylix.nix b/modules/sys/environment/stylix.nix index c242b0e..33985f3 100644 --- a/modules/sys/environment/stylix.nix +++ b/modules/sys/environment/stylix.nix @@ -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;