Merge pull request #149423 from danth/starship-module
nixos/starship: init
This commit is contained in:
commit
7723f38aab
|
@ -424,6 +424,15 @@
|
|||
renamed to <literal>linux-firmware</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
A new module was added for the
|
||||
<link xlink:href="https://starship.rs/">Starship</link> shell
|
||||
prompt, providing the options
|
||||
<literal>programs.starship.enable</literal> and
|
||||
<literal>programs.starship.settings</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
</section>
|
||||
|
|
|
@ -148,3 +148,6 @@ In addition to numerous new and upgraded packages, this release has the followin
|
|||
- The option `services.thelounge.plugins` has been added to allow installing plugins for The Lounge. Plugins can be found in `pkgs.theLoungePlugins.plugins` and `pkgs.theLoungePlugins.themes`.
|
||||
|
||||
- The `firmwareLinuxNonfree` package has been renamed to `linux-firmware`.
|
||||
|
||||
- A new module was added for the [Starship](https://starship.rs/) shell prompt,
|
||||
providing the options `programs.starship.enable` and `programs.starship.settings`.
|
||||
|
|
|
@ -198,6 +198,7 @@
|
|||
./programs/ssmtp.nix
|
||||
./programs/sysdig.nix
|
||||
./programs/systemtap.nix
|
||||
./programs/starship.nix
|
||||
./programs/steam.nix
|
||||
./programs/sway.nix
|
||||
./programs/system-config-printer.nix
|
||||
|
|
51
nixos/modules/programs/starship.nix
Normal file
51
nixos/modules/programs/starship.nix
Normal file
|
@ -0,0 +1,51 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.programs.starship;
|
||||
|
||||
settingsFormat = pkgs.formats.toml { };
|
||||
|
||||
settingsFile = settingsFormat.generate "starship.toml" cfg.settings;
|
||||
|
||||
in {
|
||||
options.programs.starship = {
|
||||
enable = mkEnableOption "the Starship shell prompt";
|
||||
|
||||
settings = mkOption {
|
||||
inherit (settingsFormat) type;
|
||||
default = { };
|
||||
description = ''
|
||||
Configuration included in <literal>starship.toml</literal>.
|
||||
|
||||
See https://starship.rs/config/#prompt for documentation.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
programs.bash.promptInit = ''
|
||||
if [[ $TERM != "dumb" && (-z $INSIDE_EMACS || $INSIDE_EMACS == "vterm") ]]; then
|
||||
export STARSHIP_CONFIG=${settingsFile}
|
||||
eval "$(${pkgs.starship}/bin/starship init bash)"
|
||||
fi
|
||||
'';
|
||||
|
||||
programs.fish.promptInit = ''
|
||||
if test "$TERM" != "dumb" -a \( -z "$INSIDE_EMACS" -o "$INSIDE_EMACS" = "vterm" \)
|
||||
set -x STARSHIP_CONFIG ${settingsFile}
|
||||
eval (${pkgs.starship}/bin/starship init fish)
|
||||
end
|
||||
'';
|
||||
|
||||
programs.zsh.promptInit = ''
|
||||
if [[ $TERM != "dumb" && (-z $INSIDE_EMACS || $INSIDE_EMACS == "vterm") ]]; then
|
||||
export STARSHIP_CONFIG=${settingsFile}
|
||||
eval "$(${pkgs.starship}/bin/starship init zsh)"
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
meta.maintainers = pkgs.starship.meta.maintainers;
|
||||
}
|
|
@ -445,6 +445,7 @@ in
|
|||
sslh = handleTest ./sslh.nix {};
|
||||
sssd = handleTestOn ["x86_64-linux"] ./sssd.nix {};
|
||||
sssd-ldap = handleTestOn ["x86_64-linux"] ./sssd-ldap.nix {};
|
||||
starship = handleTest ./starship.nix {};
|
||||
step-ca = handleTestOn ["x86_64-linux"] ./step-ca.nix {};
|
||||
strongswan-swanctl = handleTest ./strongswan-swanctl.nix {};
|
||||
sudo = handleTest ./sudo.nix {};
|
||||
|
|
31
nixos/tests/starship.nix
Normal file
31
nixos/tests/starship.nix
Normal file
|
@ -0,0 +1,31 @@
|
|||
import ./make-test-python.nix ({ pkgs, ... }: {
|
||||
name = "starship";
|
||||
meta.maintainers = pkgs.starship.meta.maintainers;
|
||||
|
||||
machine = {
|
||||
programs = {
|
||||
fish.enable = true;
|
||||
zsh.enable = true;
|
||||
|
||||
starship = {
|
||||
enable = true;
|
||||
settings.format = "<starship>";
|
||||
};
|
||||
};
|
||||
|
||||
services.getty.autologinUser = "root";
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
start_all()
|
||||
machine.wait_for_unit("default.target")
|
||||
|
||||
for shell in ["bash", "fish", "zsh"]:
|
||||
machine.send_chars(f"script -c {shell} /tmp/{shell}.txt\n")
|
||||
machine.wait_until_tty_matches(1, f"Script started.*{shell}.txt")
|
||||
machine.send_chars("exit\n")
|
||||
machine.wait_until_tty_matches(1, "Script done")
|
||||
machine.sleep(1)
|
||||
machine.succeed(f"grep -q '<starship>' /tmp/{shell}.txt")
|
||||
'';
|
||||
})
|
|
@ -6,6 +6,7 @@
|
|||
, openssl
|
||||
, installShellFiles
|
||||
, libiconv
|
||||
, nixosTests
|
||||
, Security
|
||||
}:
|
||||
|
||||
|
@ -40,10 +41,14 @@ rustPlatform.buildRustPackage rec {
|
|||
HOME=$TMPDIR
|
||||
'';
|
||||
|
||||
passthru.tests = {
|
||||
inherit (nixosTests) starship;
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
description = "A minimal, blazing fast, and extremely customizable prompt for any shell";
|
||||
homepage = "https://starship.rs";
|
||||
license = licenses.isc;
|
||||
maintainers = with maintainers; [ bbigras davidtwco Br1ght0ne Frostman marsam ];
|
||||
maintainers = with maintainers; [ bbigras danth davidtwco Br1ght0ne Frostman marsam ];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue