1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-22 18:29:39 +01:00

zellij: remove with lib

This commit is contained in:
Austin Horstman 2025-03-24 09:49:22 -05:00
parent 6d4148df8e
commit 10dca990ae

View file

@ -1,29 +1,29 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
inherit (lib) mkIf mkOption types;
cfg = config.programs.zellij; cfg = config.programs.zellij;
yamlFormat = pkgs.formats.yaml { }; yamlFormat = pkgs.formats.yaml { };
in { in {
meta.maintainers = [ hm.maintainers.mainrs ]; meta.maintainers = [ lib.hm.maintainers.mainrs ];
options.programs.zellij = { options.programs.zellij = {
enable = mkEnableOption "Zellij"; enable = lib.mkEnableOption "Zellij";
package = mkOption { package = mkOption {
type = types.package; type = types.package;
default = pkgs.zellij; default = pkgs.zellij;
defaultText = literalExpression "pkgs.zellij"; defaultText = lib.literalExpression "pkgs.zellij";
description = '' description = ''
The Zellij package to install. The Zellij package to install.
''; '';
}; };
settings = mkOption { settings = lib.mkOption {
type = yamlFormat.type; type = yamlFormat.type;
default = { }; default = { };
example = literalExpression '' example = lib.literalExpression ''
{ {
theme = "custom"; theme = "custom";
themes.custom.fg = "#ffffff"; themes.custom.fg = "#ffffff";
@ -80,26 +80,26 @@ in {
# Zellij switched from yaml to KDL in version 0.32.0: # Zellij switched from yaml to KDL in version 0.32.0:
# https://github.com/zellij-org/zellij/releases/tag/v0.32.0 # https://github.com/zellij-org/zellij/releases/tag/v0.32.0
xdg.configFile."zellij/config.yaml" = mkIf xdg.configFile."zellij/config.yaml" = mkIf
(cfg.settings != { } && (versionOlder cfg.package.version "0.32.0")) { (cfg.settings != { } && (lib.versionOlder cfg.package.version "0.32.0")) {
source = yamlFormat.generate "zellij.yaml" cfg.settings; source = yamlFormat.generate "zellij.yaml" cfg.settings;
}; };
xdg.configFile."zellij/config.kdl" = mkIf xdg.configFile."zellij/config.kdl" = mkIf (cfg.settings != { }
(cfg.settings != { } && (versionAtLeast cfg.package.version "0.32.0")) { && (lib.versionAtLeast cfg.package.version "0.32.0")) {
text = lib.hm.generators.toKDL { } cfg.settings; text = lib.hm.generators.toKDL { } cfg.settings;
}; };
programs.bash.initExtra = mkIf cfg.enableBashIntegration '' programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
eval "$(${getExe cfg.package} setup --generate-auto-start bash)" eval "$(${lib.getExe cfg.package} setup --generate-auto-start bash)"
''; '';
programs.zsh.initExtra = mkIf cfg.enableZshIntegration (mkOrder 200'' programs.zsh.initContent = mkIf cfg.enableZshIntegration (lib.mkOrder 200 ''
eval "$(${getExe cfg.package} setup --generate-auto-start zsh)" eval "$(${lib.getExe cfg.package} setup --generate-auto-start zsh)"
''); '');
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration '' programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
eval (${ eval (${
getExe cfg.package lib.getExe cfg.package
} setup --generate-auto-start fish | string collect) } setup --generate-auto-start fish | string collect)
''; '';
@ -110,10 +110,10 @@ in {
}; };
warnings = warnings =
optional (cfg.attachExistingSession && !shellIntegrationEnabled) '' lib.optional (cfg.attachExistingSession && !shellIntegrationEnabled) ''
You have enabled `programs.zellij.attachExistingSession`, but none of the shell integrations are enabled. You have enabled `programs.zellij.attachExistingSession`, but none of the shell integrations are enabled.
This option will have no effect. This option will have no effect.
'' ++ optional (cfg.exitShellOnExit && !shellIntegrationEnabled) '' '' ++ lib.optional (cfg.exitShellOnExit && !shellIntegrationEnabled) ''
You have enabled `programs.zellij.exitShellOnExit`, but none of the shell integrations are enabled. You have enabled `programs.zellij.exitShellOnExit`, but none of the shell integrations are enabled.
This option will have no effect. This option will have no effect.
''; '';