about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsefidel <contact@sefidel.net>2022-01-20 16:47:01 +0900
committersefidel <contact@sefidel.net>2022-01-20 16:49:49 +0900
commit36d0b36dd4d21288c6210ece5c52adc83bb9531a (patch)
treec8675b78d78f4d6493b2aa45ed8a89d20bbacc34
parentb83077ee03226c49d301a52da1e5860506af75bf (diff)
downloadnixrc-36d0b36dd4d21288c6210ece5c52adc83bb9531a.tar.gz
nixrc-36d0b36dd4d21288c6210ece5c52adc83bb9531a.zip
home/zellij: add module
-rw-r--r--home/modules/programs/zellij/default.nix57
1 files changed, 57 insertions, 0 deletions
diff --git a/home/modules/programs/zellij/default.nix b/home/modules/programs/zellij/default.nix
new file mode 100644
index 0000000..7edcb11
--- /dev/null
+++ b/home/modules/programs/zellij/default.nix
@@ -0,0 +1,57 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+  cfg = config.programs.zellij;
+  yamlFormat = pkgs.formats.yaml { };
+
+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 = with types;
+        let
+          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 attrsOf entries // { description = "zellij configuration"; };
+      default = { };
+      description = ''
+        Configuration written to
+        <filename>$XDG_CONFIG_HOME/zellij/config.yaml</filename>. See <link
+        xlink:href="https://zellij.dev/documentation/configuration.html"/>
+        for a list of available options.
+      '';
+      example = literalExample ''
+        {
+          default-mode = "normal";
+          simplified-ui = true;
+        }
+      '';
+    };
+  };
+
+  config = mkIf cfg.enable {
+
+    home.packages = [ cfg.package ];
+
+    xdg.configFile."zellij/config.yaml" = mkIf (cfg.settings != { }) {
+      source = yamlFormat.generate "zellij-config" cfg.settings;
+    };
+  };
+}