Bash : Use stylix.

This commit is contained in:
Dmitry Voronin 2024-04-03 06:21:29 +03:00
parent c20b960499
commit 5c8fde310a
4 changed files with 104 additions and 33 deletions

View file

@ -1,6 +1,9 @@
{ pkgs, inputs, const, ... }: let { pkgs, inputs, const, config, ... }: let
homePath = "/data/data/com.termux.nix/files/home"; homePath = "/data/data/com.termux.nix/files/home";
tmuxScript = pkgs.writeShellScriptBin "tmux_script" (builtins.readFile ./common/tmux/Script.sh); tmuxScript = pkgs.writeShellScriptBin "tmux_script" (builtins.readFile ./common/tmux/Script.sh);
bash = import ./common/bash/Bash.nix { config = config; };
bg = config.lib.stylix.colors.base00;
fg = config.lib.stylix.colors.base04;
in { in {
# NOTE: Split into modules? # NOTE: Split into modules?
environment.packages = with pkgs; [ environment.packages = with pkgs; [
@ -56,10 +59,10 @@ in {
".termux/_font.ttf".source = pkgs.runCommandNoCC "font" {} '' ".termux/_font.ttf".source = pkgs.runCommandNoCC "font" {} ''
cp ${pkgs.nerdfonts.override { fonts = [ "Terminus" ]; }}/share/fonts/truetype/NerdFonts/TerminessNerdFontMono-Regular.ttf $out cp ${pkgs.nerdfonts.override { fonts = [ "Terminus" ]; }}/share/fonts/truetype/NerdFonts/TerminessNerdFontMono-Regular.ttf $out
''; '';
# ".termux/_colors.properties".text = '' ".termux/_colors.properties".text = ''
# background=#${bg} background=#${bg}
# foreground=#${fg} foreground=#${fg}
# ''; '';
}; };
home.sessionVariables = { home.sessionVariables = {
BASH_PATH = ./common/bash; BASH_PATH = ./common/bash;
@ -71,8 +74,7 @@ in {
}; };
programs.bash = { programs.bash = {
enable = true; enable = true;
bashrcExtra = '' bashrcExtra = bash.config + ''
source $BASH_PATH/Bashrc.sh
[[ -f ~/.termux/font.ttf ]] || { [[ -f ~/.termux/font.ttf ]] || {
cp ~/.termux/_font.ttf ~/.termux/font.ttf cp ~/.termux/_font.ttf ~/.termux/font.ttf
# cp ~/.termux/_colors.properties ~/.termux/colors.properties # cp ~/.termux/_colors.properties ~/.termux/colors.properties
@ -100,5 +102,49 @@ in {
vimAlias = true; vimAlias = true;
extraConfig = (import ./common/nvim/Init.nix { inputs = inputs; }).customRc; extraConfig = (import ./common/nvim/Init.nix { inputs = inputs; }).customRc;
}; };
stylix = {
image = wallpaper.path;
autoEnable = true;
polarity = "dark";
# base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-dark-hard.yaml";
opacity = {
applications = 0.85;
terminal = 0.85;
popups = 0.85;
desktop = 0.85;
};
cursor = {
name = "phinger-cursors";
package = pkgs.phinger-cursors;
size = 24;
};
fonts = {
sizes = {
applications = 12;
terminal = 12;
popups = 12;
desktop = 12;
};
serif = {
package = (pkgs.callPackage ./applefont {});
name = "SF Pro Display";
};
sansSerif = config.stylix.fonts.serif;
monospace = {
package = (pkgs.nerdfonts.override { fonts = [ "Terminus" ]; });
name = "Terminess Nerd Font Mono";
};
emoji = {
package = pkgs.noto-fonts-emoji;
name = "Noto Color Emoji";
};
};
# targets = {
# foot = {
# enable = true;
# };
# };
};
}; };
} }

View file

@ -1,5 +1,7 @@
{ lib, ... }: { { lib, config, ... }: let
programs.bash.interactiveShellInit = "source $BASH_PATH/Bashrc.sh"; bash = import ./bash/Bash.nix { config = config; };
in {
programs.bash.interactiveShellInit = bash.config;
environment.shellAliases = lib.mkForce {}; environment.shellAliases = lib.mkForce {};
environment.variables = { environment.variables = {
BASH_PATH = ./bash; BASH_PATH = ./bash;

View file

@ -0,0 +1,46 @@
{ config, ... }: let
negative-r = config.lib.stylix.colors.base08-rgb-r;
negative-g = config.lib.stylix.colors.base08-rgb-g;
negative-b = config.lib.stylix.colors.base08-rgb-b;
neutral-r = config.lib.stylix.colors.base0C-rgb-r;
neutral-g = config.lib.stylix.colors.base0C-rgb-g;
neutral-b = config.lib.stylix.colors.base0C-rgb-b;
positive-r = config.lib.stylix.colors.base0B-rgb-r;
positive-g = config.lib.stylix.colors.base0B-rgb-g;
positive-b = config.lib.stylix.colors.base0B-rgb-b;
accent-r = config.lib.stylix.colors.base0A-rgb-r;
accent-g = config.lib.stylix.colors.base0A-rgb-g;
accent-b = config.lib.stylix.colors.base0A-rgb-b;
in {
config = ''
# If not running interactively, don't do anything.
[[ "$-" != *i* ]] && return
# Src system bashrc.
[[ -f /etc/bashrc ]] && source /etc/bashrc
# Define colors.
export negative_rgb="${negative-r};${negative-g};${negative-b}"
export neutral_rgb="${neutral-r};${neutral-g};${neutral-b}"
export positive_rgb="${positive-r};${positive-g};${positive-b}"
export accent_rgb="${accent-r};${accent-g};${accent-b}"
# Src custom modules.
for module in $BASH_PATH/module/*.sh; do
source "$module"
done
# Alias to reload.
function bashrc() {
source $BASH_PATH/Bashrc.sh
}
# Export all functions.
export -f $(find_function | tr '\n' ' ')
# Autostart Sway.
if [[ -z $DISPLAY ]] && [[ "$(tty)" = "/dev/tty1" ]]; then
exec sway
fi
'';
}

View file

@ -1,23 +0,0 @@
# If not running interactively, don't do anything.
[[ "$-" != *i* ]] && return
# Src system bashrc.
[[ -f /etc/bashrc ]] && source /etc/bashrc
# Src custom modules.
for module in ${BASH_PATH}/module/*.sh; do
source "${module}"
done
# Alias to reload.
function bashrc() {
source ${BASH_PATH}/Bashrc.sh
}
# Export all functions.
export -f $(find_function | tr '\n' ' ')
# Autostart Sway.
if [[ -z ${DISPLAY} ]] && [[ "$(tty)" = "/dev/tty1" ]]; then
exec sway
fi