feat(vars): add different color schemes for starship prompt
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-01-24 18:39:18 -05:00
parent f8b89f8fcf
commit ae55d93ace
9 changed files with 106 additions and 26 deletions

View file

@ -9,7 +9,7 @@
...
} @ inputs: {
imports = [
./vars.nix
./vars
./modules
./pkgs
@ -65,7 +65,7 @@
default = {
imports = [
# Make the vars be the same on Nix and HM
./vars.nix
./vars
{vars = config.vars;}
nur.hmModules.nur

View file

@ -1,12 +1,10 @@
{lib, ...}: let
inherit (lib) fileContents;
# TODO: have different colors depending on host
textColor = "#e3e5e5";
firstColor = "#bd93f9";
secondColor = "#715895";
thirdColor = "#382c4a";
fourthColor = "#120e18";
{
config,
lib,
...
}: let
inherit (lib) concatStrings fileContents;
inherit (config.vars) promptColors;
in {
imports = [./programs.nix];
@ -14,36 +12,37 @@ in {
starship = {
enable = true;
enableBashIntegration = true;
settings = {
format = lib.concatStrings [
format = concatStrings [
""
"[](fg:${firstColor})"
"[ ](bg:${firstColor} fg:#090c0c)"
"[](bg:${secondColor} fg:${firstColor})"
"[](fg:${promptColors.firstColor})"
"[ ](bg:${promptColors.firstColor} fg:#090c0c)"
"[](bg:${promptColors.secondColor} fg:${promptColors.firstColor})"
"$username$hostname"
"[](fg:${secondColor} bg:${thirdColor})"
"[](fg:${promptColors.secondColor} bg:${promptColors.thirdColor})"
"$directory"
"[](fg:${thirdColor} bg:${fourthColor})"
"[](fg:${promptColors.thirdColor} bg:${promptColors.fourthColor})"
"$git_branch"
"[](fg:${fourthColor})"
"[](fg:${promptColors.fourthColor})"
"\n$shlvl$nix_shell$character"
];
username = {
show_always = true;
style_user = "fg:${textColor} bg:${secondColor}";
style_root = "fg:red bg:${secondColor} blink";
style_user = "fg:${promptColors.textColor} bg:${promptColors.secondColor}";
style_root = "fg:red bg:${promptColors.secondColor} blink";
format = "[ $user]($style)";
};
hostname = {
ssh_only = false;
style = "fg:${textColor} bg:${secondColor}";
style = "fg:${promptColors.textColor} bg:${promptColors.secondColor}";
format = "[@$hostname ]($style)";
};
directory = {
style = "fg:${firstColor} bg:${thirdColor}";
style = "fg:${promptColors.firstColor} bg:${promptColors.thirdColor}";
format = "[ $path ]($style)";
truncate_to_repo = false;
truncation_length = 0;
@ -57,7 +56,7 @@ in {
};
git_branch = {
style = "fg:${secondColor} bg:${fourthColor}";
style = "fg:${promptColors.secondColor} bg:${promptColors.fourthColor}";
symbol = "";
format = "[ $symbol $branch ]($style)";
};

View file

@ -4,7 +4,7 @@
...
}: {
imports = [
./vars.nix
./vars
./pkgs
./modules/global.nix
nur.nixosModules.nur
@ -39,7 +39,7 @@
home-manager.config = {
imports = [
# Make the vars be the same on Nix and HM
./vars.nix
./vars
{vars = config.vars;}
nur.hmModules.nur

View file

@ -21,6 +21,32 @@
'';
};
promptMainColor = mkOption {
type = types.enum ["red" "green" "blue" "purple"];
default = "purple";
};
promptColors = mkOption {
description = ''
Colors used in starship prompt
'';
default = import ./prompt-schemes.nix cfg.promptMainColor;
# FIXME: doesn't work when passing vars to home-manager
# readOnly = true;
type = with types;
submodule {
options = {
textColor = mkOption {type = str;};
firstColor = mkOption {type = str;};
secondColor = mkOption {type = str;};
thirdColor = mkOption {type = str;};
fourthColor = mkOption {type = str;};
};
};
};
configDir = mkOption {
type = types.str;
default = "/home/${cfg.mainUser}/.nix/devices/${cfg.hostName}/config";
@ -35,11 +61,12 @@
The name of the main monitor used for Hyprland
and Regreet which also uses Hyprland
'';
# This is to allow a bash script to know wether this value exists
default = "null";
};
greetdDupe = mkOption {
type = types.nullOr types.bool;
type = types.bool;
description = ''
If we should duplicate regreet on all monitors
'';

View file

@ -0,0 +1,45 @@
color: let
schemes = {
"purple" = {
textColor = "#e3e5e5";
firstColor = "#bd93f9";
secondColor = "#715895";
thirdColor = "#382c4a";
fourthColor = "#120e18";
};
"green" = {
textColor = "#e3e5e5";
firstColor = "#78ae66";
secondColor = "#567c49";
thirdColor = "#334a2c";
fourthColor = "#11180e";
};
"red" = {
textColor = "#e3e5e5";
firstColor = "#9d0909";
secondColor = "#700707";
thirdColor = "#430404";
fourthColor = "#160101";
};
"blue" = {
textColor = "#e3e5e5";
firstColor = "#092a9d";
secondColor = "#071e70";
thirdColor = "#041243";
fourthColor = "#010616";
};
# Template
"color" = {
textColor = "#e3e5e5";
firstColor = "";
secondColor = "";
thirdColor = "";
fourthColor = "";
};
};
in
schemes.${color}

View file

@ -21,6 +21,7 @@ in {
vars = {
mainUser = "matt";
hostName = "binto";
promptMainColor = "purple";
mainMonitor = "desc:GIGA-BYTE TECHNOLOGY CO. LTD. G27QC 0x00000B1D";
greetdDupe = false;
fontSize = 12.5;

View file

@ -16,6 +16,12 @@ in {
vars = {
mainUser = "matt";
hostName = deviceName;
promptMainColor =
if deviceName == "thingone"
then "green"
else if deviceName == "thingtwo"
then "red"
else "purple";
};
users.users.${mainUser} = {

View file

@ -18,6 +18,7 @@ in {
vars = {
mainUser = "matt";
hostName = "servivi";
promptMainColor = "blue";
};
users.users = {

View file

@ -19,6 +19,7 @@ in {
vars = {
mainUser = "matt";
hostName = "wim";
promptMainColor = "purple";
fontSize = 12.5;
mainMonitor = "eDP-1";
};