diff --git a/common/default.nix b/common/default.nix index 424753d..b479764 100644 --- a/common/default.nix +++ b/common/default.nix @@ -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 diff --git a/common/home/bash/default.nix b/common/home/bash/default.nix index 33880c4..31fd465 100644 --- a/common/home/bash/default.nix +++ b/common/home/bash/default.nix @@ -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)"; }; diff --git a/common/nix-on-droid.nix b/common/nix-on-droid.nix index 4b0c6bb..e7c7fd3 100644 --- a/common/nix-on-droid.nix +++ b/common/nix-on-droid.nix @@ -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 diff --git a/common/vars.nix b/common/vars/default.nix similarity index 59% rename from common/vars.nix rename to common/vars/default.nix index b4eb3af..4bf0a40 100644 --- a/common/vars.nix +++ b/common/vars/default.nix @@ -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 ''; diff --git a/common/vars/prompt-schemes.nix b/common/vars/prompt-schemes.nix new file mode 100644 index 0000000..209d8d3 --- /dev/null +++ b/common/vars/prompt-schemes.nix @@ -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} diff --git a/devices/binto/default.nix b/devices/binto/default.nix index 597a3fd..7dce410 100644 --- a/devices/binto/default.nix +++ b/devices/binto/default.nix @@ -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; diff --git a/devices/cluster/default.nix b/devices/cluster/default.nix index 9cad057..204d352 100644 --- a/devices/cluster/default.nix +++ b/devices/cluster/default.nix @@ -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} = { diff --git a/devices/servivi/default.nix b/devices/servivi/default.nix index 29f01c2..be18313 100644 --- a/devices/servivi/default.nix +++ b/devices/servivi/default.nix @@ -18,6 +18,7 @@ in { vars = { mainUser = "matt"; hostName = "servivi"; + promptMainColor = "blue"; }; users.users = { diff --git a/devices/wim/default.nix b/devices/wim/default.nix index d2d33e1..93f6963 100644 --- a/devices/wim/default.nix +++ b/devices/wim/default.nix @@ -19,6 +19,7 @@ in { vars = { mainUser = "matt"; hostName = "wim"; + promptMainColor = "purple"; fontSize = 12.5; mainMonitor = "eDP-1"; };