2017-01-07 18:16:26 +00:00
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
|
|
cfg = config.programs.gnome-terminal;
|
|
|
|
|
|
2019-01-03 15:35:15 +00:00
|
|
|
|
vteInitStr = ''
|
|
|
|
|
# gnome-terminal: Show current directory in the terminal window title.
|
|
|
|
|
. ${pkgs.gnome3.vte}/etc/profile.d/vte.sh
|
|
|
|
|
'';
|
|
|
|
|
|
2019-03-26 16:26:47 +00:00
|
|
|
|
backForeSubModule = types.submodule (
|
|
|
|
|
{ ... }: {
|
|
|
|
|
options = {
|
|
|
|
|
foreground = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
description = "The foreground color.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
background = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
description = "The background color.";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2017-01-07 18:16:26 +00:00
|
|
|
|
profileColorsSubModule = types.submodule (
|
|
|
|
|
{ ... }: {
|
|
|
|
|
options = {
|
|
|
|
|
foregroundColor = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
description = "The foreground color.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
backgroundColor = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
description = "The background color.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
boldColor = mkOption {
|
|
|
|
|
default = null;
|
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
description = "The bold color, null to use same as foreground.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
palette = mkOption {
|
|
|
|
|
type = types.listOf types.str;
|
|
|
|
|
description = "The terminal palette.";
|
|
|
|
|
};
|
2019-03-26 16:26:47 +00:00
|
|
|
|
|
|
|
|
|
cursor = mkOption {
|
|
|
|
|
default = null;
|
|
|
|
|
type = types.nullOr backForeSubModule;
|
|
|
|
|
description = "The color for the terminal cursor.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
highlight = mkOption {
|
|
|
|
|
default = null;
|
|
|
|
|
type = types.nullOr backForeSubModule;
|
|
|
|
|
description = "The colors for the terminal’s highlighted area.";
|
|
|
|
|
};
|
2017-01-07 18:16:26 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
profileSubModule = types.submodule (
|
|
|
|
|
{ name, config, ... }: {
|
|
|
|
|
options = {
|
|
|
|
|
default = mkOption {
|
|
|
|
|
default = false;
|
|
|
|
|
type = types.bool;
|
|
|
|
|
description = "Whether this should be the default profile.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
visibleName = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
description = "The profile name.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
colors = mkOption {
|
|
|
|
|
default = null;
|
|
|
|
|
type = types.nullOr profileColorsSubModule;
|
|
|
|
|
description = "The terminal colors, null to use system default.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
cursorShape = mkOption {
|
|
|
|
|
default = "block";
|
|
|
|
|
type = types.enum [ "block" "ibeam" "underline" ];
|
|
|
|
|
description = "The cursor shape.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
font = mkOption {
|
|
|
|
|
default = null;
|
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
|
description = "The font name, null to use system default.";
|
|
|
|
|
};
|
|
|
|
|
|
2019-03-26 16:26:47 +00:00
|
|
|
|
allowBold = mkOption {
|
|
|
|
|
default = null;
|
|
|
|
|
type = types.nullOr types.bool;
|
|
|
|
|
description = ''
|
|
|
|
|
If <literal>true</literal>, allow applications in the
|
|
|
|
|
terminal to make text boldface.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2017-01-07 18:16:26 +00:00
|
|
|
|
scrollOnOutput = mkOption {
|
|
|
|
|
default = true;
|
|
|
|
|
type = types.bool;
|
|
|
|
|
description = "Whether to scroll when output is written.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
showScrollbar = mkOption {
|
|
|
|
|
default = true;
|
|
|
|
|
type = types.bool;
|
|
|
|
|
description = "Whether the scroll bar should be visible.";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
scrollbackLines = mkOption {
|
|
|
|
|
default = 10000;
|
|
|
|
|
type = types.nullOr types.int;
|
|
|
|
|
description =
|
|
|
|
|
''
|
|
|
|
|
The number of scrollback lines to keep, null for infinite.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
buildProfileSet = pcfg:
|
|
|
|
|
{
|
|
|
|
|
visible-name = pcfg.visibleName;
|
|
|
|
|
scrollbar-policy = if pcfg.showScrollbar then "always" else "never";
|
|
|
|
|
scrollback-lines = pcfg.scrollbackLines;
|
|
|
|
|
cursor-shape = pcfg.cursorShape;
|
|
|
|
|
}
|
|
|
|
|
// (
|
|
|
|
|
if (pcfg.font == null)
|
|
|
|
|
then { use-system-font = true; }
|
|
|
|
|
else { use-system-font = false; font = pcfg.font; }
|
|
|
|
|
) // (
|
|
|
|
|
if (pcfg.colors == null)
|
|
|
|
|
then { use-theme-colors = true; }
|
|
|
|
|
else (
|
|
|
|
|
{
|
|
|
|
|
use-theme-colors = false;
|
|
|
|
|
foreground-color = pcfg.colors.foregroundColor;
|
|
|
|
|
background-color = pcfg.colors.backgroundColor;
|
|
|
|
|
palette = pcfg.colors.palette;
|
|
|
|
|
}
|
2019-03-26 16:26:47 +00:00
|
|
|
|
// optionalAttrs (pcfg.allowBold != null) {
|
|
|
|
|
allow-bold = pcfg.allowBold;
|
|
|
|
|
}
|
2017-01-07 18:16:26 +00:00
|
|
|
|
// (
|
|
|
|
|
if (pcfg.colors.boldColor == null)
|
|
|
|
|
then { bold-color-same-as-fg = true; }
|
|
|
|
|
else {
|
|
|
|
|
bold-color-same-as-fg = false;
|
|
|
|
|
bold-color = pcfg.colors.boldColor;
|
|
|
|
|
}
|
|
|
|
|
)
|
2019-03-26 16:26:47 +00:00
|
|
|
|
// (
|
|
|
|
|
if (pcfg.colors.cursor != null)
|
|
|
|
|
then {
|
|
|
|
|
cursor-colors-set = true;
|
|
|
|
|
cursor-foreground-color = pcfg.colors.cursor.foreground;
|
|
|
|
|
cursor-background-color = pcfg.colors.cursor.background;
|
|
|
|
|
}
|
|
|
|
|
else { cursor-colors-set = false; }
|
|
|
|
|
)
|
|
|
|
|
// (
|
|
|
|
|
if (pcfg.colors.highlight != null)
|
|
|
|
|
then {
|
|
|
|
|
highlight-colors-set = true;
|
|
|
|
|
highlight-foreground-color = pcfg.colors.highlight.foreground;
|
|
|
|
|
highlight-background-color = pcfg.colors.highlight.background;
|
|
|
|
|
}
|
|
|
|
|
else { highlight-colors-set = false; }
|
|
|
|
|
)
|
2017-01-07 18:16:26 +00:00
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
|
|
{
|
2017-09-26 21:40:31 +00:00
|
|
|
|
meta.maintainers = [ maintainers.rycee ];
|
|
|
|
|
|
2017-01-07 18:16:26 +00:00
|
|
|
|
options = {
|
|
|
|
|
programs.gnome-terminal = {
|
|
|
|
|
enable = mkEnableOption "Gnome Terminal";
|
|
|
|
|
|
|
|
|
|
showMenubar = mkOption {
|
|
|
|
|
default = true;
|
|
|
|
|
type = types.bool;
|
|
|
|
|
description = "Whether to show the menubar by default";
|
|
|
|
|
};
|
|
|
|
|
|
2019-02-24 04:53:46 +00:00
|
|
|
|
themeVariant = mkOption {
|
|
|
|
|
default = "default";
|
|
|
|
|
type = types.enum [ "default" "light" "dark" ];
|
|
|
|
|
description = "The theme variation to request";
|
|
|
|
|
};
|
|
|
|
|
|
2017-01-07 18:16:26 +00:00
|
|
|
|
profile = mkOption {
|
|
|
|
|
default = {};
|
2017-05-09 22:20:15 +00:00
|
|
|
|
type = types.attrsOf profileSubModule;
|
2017-01-15 19:03:55 +00:00
|
|
|
|
description = "A set of Gnome Terminal profiles.";
|
2017-01-07 18:16:26 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2017-01-09 23:35:54 +00:00
|
|
|
|
home.packages = [ pkgs.gnome3.gnome_terminal ];
|
|
|
|
|
|
2018-11-04 19:56:43 +00:00
|
|
|
|
dconf.settings =
|
2017-01-07 18:16:26 +00:00
|
|
|
|
let
|
2018-11-04 19:56:43 +00:00
|
|
|
|
dconfPath = "org/gnome/terminal/legacy";
|
2017-01-07 18:16:26 +00:00
|
|
|
|
in
|
2018-11-04 19:56:43 +00:00
|
|
|
|
{
|
|
|
|
|
"${dconfPath}" = {
|
|
|
|
|
default-show-menubar = cfg.showMenubar;
|
2019-02-24 04:53:46 +00:00
|
|
|
|
theme-variant = cfg.themeVariant;
|
2018-11-04 19:56:43 +00:00
|
|
|
|
schema-version = 3;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
"${dconfPath}/profiles:" = {
|
|
|
|
|
default = head (attrNames (filterAttrs (n: v: v.default) cfg.profile));
|
|
|
|
|
list = attrNames cfg.profile;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
// mapAttrs' (n: v:
|
|
|
|
|
nameValuePair ("${dconfPath}/profiles:/:${n}") (buildProfileSet v)
|
|
|
|
|
) cfg.profile;
|
2019-01-03 15:35:15 +00:00
|
|
|
|
|
|
|
|
|
programs.bash.initExtra = mkBefore vteInitStr;
|
|
|
|
|
programs.zsh.initExtra = vteInitStr;
|
2017-01-07 18:16:26 +00:00
|
|
|
|
};
|
|
|
|
|
}
|