summaryrefslogtreecommitdiff
path: root/home-manager/common.nix
blob: ee7d8f2437a143c18ceb56f660897c7a45aa9594 (plain)
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
{ lib, pkgs, inputs, ... }: {
  # # You can also create simple shell scripts directly inside your
  # # configuration. For example, this adds a command 'my-hello' to your
  # # environment:
  # (pkgs.writeShellScriptBin "my-hello" ''
  #   echo "Hello, ${config.home.username}!"
  # '')
  home.packages = [
    pkgs.gnumake
    pkgs.git-crypt
    pkgs.maim
    pkgs.xkcdpass
    pkgs.speedtest-cli
    pkgs.bitwarden-cli
    # Language servers
    pkgs.nixfmt-rfc-style
    pkgs.nixd
    pkgs.pyright
    pkgs.gopls
    pkgs.lua-language-server
    pkgs.ansible-language-server
    pkgs.ansible-lint
    # ---
    pkgs.fd
    pkgs.glow
    pkgs.eza
    pkgs.openssh

    pkgs.cobra-cli
    pkgs.yq-go

    # Programming languages
    pkgs.gleam
    pkgs.erlang_26
    pkgs.elixir_1_15
    pkgs.elixir_ls

    # Python formatted and linter
    pkgs.python313
    pkgs.black
    pkgs.ruff
  ];

  # # Building this configuration will create a copy of 'dotfiles/screenrc' in
  # # the Nix store. Activating the configuration will then make '~/.screenrc' a
  # # symlink to the Nix store copy.
  # ".screenrc".source = dotfiles/screenrc;

  # # You can also set the file content immediately.
  # ".gradle/gradle.properties".text = ''
  #   org.gradle.console=verbose
  #   org.gradle.daemon.idletimeout=3600000
  # '';
  home.file = { };

  # You can also manage environment variables but you will have to manually
  # source
  #
  #  ~/.nix-profile/etc/profile.d/hm-session-vars.sh
  #
  # or
  #
  #  /etc/profiles/per-user/jras/etc/profile.d/hm-session-vars.sh
  #
  # if you don't want to manage your shell through Home Manager.
  home.sessionVariables = { EDITOR = "hx"; };
  home.sessionPath = [ "$GOBIN" ];

  # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;
  programs.ripgrep.enable = true;
  programs.bat.enable = true;
  programs.btop.enable = true;
  programs.go = {
    enable = true;
    goPath = "go";
    goBin = "go/bin";
  };

  programs.zoxide = {
    enable = true;
    options = [ "--cmd cd" ];
  };
  programs.fzf.enable = true;

  programs.direnv = {
    enable = true;
    nix-direnv.enable = true;
  };

  programs.zsh = {
    enable = true;
    defaultKeymap = "emacs";
    envExtra = ''
      export ZVM_VI_INSERT_ESCAPE_BINDKEY="jk"
    '';
    initExtra = ''
      # https://github.com/jeffreytse/zsh-vi-mode
                  source ${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh
    '';
    shellAliases = {
      g = "git";
    };
  };

  programs.git = {
    enable = true;
    aliases = {
      b = "branch";
      f = "fetch";
      p = "pull";
      s = "status";
      co = "checkout";
      pu = "push";
      nb = "checkout -b";
      db = "branch -D";
      lg =
        "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit";
      praise = "blame";
      bump = "!git bump";
      ae = "!git add -A && git commit --amend";
      ad = "commit --amend";
      ac = "!git add -A && git commit";
      rmbs =
        "!git branch | grep -wv master | grep -wv main | xargs git branch -D";
    };
    extraConfig = {
      pull.rebase = false;
      init.defaultBranch = "main";
    };
  };

  programs.tmux = {
    enable = true;
    shortcut = "a";
    newSession = true;
    terminal = "tmux-256color";
    extraConfig = ''
      # Recommended by NeoVim's checkhealth
                  set-option -sg escape-time 10
                  set-option -g default-shell ${pkgs.zsh}/bin/zsh

      # # Set vim keymode
                   set-window-option -g mode-keys vi
                   bind-key -T copy-mode-vi v send -X begin-selection
                   bind-key -T copy-mode-vi V send -X select-line
                   bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
    '';
    plugins = with pkgs.tmuxPlugins; [
      vim-tmux-navigator

      {
        plugin = catppuccin;
        extraConfig = ''
          set -g @catppuccin_flavour 'frappe'
          set -g @catppuccin_powerline_theme_enabled 'on'
          set -g @catppuccin_l_left_separator ''
          set -g @catppuccin_l_right_separator ''
          set -g @catppuccin_r_left_separator ''
          set -g @catppuccin_r_right_separator ''
        '';
      }
    ];
  };

  programs.neovim = {
    enable = true;
    vimAlias = true;
    plugins = with pkgs.vimPlugins; [
      gleam-vim
      plenary-nvim
      telescope-file-browser-nvim
      vim-tmux-navigator
      nui-nvim
      # Colors
      catppuccin-nvim
      # LSP
      nvim-lspconfig
      trouble-nvim
      # Completion
      luasnip
      nvim-cmp
      cmp-nvim-lsp
      cmp-nvim-lua
      cmp-buffer
      cmp-path
      cmp_luasnip

      {
        plugin = lsp-zero-nvim;
        type = "lua";
        config = builtins.readFile (./neovim/lsp-zero-nvim.lua);
      }
      {
        plugin = nvim-web-devicons;
        type = "lua";
        config = builtins.readFile (./neovim/nvim-web-devicons.lua);
      }
      {
        plugin = nvim-treesitter.withAllGrammars;
        type = "lua";
        config = builtins.readFile (./neovim/nvim-treesitter.lua);
      }
      {
        plugin = telescope-nvim;
        type = "lua";
        config = builtins.readFile (./neovim/telescope-nvim.lua);
      }
      {
        plugin = harpoon;
        type = "lua";
        config = builtins.readFile (./neovim/harpoon.lua);
      }
      #{
      #  plugin = copilot-vim;
      #  type = "lua";
      #  config = builtins.readFile (./neovim/copilot-vim.lua);
      #}
    ];
    extraLuaConfig = builtins.readFile (./neovim/init.lua);
    extraConfig = ''
      set shiftwidth=4 smarttab
      set expandtab
      set tabstop=4 softtabstop=0

      inoremap jk <ESC>
      let mapleader=" "   " remap the mapleader

      syntax on       " syntax highlighting
      set number      " show line numbers
      set relativenumber " relative line numbers
      set noswapfile  " disable the swap file
      set hlsearch    " highlight all results
      set ignorecase  " ignore case in search
      set incsearch   " show search results as you type

      " disable mouse
      set mouse=

      autocmd BufWritePost *.nix !nixfmt %
      autocmd BufWritePost *.go !gofmt -w %
    '';
  };

  programs.starship = {
    enable = true;
    settings = {
      directory.style = "blue";

      format = lib.concatStrings [
        "$username"
        "$hostname"
        "$directory"
        "$git_branch"
        "$git_state"
        "$git_status"
        "$cmd_duration"
        "$line_break"
        "$python"
        "$openstack"
        "$character"
      ];

      character = {
        success_symbol = "[❯](purple)";
        error_symbol = "[❯](red)";
        vimcmd_symbol = "[❮](green)";
      };

      git_branch = {
        format = "[$branch]($style)";
        style = "bright-black";
      };

      git_status = {
        format =
          "[[(*$conflicted$untracked$modified$staged$renamed$deleted)](218) ($ahead_behind$stashed)]($style)";
        style = "cyan";
        conflicted = "​";
        untracked = "​";
        modified = "​";
        staged = "​";
        renamed = "​";
        deleted = "​";
        stashed = "≡";
      };

      git_state = {
        format = "'([$state( $progress_current/$progress_total)]($style))' ";
        style = "bright-black";
      };

      cmd_duration = {
        format = "[$duration]($style) ";
        style = "yellow";
      };

      python = {
        format = "[$virtualenv]($style) ";
        style = "bright-black";
      };
    };
  };

  programs.helix = {
    enable = true;
    package = inputs.helix.packages."${pkgs.system}".helix;
    defaultEditor = true;
    languages = {
      language = [
        {
          name = "python";
          language-servers = [ "pyright" "ruff" ];
          formatter = { command = "black"; args = ["--line-length" "88" "--quiet" "-"]; };
          auto-format = true;
        }
        {
          name = "elixir";
          language-servers = [ "elixir-ls" ];
          formatter = { command = "mix format"; };
          auto-format = true;
        }
      ];
      language-server.pyright.config.python.analysis = { typeCheckingMode = "basic"; };
      language-server.ruff = { command = "ruff"; };
      language-server.ruff.config.setting = { args = ["--ignore" "E501" ]; };
      language-server.intelephense = with pkgs.nodePackages; {
        command = "${intelephense}/bin/intelephense";
      };
    };
    settings = { 
      keys.normal = {
        space.F = "file_picker_in_current_buffer_directory";
      };
      editor = {
        line-number = "relative";
        bufferline = "always";
        lsp = {
          enable = true;
          display-messages = true;
        };
        indent-guides = {
          render = true;
          skip-levels = 1;
        };
        auto-save = false;
      };
     };
  };

  services.ssh-agent.enable = true;
  programs.ssh = {
    enable = true;
    package = "${pkgs.openssh}";
    addKeysToAgent = "yes";
  };

  programs.alacritty = {
    settings = {
      window = {
        padding = { x = 5; y = 2; };
      };
      env = { TERM = "alacritty-direct"; };
      shell = {
        program = "${pkgs.zsh}/bin/zsh";
        args = [ "-l" ];
      };
    } // builtins.fromJSON (builtins.readFile ./alacritty/catppuccin-frappe.json);
  };

  programs.taskwarrior = {
    enable = true;
    package = "${pkgs.taskwarrior3}";
  };
}