shell.nix (4233B)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | ## Shell Configuration ## {config, ...}: let inherit (config.flake) files; editor = { autoindent = true; backup = true; clipboard = "external"; cursorline = true; eofnewline = false; helpsplit = "vsplit"; hltrailingws = true; infobar = true; matchbrace = true; keymenu = true; mouse = true; reload = "prompt"; ruler = true; saveundo = true; scrollbar = true; smartpaste = true; statusline = true; syntax = true; }; in { flake.modules = { nixos.shell = {pkgs, ...}: { config = { environment = { shells = [pkgs.bashInteractive]; # Text Editor variables."EDITOR" = "micro"; systemPackages = [pkgs.micro]; interactiveShellInit = '' e() { "''${EDITOR:-nano}" "$@"; } ''; }; systemd.tmpfiles.rules = let settings = pkgs.writeText "micro-settings.json" (builtins.toJSON editor); in [ "d /root/.config 0700 root root -" "d /root/.config/micro 0700 root root -" "L+ /root/.config/micro/settings.json - - - - ${settings}" ]; programs = { nano = { enable = true; syntaxHighlight = true; nanorc = files.nano; }; # Bourne Shell bash = { vteIntegration = true; promptInit = '' shopt -s autocd shopt -s cdspell shopt -s checkjobs shopt -s checkwinsize shopt -s cmdhist shopt -s extglob shopt -s globstar shopt -s histappend HISTCONTROL=erasedups:ignoredups:ignorespace HISTFILESIZE=100000 HISTIGNORE=rm:killall HISTSIZE=100000 ''; }; # Z Shell zsh = { enable = true; autosuggestions.enable = true; enableCompletion = false; syntaxHighlighting.enable = true; vteIntegration = true; setOptions = [ "autocd" "EXTENDED_HISTORY" "HIST_EXPIRE_DUPS_FIRST" ]; promptInit = '' bindkey '^[[1;5C' forward-word bindkey '^[[1;5D' backward-word bindkey '^[[3;5~' kill-word bindkey '^[[3~' delete-char bindkey "^[[5~" beginning-of-history bindkey "^[[6~" end-of-history bindkey '^[[A' up-line-or-search bindkey '^[[B' down-line-or-search bindkey '^[[C' forward-char bindkey '^[[D' backward-char bindkey '^[[F' end-of-linegestures bindkey '^[[H' beginning-of-line bindkey '^J' backward-kill-line ''; interactiveShellInit = '' source ${pkgs.zsh-autopair}/share/zsh/zsh-autopair/autopair.zsh ''; }; }; system.userActivationScripts.zshrc = "touch .zshrc"; }; }; homeManager.shell = {config, ...}: { home.persist = { files = [ ".bash_history" ".zsh_history" ]; directories = [ ".config/micro" ".local/share/bash" ".cache/zsh" ]; }; programs = { bash = { enable = true; historySize = 100000; historyFileSize = 100000; historyControl = [ "erasedups" "ignoredups" "ignorespace" ]; historyIgnore = [ "rm" "killall" ]; }; zsh = { enable = true; history = { path = "${config.home.homeDirectory}/.zsh_history"; size = 100000; save = 100000; extended = true; expireDuplicatesFirst = true; ignoreDups = true; ignoreSpace = true; share = true; }; }; # Text Editor micro = { enable = true; settings = editor; }; }; }; }; } |