Skip to content

Commit

Permalink
Remove individual temrinal options and configure them using programs.…
Browse files Browse the repository at this point in the history
… Also define a defualt one for shortcuts and etc.
  • Loading branch information
arunoruto committed Dec 27, 2024
1 parent 56fda56 commit 6c140bc
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 80 deletions.
5 changes: 4 additions & 1 deletion modules/home-manager/pc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
desktop.enable = lib.mkDefault true;
documents.enable = lib.mkDefault true;
pc.programs.enable = lib.mkDefault true;
terminals.enable = lib.mkDefault true;
terminals = {
enable = lib.mkDefault true;
main = "ghostty";
};

programs = {
autorandr.enable = lib.mkDefault true;
Expand Down
2 changes: 1 addition & 1 deletion modules/home-manager/pc/desktop/gnome/dconf.nix
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
name = "Terminal Super";
#command = "env WAYLAND_DISPLAY= alacritty";
#command = "wezterm start --always-new-process";
command = "wezterm";
command = config.terminals.main;
binding = "<Super>Return";
};
#"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1" = {
Expand Down
51 changes: 23 additions & 28 deletions modules/home-manager/pc/terminal/alacritty.nix
Original file line number Diff line number Diff line change
@@ -1,39 +1,34 @@
{
lib,
config,
...
}:
{
options.terminals.alacritty.enable = lib.mkEnableOption "Enable alacritty config";

config = lib.mkIf config.terminals.alacritty.enable {
programs.alacritty = {
enable = true;
settings = {
terminal.shell = {
program = config.shell.main;
};
window = {
decorations = "full";
dimensions = {
columns = config.terminals.width;
lines = config.terminals.height;
};
# opacity = 1;
# blur = true;
programs.alacritty = {
settings = {
terminal.shell = {
program = config.shell.main;
};
window = {
decorations = "full";
dimensions = {
columns = config.terminals.width;
lines = config.terminals.height;
};
# font = {
# size = 12;
# offset = {
# y = 0;
# x = 0;
# };
# glyph_offset = {
# y = 0;
# x = 0;
# };
# };
# opacity = 1;
# blur = true;
};
# font = {
# size = 12;
# offset = {
# y = 0;
# x = 0;
# };
# glyph_offset = {
# y = 0;
# x = 0;
# };
# };
};
};
}
12 changes: 11 additions & 1 deletion modules/home-manager/pc/terminal/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@

options.terminals = {
enable = lib.mkEnableOption "Enable configured terminals";
main = lib.mkOption {
type = lib.types.str;
default = "";
example = "wezterm";
description = ''
Main terminal to be used, for example in shortcuts.
This one will be always enabled!
'';
};
width = lib.mkOption {
type = lib.types.int;
default = 108;
Expand All @@ -29,8 +38,9 @@
};

config = lib.mkIf config.terminals.enable {
terminals = {
programs = {
alacritty.enable = lib.mkDefault false;
ghostty.enable = lib.mkDefault true;
warp.enable = lib.mkDefault false;
wezterm.enable = lib.mkDefault true;
};
Expand Down
37 changes: 30 additions & 7 deletions modules/home-manager/pc/terminal/ghostty-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
let
cfg = config.programs.ghostty;
keyValue = pkgs.formats.keyValue {
listsAsDuplicateKeys = true;
mkKeyValue = lib.generators.mkKeyValueDefault { } " = ";
};
in
Expand All @@ -16,7 +17,6 @@ in
options.programs.ghostty = {
enable = lib.mkEnableOption "ghostty";
package = lib.mkPackageOption pkgs "ghostty" { };

settings = lib.mkOption {
inherit (keyValue) type;
default = { };
Expand All @@ -28,16 +28,39 @@ in
'';
description = ''
Configuration written to $XDG_CONFIG_HOME/ghostty/config.
See https://ghostty.org/docs/config/reference for more information.
'';
};
};

config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ];

xdg.configFile."ghostty/config" = lib.mkIf (cfg.settings != { }) {
source = keyValue.generate "ghostty-config" cfg.settings;
installBatSyntax = lib.mkEnableOption "installation of ghostty configuration syntax for bat" // {
default = true;
};
installVimSyntax = lib.mkEnableOption "installation of ghostty configuration syntax for vim/neovim";
};

config = lib.mkIf cfg.enable (
lib.mkMerge [
{
home.packages = [ cfg.package ];

xdg.configFile."ghostty/config" = lib.mkIf (cfg.settings != { }) {
source = keyValue.generate "ghostty-config" cfg.settings;
};
}
(lib.mkIf cfg.installBatSyntax {
programs.bat = {
syntaxes.ghostty = {
src = cfg.package;
file = "share/bat/syntaxes/ghostty.sublime-syntax";
};
config.map-syntax = [ "*/ghostty/config:Ghostty Config" ];
};
})
(lib.mkIf cfg.installVimSyntax {
programs.vim.plugins = [ cfg.package.vim ];
programs.neovim.plugins = [ cfg.package.vim ];
})
]
);
}
41 changes: 37 additions & 4 deletions modules/home-manager/pc/terminal/ghostty.nix
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
{ inputs, ... }:
{ inputs, config, ... }:
{
imports = [
./ghostty-module.nix
];

config = {
programs.ghostty = {
enable = true;
package = inputs.ghostty.packages.x86_64-linux.default;

settings = {
# theme = "catppuccin-mocha";
font-size = 10;
theme = "stylix";
# background-blur-radius = 20;
background-opacity = config.stylix.opacity.terminal;
font-family = config.stylix.fonts.monospace.name;
font-size = config.stylix.fonts.sizes.terminal;
window-height = config.terminals.height;
window-width = config.terminals.width;
keybind = [
"alt+enter=toggle_fullscreen"
"alt+h=previous_tab"
"alt+l=next_tab"
];
};
};

Expand All @@ -20,5 +29,29 @@
# home-files/.config/ghostty/config \
# ${./example-config-expected}
# '';

home.file.".config/ghostty/themes/stylix".text = with config.lib.stylix.colors.withHashtag; ''
palette = 0=${base03}
palette = 1=${base08}
palette = 2=${base0B}
palette = 3=${base0A}
palette = 4=${base0D}
palette = 5=${base0F}
palette = 6=${base0C}
palette = 7=${base05}
palette = 8=${base04}
palette = 9=${base08}
palette = 10=${base0B}
palette = 11=${base0A}
palette = 12=${base0D}
palette = 13=${base0F}
palette = 14=${base0C}
palette = 15=${base05}
background = ${base00}
foreground = ${base05}
cursor-color = ${base06}
selection-background = ${base02}
selection-foreground = ${base05}
'';
};
}
4 changes: 2 additions & 2 deletions modules/home-manager/pc/terminal/warp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ let
};
in
{
options.terminals.warp.enable = lib.mkEnableOption "Enable warp terminal";
options.programs.warp.enable = lib.mkEnableOption "Enable warp terminal";

config = lib.mkIf config.terminals.warp.enable {
config = lib.mkIf config.programs.warp.enable {
home = {
packages = with pkgs; [
unstable.warp-terminal
Expand Down
67 changes: 31 additions & 36 deletions modules/home-manager/pc/terminal/wezterm.nix
Original file line number Diff line number Diff line change
@@ -1,44 +1,39 @@
{
config,
lib,
pkgs,
inputs,
osConfig,
# lib,
# pkgs,
# inputs,
...
}@args:
{
options.terminals.wezterm.enable = lib.mkEnableOption "Enable wezterm terminal";

config = lib.mkIf config.terminals.wezterm.enable {
programs.wezterm = {
enable = true;
enableZshIntegration = config.programs.zsh.enable;
extraConfig = ''
local wezterm = require 'wezterm'
local config = {}
config.audible_bell = "Disabled"
config.enable_wayland = false
-- config.front_end = "WebGpu"
-- config.enable_wayland = true
config.front_end = "${
# if ((args ? nixosConfig) && (!osConfig.hosts.nvidia.enable)) then "OpenGL" else "WebGpu"
if ((args ? nixosConfig) && (osConfig.networking.hostName == "madara")) then "OpenGL" else "WebGpu"
}"
config.hide_tab_bar_if_only_one_tab = true
-- config.window_decorations = 'TITLE | RESIZE'
config.window_decorations = 'RESIZE'
config.initial_rows = ${builtins.toString config.terminals.height}
config.initial_cols = ${builtins.toString config.terminals.width}
config.warn_about_missing_glyphs = false
return config
'';
};
# // lib.optionalAttrs (args ? nixosConfig) {
# package =
# if osConfig.hosts.nvidia.enable then
# inputs.wezterm.packages.${pkgs.system}.default
# else
# pkgs.wezterm;
# };
programs.wezterm = {
enableZshIntegration = config.programs.zsh.enable;
extraConfig = ''
local wezterm = require 'wezterm'
local config = {}
config.audible_bell = "Disabled"
config.enable_wayland = false
-- config.front_end = "WebGpu"
-- config.enable_wayland = true
config.front_end = "${
# if ((args ? nixosConfig) && (!osConfig.hosts.nvidia.enable)) then "OpenGL" else "WebGpu"
if ((args ? nixosConfig) && (osConfig.networking.hostName == "madara")) then "OpenGL" else "WebGpu"
}"
config.hide_tab_bar_if_only_one_tab = true
-- config.window_decorations = 'TITLE | RESIZE'
config.window_decorations = 'RESIZE'
config.initial_rows = ${builtins.toString config.terminals.height}
config.initial_cols = ${builtins.toString config.terminals.width}
config.warn_about_missing_glyphs = false
return config
'';
};
# // lib.optionalAttrs (args ? nixosConfig) {
# package =
# if osConfig.hosts.nvidia.enable then
# inputs.wezterm.packages.${pkgs.system}.default
# else
# pkgs.wezterm;
# };
}

0 comments on commit 6c140bc

Please sign in to comment.