2021-10-11 17:08:18 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
let
|
2021-10-12 17:07:33 +00:00
|
|
|
|
2021-10-11 17:08:18 +00:00
|
|
|
cfg = config.sconfig.powerline;
|
2021-10-12 17:07:33 +00:00
|
|
|
|
|
|
|
theme = pkgs.writeText "powerline.json" (builtins.toJSON
|
|
|
|
{
|
|
|
|
CwdFg = 15;
|
|
|
|
PathFg = 15;
|
|
|
|
PathBg = 24;
|
|
|
|
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-10-12 17:07:33 +00:00
|
|
|
"-modules=\${remote:+'user,host,'}nix-shell,git,jobs,cwd"
|
2021-10-11 17:08:18 +00:00
|
|
|
"-git-assume-unchanged-size 0"
|
2021-10-12 17:07:33 +00:00
|
|
|
"-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 {
|
|
|
|
|
2021-10-12 17:07:33 +00:00
|
|
|
environment.systemPackages = [
|
|
|
|
(pkgs.powerline-go.overrideAttrs (old: { patches = [ ./bold.patch ]; }))
|
|
|
|
];
|
2021-10-11 17:08:18 +00:00
|
|
|
|
|
|
|
programs.bash.interactiveShellInit = ''
|
|
|
|
function _update_ps1() {
|
2021-10-12 17:07:33 +00:00
|
|
|
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"
|
|
|
|
'';
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|