From 4ba4d8cfab612c341f74fa11b5c01c9dee3cf283 Mon Sep 17 00:00:00 2001 From: Myned Date: Thu, 26 Dec 2024 00:26:26 -0500 Subject: [PATCH] starship: initial program Signed-off-by: Myned --- options/custom/programs/default.nix | 1 + options/custom/programs/starship/default.nix | 229 ++++++++++++++++++ .../starship/presets/nerd-font-symbols.toml | 170 +++++++++++++ .../starship/presets/no-runtime-versions.toml | 131 ++++++++++ 4 files changed, 531 insertions(+) create mode 100644 options/custom/programs/starship/default.nix create mode 100644 options/custom/programs/starship/presets/nerd-font-symbols.toml create mode 100644 options/custom/programs/starship/presets/no-runtime-versions.toml diff --git a/options/custom/programs/default.nix b/options/custom/programs/default.nix index 8c2de5e..e2a1db1 100644 --- a/options/custom/programs/default.nix +++ b/options/custom/programs/default.nix @@ -20,6 +20,7 @@ with lib; { nushell.enable = true; polkit.enable = true; ssh.enable = true; + starship.enable = true; sudo.enable = true; tmux.enable = true; }) diff --git a/options/custom/programs/starship/default.nix b/options/custom/programs/starship/default.nix new file mode 100644 index 0000000..47e3b68 --- /dev/null +++ b/options/custom/programs/starship/default.nix @@ -0,0 +1,229 @@ +{ + config, + lib, + ... +}: +with lib; let + cfg = config.custom.programs.starship; +in { + options.custom.programs.starship = { + enable = mkOption {default = false;}; + transience = mkOption {default = true;}; + }; + + config = mkIf cfg.enable { + # https://starship.rs/ + # https://wiki.nixos.org/wiki/Starship + programs.starship.enable = true; + + home-manager.sharedModules = [ + { + programs = { + starship = { + enable = true; + enableTransience = cfg.transience; + + # https://starship.rs/config/ + # https://www.nerdfonts.com/cheat-sheet + settings = + ### Presets + # https://starship.rs/presets/ + #?? starship preset PRESET | wl-copy + #!! Manually import from preset file + # https://github.com/nix-community/home-manager/issues/4231 + recursiveUpdate ( + recursiveUpdate + (fromTOML (readFile ./presets/nerd-font-symbols.toml)) + (fromTOML (readFile ./presets/no-runtime-versions.toml)) + ) + { + ### Overrides + # https://starship.rs/config/#prompt + add_newline = false; + + format = concatStringsSep "" [ + # Top left + "$shell" + "$all" + "$fill" + + # Top right + "$cmd_duration" + "$time" + "$battery" + "$os" + "$line_break" + + # Bottom left + "$jobs" + "$character" + ]; + + # https://starship.rs/config/#battery + battery = { + format = " [$symbol]($style)"; + + display = [ + { + threshold = 15; + style = "bold red"; + } + + { + threshold = 30; + style = "bold yellow"; + } + ]; + }; + + # https://starship.rs/config/#character + character = { + error_symbol = "[](bold red) "; + success_symbol = "[](bold) "; + }; + + # https://starship.rs/config/#command-duration + cmd_duration = { + format = "[󱎫 $duration](#586e75)"; + min_time = 5 * 1000; # Milliseconds + }; + + # https://starship.rs/config/#directory + directory = { + format = " [$path]($style)[$read_only]($read_only_style) "; + repo_root_format = " [$before_root_path]($before_repo_root_style)[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) "; + style = "bold #657b83"; + before_repo_root_style = "bold #586e75"; + repo_root_style = "bold"; + fish_style_pwd_dir_length = 1; + truncation_length = 1; + truncation_symbol = "…/"; + use_os_path_sep = false; + }; + + # https://starship.rs/config/#fill + fill = { + symbol = " "; + }; + + # https://starship.rs/config/#git-branch + git_branch = { + format = "[$symbol$branch(:$remote_branch)]($style) "; + }; + + # https://starship.rs/config/#hostname + hostname = { + format = "[[@](#586e75)$hostname]($style) "; + style = "bold"; + }; + + # https://starship.rs/config/#local-ip + localip = { + disabled = false; + }; + + # https://starship.rs/config/#os + os = { + disabled = false; + style = "bold"; + + # "ICON " required for proper size + symbols = { + AIX = "  "; + Alpaquita = "  "; + AlmaLinux = "  "; + Alpine = "  "; + Amazon = "  "; + Android = "  "; + Arch = "  "; + Artix = "  "; + CentOS = "  "; + Debian = "  "; + DragonFly = "  "; + Emscripten = " 󰯁 "; + EndeavourOS = "  "; + Fedora = "  "; + FreeBSD = "  "; + Garuda = "  "; + Gentoo = "  "; + HardenedBSD = " 󰥯 "; + Illumos = "  "; + Kali = "  "; + Linux = " 󰌽 "; + Mabox = "  "; + Macos = "  "; + Manjaro = "  "; + Mariner = "  "; + MidnightBSD = " 󰖔 "; + Mint = " 󰣭 "; + NetBSD = "  "; + NixOS = "  "; + OpenBSD = "  "; + OpenCloudOS = "  "; + openEuler = " 󰏒 "; + openSUSE = "  "; + OracleLinux = "  "; + Pop = "  "; + Raspbian = "  "; + Redhat = "  "; + RedHatEnterprise = "  "; + RockyLinux = "  "; + Redox = " 󰙨 "; + Solus = "  "; + SUSE = "  "; + Ubuntu = "  "; + Ultramarine = " 󰜃 "; + Unknown = "  "; + Void = "  "; + Windows = "  "; + }; + }; + + # https://starship.rs/config/#shell + shell = { + disabled = false; + style = "bold"; + + bash_indicator = " "; + cmd_indicator = " "; + elvish_indicator = "󰲋 "; + fish_indicator = " "; + ion_indicator = " "; + nu_indicator = "󰟢 "; + powershell_indicator = " "; + tcsh_indicator = " "; + unknown_indicator = " "; + xonsh_indicator = " "; + zsh_indicator = " "; + }; + + # https://starship.rs/config/#time + time = { + disabled = false; + format = " [$time]($style)"; + style = "bold #657b83"; + + # https://docs.rs/chrono/latest/chrono/format/strftime/index.html + time_format = "%a %b %-d %I:%M%P"; + }; + + # https://starship.rs/config/#username + username = { + format = "[$user]($style)"; + style_user = "bold #6c71c4"; + show_always = true; + }; + }; + }; + + fish.functions = mkIf cfg.transience { + # https://starship.rs/advanced-config/#transientprompt-and-transientrightprompt-in-fish + starship_transient_prompt_func = '' + starship module character + ''; + }; + }; + } + ]; + }; +} diff --git a/options/custom/programs/starship/presets/nerd-font-symbols.toml b/options/custom/programs/starship/presets/nerd-font-symbols.toml new file mode 100644 index 0000000..65c0b74 --- /dev/null +++ b/options/custom/programs/starship/presets/nerd-font-symbols.toml @@ -0,0 +1,170 @@ +[aws] +symbol = " " + +[buf] +symbol = " " + +[c] +symbol = " " + +[conda] +symbol = " " + +[crystal] +symbol = " " + +[dart] +symbol = " " + +[directory] +read_only = " 󰌾" + +[docker_context] +symbol = " " + +[elixir] +symbol = " " + +[elm] +symbol = " " + +[fennel] +symbol = " " + +[fossil_branch] +symbol = " " + +[git_branch] +symbol = " " + +[git_commit] +tag_symbol = '  ' + +[golang] +symbol = " " + +[guix_shell] +symbol = " " + +[haskell] +symbol = " " + +[haxe] +symbol = " " + +[hg_branch] +symbol = " " + +[hostname] +ssh_symbol = " " + +[java] +symbol = " " + +[julia] +symbol = " " + +[kotlin] +symbol = " " + +[lua] +symbol = " " + +[memory_usage] +symbol = "󰍛 " + +[meson] +symbol = "󰔷 " + +[nim] +symbol = "󰆥 " + +[nix_shell] +symbol = " " + +[nodejs] +symbol = " " + +[ocaml] +symbol = " " + +[os.symbols] +Alpaquita = " " +Alpine = " " +AlmaLinux = " " +Amazon = " " +Android = " " +Arch = " " +Artix = " " +CentOS = " " +Debian = " " +DragonFly = " " +Emscripten = " " +EndeavourOS = " " +Fedora = " " +FreeBSD = " " +Garuda = "󰛓 " +Gentoo = " " +HardenedBSD = "󰞌 " +Illumos = "󰈸 " +Kali = " " +Linux = " " +Mabox = " " +Macos = " " +Manjaro = " " +Mariner = " " +MidnightBSD = " " +Mint = " " +NetBSD = " " +NixOS = " " +OpenBSD = "󰈺 " +openSUSE = " " +OracleLinux = "󰌷 " +Pop = " " +Raspbian = " " +Redhat = " " +RedHatEnterprise = " " +RockyLinux = " " +Redox = "󰀘 " +Solus = "󰠳 " +SUSE = " " +Ubuntu = " " +Unknown = " " +Void = " " +Windows = "󰍲 " + +[package] +symbol = "󰏗 " + +[perl] +symbol = " " + +[php] +symbol = " " + +[pijul_channel] +symbol = " " + +[python] +symbol = " " + +[rlang] +symbol = "󰟔 " + +[ruby] +symbol = " " + +[rust] +symbol = "󱘗 " + +[scala] +symbol = " " + +[swift] +symbol = " " + +[zig] +symbol = " " + +[gradle] +symbol = " " diff --git a/options/custom/programs/starship/presets/no-runtime-versions.toml b/options/custom/programs/starship/presets/no-runtime-versions.toml new file mode 100644 index 0000000..b411bd4 --- /dev/null +++ b/options/custom/programs/starship/presets/no-runtime-versions.toml @@ -0,0 +1,131 @@ +[bun] +format = "via [$symbol]($style)" + +[buf] +format = "via [$symbol]($style)" + +[cmake] +format = "via [$symbol]($style)" + +[cobol] +format = "via [$symbol]($style)" + +[crystal] +format = "via [$symbol]($style)" + +[daml] +format = "via [$symbol]($style)" + +[dart] +format = "via [$symbol]($style)" + +[deno] +format = "via [$symbol]($style)" + +[dotnet] +format = "[$symbol(󰓾 $tfm )]($style)" + +[elixir] +format = 'via [$symbol]($style)' + +[elm] +format = 'via [$symbol]($style)' + +[erlang] +format = 'via [$symbol]($style)' + +[fennel] +format = 'via [$symbol]($style)' + +[gleam] +format = 'via [$symbol]($style)' + +[golang] +format = 'via [$symbol]($style)' + +[gradle] +format = 'via [$symbol]($style)' + +[haxe] +format = 'via [$symbol]($style)' + +[helm] +format = 'via [$symbol]($style)' + +[java] +format = 'via [$symbol]($style)' + +[julia] +format = 'via [$symbol]($style)' + +[kotlin] +format = 'via [$symbol]($style)' + +[lua] +format = 'via [$symbol]($style)' + +[meson] +format = 'via [$symbol]($style)' + +[nim] +format = 'via [$symbol]($style)' + +[nodejs] +format = 'via [$symbol]($style)' + +[ocaml] +format = 'via [$symbol(\($switch_indicator$switch_name\) )]($style)' + +[opa] +format = 'via [$symbol]($style)' + +[perl] +format = 'via [$symbol]($style)' + +[php] +format = 'via [$symbol]($style)' + +[pulumi] +format = 'via [$symbol$stack]($style)' + +[purescript] +format = 'via [$symbol]($style)' + +[python] +format = 'via [$symbol]($style)' + +[quarto] +format = 'via [$symbol]($style)' + +[raku] +format = 'via [$symbol]($style)' + +[red] +format = 'via [$symbol]($style)' + +[rlang] +format = 'via [$symbol]($style)' + +[ruby] +format = 'via [$symbol]($style)' + +[rust] +format = 'via [$symbol]($style)' + +[solidity] +format = 'via [$symbol]($style)' + +[typst] +format = 'via [$symbol]($style)' + +[swift] +format = 'via [$symbol]($style)' + +[vagrant] +format = 'via [$symbol]($style)' + +[vlang] +format = 'via [$symbol]($style)' + +[zig] +format = 'via [$symbol]($style)'