nixos-config/modules/cli/powerline.nix

69 lines
1.7 KiB
Nix
Raw Normal View History

2021-10-11 17:08:18 +00:00
{ config, pkgs, lib, ... }:
let
2021-10-11 17:08:18 +00:00
cfg = config.sconfig.powerline;
theme = pkgs.writeText "powerline.json" (builtins.toJSON
{
BoldForeground = true;
CwdFg = 15;
PathBg = 24;
PathFg = 15;
SeparatorFg = 16;
});
2021-10-11 17:08:18 +00:00
in
{
options.sconfig.powerline =
{
enable = lib.mkOption {
type = lib.types.bool;
default = true;
};
args = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [
2021-12-07 21:23:02 +00:00
"-modules=\${remote:+'user,host,'}nix-shell,shlvl,git,jobs,cwd"
2021-10-11 17:08:18 +00:00
"-git-assume-unchanged-size 0"
"-theme ${theme}"
"-path-aliases '~/git=~/git'"
2021-10-11 17:08:18 +00:00
"-jobs $(jobs -p | wc -l)"
2021-10-12 18:06:32 +00:00
] ++ config.sconfig.powerline.extraArgs;
};
extraArgs = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
2021-10-11 17:08:18 +00:00
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [
((pkgs.callPackage
(pkgs.fetchurl
{
url = "https://raw.githubusercontent.com/NixOS/nixpkgs/6ce4a720012398d451c21bc042d6740e92289615/pkgs/tools/misc/powerline-go/default.nix";
sha256 = "7a8294ac9726da9531f1e506369233b051ecc6aa32c77a281f7167027a89977e";
}
)
{ }
).overrideAttrs (old: {
2021-12-07 21:23:02 +00:00
patches = [
./shlvl.patch
];
}))
];
2021-10-11 17:08:18 +00:00
programs.bash.interactiveShellInit = ''
function _update_ps1() {
local remote=y
[ "$XDG_SESSION_TYPE" = "x11" ] && unset remote
[ "$XDG_SESSION_TYPE" = "wayland" ] && unset remote
PS1="\n$(powerline-go ${lib.concatStringsSep " " cfg.args})"
2021-10-11 17:08:18 +00:00
}
[ "$TERM" = "linux" ] || PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
'';
};
}