mirror of
https://github.com/nix-community/home-manager
synced 2025-01-30 21:05:02 +01:00
ghostty: allow darwin users to manager their config (#6300)
* ghostty: allow darwin users to manager their config
Currently nixpkgs does not contain a package defintion for ghostty
compatible with Darwin. Darwin users may still want to use this module
to manage their config or share config between systems. This carries
over behaviour from the beta period where this same technique was used.
see: 887e13a6e7/module.nix (L167-L173)
Also improves validation to cover theme files.
* ghostty: guard all package access with isLinux
ghostty is currently marked as broken in nixpkgs. Darwin users still
want to manage ghostty config via home-manager. Avoiding installing the
package and any extra files that depend on the package outside Linux
allows this.
* ghostty: allow nullable
This commit is contained in:
parent
c4650fb9c0
commit
d71828a7dd
1 changed files with 33 additions and 8 deletions
|
@ -13,7 +13,11 @@ in {
|
||||||
options.programs.ghostty = {
|
options.programs.ghostty = {
|
||||||
enable = lib.mkEnableOption "Ghostty";
|
enable = lib.mkEnableOption "Ghostty";
|
||||||
|
|
||||||
package = lib.mkPackageOption pkgs "ghostty" { };
|
package = lib.mkPackageOption pkgs "ghostty" {
|
||||||
|
nullable = true;
|
||||||
|
extraDescription =
|
||||||
|
"Set programs.ghostty.package to null on platfroms where ghostty is not available or marked broken";
|
||||||
|
};
|
||||||
|
|
||||||
settings = lib.mkOption {
|
settings = lib.mkOption {
|
||||||
inherit (keyValue) type;
|
inherit (keyValue) type;
|
||||||
|
@ -82,7 +86,9 @@ in {
|
||||||
installBatSyntax =
|
installBatSyntax =
|
||||||
lib.mkEnableOption "installation of Ghostty configuration syntax for bat"
|
lib.mkEnableOption "installation of Ghostty configuration syntax for bat"
|
||||||
// {
|
// {
|
||||||
default = true;
|
default = cfg.package != null;
|
||||||
|
defaultText =
|
||||||
|
lib.literalMD "`true` if programs.ghostty.package is not null";
|
||||||
};
|
};
|
||||||
|
|
||||||
enableBashIntegration = lib.mkEnableOption ''
|
enableBashIntegration = lib.mkEnableOption ''
|
||||||
|
@ -112,7 +118,7 @@ in {
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable (lib.mkMerge [
|
config = lib.mkIf cfg.enable (lib.mkMerge [
|
||||||
{
|
{
|
||||||
home.packages = [ cfg.package ];
|
home.packages = lib.optionals (cfg.package != null) [ cfg.package ];
|
||||||
|
|
||||||
programs.ghostty.settings = lib.mkIf cfg.clearDefaultKeybinds {
|
programs.ghostty.settings = lib.mkIf cfg.clearDefaultKeybinds {
|
||||||
keybind = lib.mkBefore [ "clear" ];
|
keybind = lib.mkBefore [ "clear" ];
|
||||||
|
@ -120,27 +126,46 @@ in {
|
||||||
|
|
||||||
# MacOS also supports XDG configuration directory, so we use it for both
|
# MacOS also supports XDG configuration directory, so we use it for both
|
||||||
# Linux and macOS to reduce complexity
|
# Linux and macOS to reduce complexity
|
||||||
xdg.configFile = lib.mkMerge [
|
xdg.configFile = let
|
||||||
|
validate = file:
|
||||||
|
lib.mkIf (cfg.package != null) "${
|
||||||
|
lib.getExe cfg.package
|
||||||
|
} +validate-config --config-file=${config.xdg.configHome}/ghostty/${file}";
|
||||||
|
in lib.mkMerge [
|
||||||
{
|
{
|
||||||
"ghostty/config" = lib.mkIf (cfg.settings != { }) {
|
"ghostty/config" = lib.mkIf (cfg.settings != { }) {
|
||||||
source = keyValue.generate "ghostty-config" cfg.settings;
|
source = keyValue.generate "ghostty-config" cfg.settings;
|
||||||
onChange = "${lib.getExe cfg.package} +validate-config";
|
onChange = validate "config";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
(lib.mkIf (cfg.themes != { }) (lib.mapAttrs' (name: value: {
|
(lib.mkIf (cfg.themes != { }) (lib.mapAttrs' (name: value: {
|
||||||
name = "ghostty/themes/${name}";
|
name = "ghostty/themes/${name}";
|
||||||
value.source = keyValue.generate "ghostty-${name}-theme" value;
|
value = {
|
||||||
|
source = keyValue.generate "ghostty-${name}-theme" value;
|
||||||
|
onChange = validate "themes/${name}";
|
||||||
|
};
|
||||||
}) cfg.themes))
|
}) cfg.themes))
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
(lib.mkIf cfg.installVimSyntax {
|
(lib.mkIf cfg.installVimSyntax {
|
||||||
programs.vim.plugins = [ cfg.package.vim ];
|
assertions = [{
|
||||||
|
assertion = cfg.installVimSyntax -> cfg.package != null;
|
||||||
|
message =
|
||||||
|
"programs.ghostty.installVimSyntax cannot be enabled when programs.ghostty.package is null";
|
||||||
|
}];
|
||||||
|
programs.vim.plugins =
|
||||||
|
lib.optionals (cfg.package != null) [ cfg.package.vim ];
|
||||||
})
|
})
|
||||||
|
|
||||||
(lib.mkIf cfg.installBatSyntax {
|
(lib.mkIf cfg.installBatSyntax {
|
||||||
programs.bat = {
|
assertions = [{
|
||||||
|
assertion = cfg.installBatSyntax -> cfg.package != null;
|
||||||
|
message =
|
||||||
|
"programs.ghostty.installBatSyntax cannot be enabled when programs.ghostty.package is null";
|
||||||
|
}];
|
||||||
|
programs.bat = lib.mkIf (cfg.package != null) {
|
||||||
syntaxes.ghostty = {
|
syntaxes.ghostty = {
|
||||||
src = cfg.package;
|
src = cfg.package;
|
||||||
file = "share/bat/syntaxes/ghostty.sublime-syntax";
|
file = "share/bat/syntaxes/ghostty.sublime-syntax";
|
||||||
|
|
Loading…
Add table
Reference in a new issue