1{ 2 pkgs, 3 config, 4 lib, 5 ... 6}: 7 8let 9 cfg = config.custom; 10in 11{ 12 imports = [ 13 ./mail.nix 14 ./calendar.nix 15 ./gui/default.nix 16 ./nvim/default.nix 17 ./emacs/default.nix 18 ./battery.nix 19 ]; 20 21 options.custom.machineColour = lib.mkOption { 22 type = lib.types.str; 23 default = "cyan"; 24 }; 25 26 config = { 27 home.sessionVariables = { 28 EDITOR = "nvim"; 29 NIX_AUTO_RUN = "y"; 30 NIX_AUTO_RUN_INTERACTIVE = "y"; 31 GOPATH = "$HOME/.go"; 32 }; 33 home.packages = 34 let 35 status = pkgs.stdenv.mkDerivation { 36 name = "status"; 37 38 src = ./status; 39 40 installPhase = '' 41 mkdir -p $out 42 cp -r * $out 43 ''; 44 }; 45 in 46 with pkgs; 47 [ 48 status 49 tree 50 htop 51 gnumake 52 killall 53 inetutils 54 dnsutils 55 nmap 56 gcc 57 fzf 58 nix-tree 59 jq 60 bc 61 openssh 62 # multicore rust command line utils 63 dua 64 fd 65 bat 66 ripgrep 67 ]; 68 69 home.shellAliases = { 70 ls = "ls -p --color=auto"; 71 pls = "sudo $(fc -ln -1)"; 72 o = "xdg-open"; 73 se = "sudoedit"; 74 su = "su -p"; 75 ssh = "TERM=xterm ssh"; 76 nix-shell = "nix-shell --command zsh"; 77 inhibit-lid = "systemd-inhibit --what=handle-lid-switch sleep 1d"; 78 tmux = "tmux -2"; 79 feh = "feh --scale-down --auto-zoom"; 80 nix-stray-roots = "nix-store --gc --print-roots | egrep -v '^(/nix/var|/run|/proc|{censored})'"; 81 }; 82 83 # https://github.com/nix-community/home-manager/issues/1439#issuecomment-1106208294 84 home.activation = { 85 linkDesktopApplications = { 86 after = [ 87 "writeBoundary" 88 "createXdgUserDirectories" 89 ]; 90 before = [ ]; 91 data = '' 92 rm -rf ${config.xdg.dataHome}/"applications/home-manager" 93 mkdir -p ${config.xdg.dataHome}/"applications/home-manager" 94 cp -Lr ${config.home.homeDirectory}/.nix-profile/share/applications/* ${config.xdg.dataHome}/"applications/home-manager/" 95 ''; 96 }; 97 }; 98 99 programs.zsh = { 100 enable = true; 101 history = { 102 size = 1000000; 103 path = "$HOME/.histfile"; 104 share = false; 105 }; 106 autosuggestion.enable = true; 107 syntaxHighlighting.enable = true; 108 enableCompletion = true; 109 initExtraFirst = '' 110 export ZSH_AUTOSUGGEST_STRATEGY=(match_prev_cmd completion history) 111 export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=5" 112 PROMPT='%(?..%F{red}%3?%f )%F{${config.custom.machineColour}}%n@%m%f:%~ %#'$'\n' 113 ''; 114 initExtra = builtins.readFile ./zsh.cfg; 115 }; 116 117 programs.bash.initExtra = '' 118 PS1='\[\e[36m\]\u@\h:\W\[\e[0m\] $ ' 119 ''; 120 121 programs.gpg = { 122 enable = true; 123 publicKeys = [ 124 { 125 text = '' 126 -----BEGIN PGP PUBLIC KEY BLOCK----- 127 128 mDMEZZ1zrBYJKwYBBAHaRw8BAQdA8Zeb1OFbzEWx3tM7ylO0ILCnDCG2JoA/iay6 129 iWXmB7G0G1J5YW4gR2liYiA8cnlhbkBmcmV1bWgub3JnPoiUBBMWCgA8FiEE67lV 130 Y2amyVrqUoWjGfnbY35Mq3QFAmWdc6wCGwMFCQPCZwAECwkIBwQVCgkIBRYCAwEA 131 Ah4FAheAAAoJEBn522N+TKt0mwcA/AvuKD4dTPj4hJ/cezEWDOFELMaVYZqDS3V1 132 LmRJrdIHAQDYgST8awabyd2Y3PRTFf9ZcWRRompeg0v7c2hCc9/3A7g4BGWdc6wS 133 CisGAQQBl1UBBQEBB0AdJP8T3mGR7SUp9DBlIaVU1ESRC7sLWbm4QFCR1JTfSgMB 134 CAeIfgQYFgoAJhYhBOu5VWNmpsla6lKFoxn522N+TKt0BQJlnXOsAhsMBQkDwmcA 135 AAoJEBn522N+TKt07KwA/10R+ejRZeW0cYScowHAsnDZ09A43bZvdp1X7KeQHMl+ 136 AQD+TbceHh393VFc4tkl5pYHfrmkCXMdN0faVWolkc7GCA== 137 =EfP/ 138 -----END PGP PUBLIC KEY BLOCK----- 139 ''; 140 trust = "ultimate"; 141 } 142 ]; 143 }; 144 services.gpg-agent.pinentryPackage = pkgs.pinentry-qt; 145 146 programs.git = { 147 enable = true; 148 extraConfig = { 149 init = { 150 defaultBranch = "main"; 151 }; 152 user = { 153 email = "ryan@freumh.org"; 154 name = "Ryan Gibb"; 155 signingKey = "19F9DB637E4CAB74"; 156 }; 157 alias = { 158 s = "status"; 159 c = "commit"; 160 cm = "commit --message"; 161 ca = "commit --amend"; 162 cu = "commit --message update"; 163 ci = "commit --message initial"; 164 br = "branch"; 165 co = "checkout"; 166 df = "diff"; 167 l = "log"; 168 lg = "log -p"; 169 lol = "log --graph --decorate --pretty=oneline --abbrev-commit"; 170 lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all"; 171 ls = "ls-files"; 172 a = "add"; 173 aa = "add --all"; 174 au = "add -u"; 175 ap = "add --patch"; 176 ai = "add -i"; 177 ps = "push"; 178 pf = "push --force"; 179 pu = "push --set-upstream"; 180 pl = "pull"; 181 pr = "pull --rebase"; 182 acp = "!git add --all && git commit --message update && git push"; 183 d = "diff"; 184 dc = "diff --cached"; 185 }; 186 }; 187 }; 188 189 programs.tmux = { 190 enable = true; 191 extraConfig = 192 let 193 toggle-status-bar = pkgs.writeScript "toggle-status-bar.sh" '' 194 #!/usr/bin/env bash 195 window_count=$(tmux list-windows | wc -l) 196 if [ "$window_count" -ge "2" ]; then 197 tmux set-option status on 198 else 199 tmux set-option status off 200 fi 201 ''; 202 # https://github.com/ThePrimeagen/.dotfiles/blob/master/bin/.local/scripts/tmux-sessionizer 203 sessionizer = pkgs.writeScript "sessionizer.sh" '' 204 #!/usr/bin/env bash 205 206 if [[ $# -eq 1 ]]; then 207 selected=$1 208 else 209 selected=$(find ~ -not -path '*/.*' -maxdepth 2 -type d | fzf) 210 fi 211 212 if [[ -z $selected ]]; then 213 exit 0 214 fi 215 216 selected_name=$(basename "$selected" | tr . _) 217 tmux_running=$(pgrep tmux) 218 219 if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then 220 tmux new-session -s $selected_name -c $selected 221 exit 0 222 fi 223 224 if ! tmux has-session -t=$selected_name 2> /dev/null; then 225 tmux new-session -ds $selected_name -c $selected 226 fi 227 228 tmux switch-client -t $selected_name 229 ''; 230 in 231 '' 232 # alternative modifier 233 unbind C-b 234 set-option -g prefix C-a 235 bind-key C-a send-prefix 236 237 set-window-option -g mode-keys vi 238 set-option -g mouse on 239 set-option -g set-titles on 240 set-option -g set-titles-string "#T" 241 bind-key t capture-pane -S -\; new-window '(tmux show-buffer; tmux delete-buffer) | nvim -c $' 242 bind-key u capture-pane\; new-window '(tmux show-buffer; tmux delete-buffer) | ${pkgs.urlscan}/bin/urlscan' 243 set-hook -g session-window-changed 'run-shell ${toggle-status-bar}' 244 set-hook -g session-created 'run-shell ${toggle-status-bar}' 245 # Fixes C-Up/Down in TUIs 246 set-option default-terminal tmux 247 # https://stackoverflow.com/questions/62182401/neovim-screen-lagging-when-switching-mode-from-insert-to-normal 248 # locking 249 set -s escape-time 0 250 set -g lock-command ${pkgs.vlock}/bin/vlock 251 set -g lock-after-time 0 # Seconds; 0 = never 252 bind L lock-session 253 # for .zprofile display environment starting https://github.com/tmux/tmux/issues/3483 254 set-option -g update-environment XDG_VTNR 255 # Allow clipboard with OSC-52 work 256 set -s set-clipboard on 257 # toggle 258 bind -r ^ last-window 259 # vim copy 260 bind -T copy-mode-vi v send-keys -X begin-selection 261 bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel 262 # find 263 bind-key -r g run-shell "tmux neww ${sessionizer}" 264 # reload 265 bind-key r source-file ~/.config/tmux/tmux.conf 266 # kill unattached 267 bind-key K run-shell 'tmux ls | grep -v attached | cut -d: -f1 | xargs -I {} tmux kill-window -t {}' 268 ''; 269 }; 270 271 programs.less = { 272 enable = true; 273 keys = '' 274 #line-edit 275 \e[1;5D word-left 276 \e[1;5C word-right 277 ''; 278 }; 279 280 programs.go.goPath = "~/.go"; 281 282 home.stateVersion = "22.05"; 283 }; 284}