Skip to content

Commit

Permalink
add ghostty module
Browse files Browse the repository at this point in the history
it could be removed when the module is backported to
nix-community/home-manager/release-24.11
  • Loading branch information
adomixaszvers committed Dec 30, 2024
1 parent 288364c commit e43915b
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 21 deletions.
1 change: 1 addition & 0 deletions modules/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
imports = [
./ghostty.nix
./kbdd.nix
./polybar-program.nix
./thermal-zone.nix
Expand Down
65 changes: 65 additions & 0 deletions modules/ghostty.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
pkgs,
config,
inputs,
lib,
...
}:
let
cfg = config.programs.ghostty;
keyValueSettings = {
listsAsDuplicateKeys = true;
mkKeyValue = lib.generators.mkKeyValueDefault { } " = ";
};
keyValue = pkgs.formats.keyValue keyValueSettings;
in
{
options.programs.ghostty = {
enable = lib.mkEnableOption "Enable ghostty";
package = lib.mkOption {
type = lib.types.package;
default =
let
ghosttyPkgs = builtins.getAttr pkgs.hostPlatform.system inputs.ghostty.packages;
in
ghosttyPkgs.ghostty;
defaultText = lib.literalExpression "pkgs.ghostty";
description = ''
Ghostty package to install.
'';
};
settings = lib.mkOption {
inherit (keyValue) type;
default =
let
inherit (config.stylix) fonts opacity;
inherit (config.lib.stylix) scheme;
in
{
font-family = [
fonts.monospace.name
fonts.emoji.name
];
font-size = fonts.sizes.terminal;
background-opacity = opacity.terminal;
theme = scheme.slug;
};
example = lib.literalExpression ''
{
theme = "catppuccin-mocha";
font-size = 10;
}
'';
description = ''
Configuration written to {file}`$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;
};
};
}
38 changes: 17 additions & 21 deletions profiles/gui/ghostty.nix
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
{
pkgs,
config,
inputs,
lib,
...
}:
{
home.packages =
let
ghosttyPkgs = builtins.getAttr pkgs.hostPlatform.system inputs.ghostty.packages;
in
[ ghosttyPkgs.ghostty ];
xdg.configFile."ghostty/config".text =
let
inherit (config.stylix) fonts opacity;
inherit (config.lib.stylix) scheme;
in
''
font-family = ${fonts.monospace.name}
font-family = ${fonts.emoji.name}
font-size = ${toString fonts.sizes.terminal}
background-opacity = ${toString opacity.terminal}
gtk-titlebar = false
window-decoration = false
theme = ${scheme.slug}
'';
programs.ghostty = {
enable = lib.mkDefault true;
settings =
let
inherit (config.stylix) fonts opacity;
inherit (config.lib.stylix) scheme;
in
{
font-family = [
fonts.monospace.name
fonts.emoji.name
];
font-size = fonts.sizes.terminal;
background-opacity = opacity.terminal;
theme = scheme.slug;
};
};
}
2 changes: 2 additions & 0 deletions profiles/pc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
home.sessionVariables = {
BROWSER = "firefox";
};
programs.ghostty.enable = true;

stylix = {
enable = true;
targets.gtk.enable = false;
Expand Down
6 changes: 6 additions & 0 deletions profiles/t14.nix
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@
};
};
};
ghostty = {
settings = {
gtk-titlebar = false;
window-decoration = false;
};
};
};
services.screen-locker = {
# enable = true;
Expand Down
6 changes: 6 additions & 0 deletions profiles/work-common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@
};
};
};
ghostty = {
settings = {
gtk-titlebar = false;
with-decoration = false;
};
};
git.includes = [
{
condition = "gitdir:~/projektai/**";
Expand Down

0 comments on commit e43915b

Please sign in to comment.