{ config, lib, pkgs, ... }: with lib; with lib.types; let cfg = config.programs.zellij; yamlFormat = pkgs.formats.yaml { }; prim = oneOf [ bool int str ]; primOrPrimAttrs = either prim (attrsOf prim); entry = either prim (listOf primOrPrimAttrs); entryOrAttrsOf = t: either entry (attrsOf t); entries = entryOrAttrsOf (entryOrAttrsOf entry); in { meta.maintainers = with lib.maintainers; [ boppyt ]; options.programs.zellij = { enable = mkEnableOption "Zellij, A terminal workspace with batteries included."; package = mkOption { type = types.package; default = pkgs.zellij; defaultText = literalExpression "pkgs.zellij"; description = "The zellij package to install"; }; settings = mkOption { type = attrsOf entries // { description = "zellij configuration"; }; default = { }; description = '' Configuration written to $XDG_CONFIG_HOME/zellij/config.yaml. See for a list of available options. ''; example = literalExample '' { default-mode = "normal"; simplified-ui = true; } ''; }; defaultLayout = mkOption { type = attrsOf entries // { description = "zellij default pane layout"; }; default = { }; description = '' Configuration written to $XDG_CONFIG_HOME/zellij/layout/default.yaml. See for a list of available options. ''; }; }; config = mkIf cfg.enable { home.packages = [ cfg.package ]; xdg.configFile."zellij/config.yaml" = mkIf (cfg.settings != { }) { source = yamlFormat.generate "zellij-config" cfg.settings; }; xdg.configFile."zellij/layout/default.yaml" = mkIf (cfg.defaultLayout != { }) { source = yamlFormat.generate "zellij-layout" cfg.defaultLayout; }; }; }