summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2016-10-21 23:32:03 +0200
committerDaiderd Jordan <daiderd@gmail.com>2016-10-21 23:32:03 +0200
commit4a7514f2eae42f0c36abee8b105265c3e73a89ca (patch)
treed6fbcbb3ffba1095d52fdb742673022b03ad2b04 /modules
parente968db6224c7a4ba7a36fab7aec8231c0e1c8aba (diff)
add basic options for programs.tmux
Diffstat (limited to 'modules')
-rw-r--r--modules/environment.nix2
-rw-r--r--modules/tmux.nix85
2 files changed, 86 insertions, 1 deletions
diff --git a/modules/environment.nix b/modules/environment.nix
index d2e0d14..58a5e25 100644
--- a/modules/environment.nix
+++ b/modules/environment.nix
@@ -39,6 +39,7 @@ in {
};
environment.variables = mkOption {
+ type = types.attrsOf (types.loeOf types.str);
default = {};
description = ''
A set of environment variables used in the global environment.
@@ -47,7 +48,6 @@ in {
strings. The latter is concatenated, interspersed with colon
characters.
'';
- type = types.attrsOf (types.loeOf types.str);
apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v);
};
diff --git a/modules/tmux.nix b/modules/tmux.nix
new file mode 100644
index 0000000..249e015
--- /dev/null
+++ b/modules/tmux.nix
@@ -0,0 +1,85 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+ inherit (pkgs) stdenv;
+
+ cfg = config.programs.tmux;
+
+ tmuxConfigs =
+ mapAttrsToList (n: v: "${v}") cfg.text;
+
+in {
+ options = {
+
+ programs.tmux.enableSensible = mkOption {
+ type = types.bool;
+ default = false;
+ example = true;
+ description = ''
+ Enable sensible configuration options.
+ '';
+ };
+
+ programs.tmux.enableVim = mkOption {
+ type = types.bool;
+ default = false;
+ example = true;
+ description = ''
+ Enable vim style keybindings for copy mode, and navigation of panes.
+ '';
+ };
+
+ programs.tmux.text = mkOption {
+ internal = true;
+ type = types.attrsOf types.str;
+ default = {};
+ };
+
+ };
+
+ config = {
+
+ system.build.setTmuxOptions = pkgs.writeText "set-tmux-options"
+ (concatStringsSep "\n" tmuxConfigs);
+
+ programs.tmux.text.sensible = mkIf cfg.enableSensible (''
+ set -g default-terminal "screen-256color"
+ setw -g aggressive-resize on
+
+ set -g base-index 1
+ set -g renumber-windows on
+ bind 0 set -g status
+
+ set -g status-keys emacs
+ set -s escape-time 0
+
+ bind c new-window -c '#{pane_current_path}'
+ bind % split-window -v -c '#{pane_current_path}'
+ bind '"' split-window -h -c '#{pane_current_path}'
+
+ # TODO: make these interactive
+ bind C new-session
+ bind S switch-client -l
+
+ # set -g status-utf8 on
+ # set -g utf8 on
+ '' + optionalString stdenv.isDarwin ''
+ set -g default-command "reattach-to-user-namespace -l $SHELL"
+ '');
+
+ programs.tmux.text.vim = mkIf cfg.enableVim ''
+ setw -g mode-keys vi
+
+ bind h select-pane -L
+ bind j select-pane -D
+ bind k select-pane -U
+ bind l select-pane -R
+ bind s split-window -v -c '#{pane_current_path}'
+ bind v split-window -h -c '#{pane_current_path}'
+ '';
+
+ };
+}