about summary refs log tree commit diff
path: root/home/profiles/development/default.nix
blob: 71cf3af62c04222c3143b6c6c8e0c48e845c952f (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
{ config, lib, pkgs, self, ... }:

let
  cfg = config.profiles.development;
in
{
  imports = [
    ../../modules/programs/zshell
  ];

  options.profiles.development = {
    enable = lib.mkEnableOption
      "A profile that enables the system to be used for developing programs";
  };

  config = lib.mkIf cfg.enable {
    programs.git = {
      enable = true;
      package = pkgs.gitFull;

      userName = "sefidel";
      userEmail = "contact@sefidel.net";

      signing = {
        key = "8BDFDFB56842239382A0441B9238BC709E05516A";
        signByDefault = true;
      };

      aliases = {
        graph =
          "log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold yellow)%h%C(reset) - %C(green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n %C(normal)%s%C(reset) %C(blue)- %an%C(reset)' --all";
        co = "checkout";
        br = "branch";
        st = "status";
        ps = "push";
        pl = "pull";
        root = "rev-parse --show-toplevel";
      };

      extraConfig = {
        init.defaultBranch = "main";
        pull.rebase = true;

        merge.conflictStyle = "zdiff3";

        mergetool.fugitive = {
          cmd = ''nvim -f -c "Gvdiffsplit!" "$MERGED"'';
          trustExitCode = true;
        };

        merge.tool = "fugitive";
        mergetool.prompt = false;

        format.signOff = true;

        sendemail = {
          smtpserver = "smtp.migadu.com";
          smtpuser = "contact@sefidel.com";
          smtpencryption = "ssl";
          smtpserverport = "465";
        };
      };

      ignores = [
        # IntelliJ files and folders
        ".idea/"
        "*.iml"
        # backupfiles and shadow copies done by editors
        "*~"
        "\\#*\\#"
        ".#*"
        # Elixir language server
        "/.elixir_ls"
        # MyPy Cache
        ".mypy_cache"
        # Visual Studio Code project configuration
        "/.vscode"
        # Result folder for nix builds
        "result"
        "result-*"
        # direnv caches
        ".direnv/"
        # emacs/python stuff
        "flycheck_*.py"
      ];
    };

    # GPG Authentication subkey is used for provisioning the server,
    # thus we need to use fallback key to identify with gitolite.
    programs.ssh.enable = true; # this has no relation with the sshd daemon.
    programs.ssh.forwardAgent = true;
    programs.ssh.extraConfig = ''
      Host git.exotic.sh
        User git
        Port 22
        IdentityFile ~/.ssh/sefidel.pub
        IdentitiesOnly true

      Host git-admin.vhosts.exotic.sh
        HostName git.exotic.sh
        User git
        Port 22
        IdentityFile ~/.ssh/id_ed25519
        IdentitiesOnly true

      Host work.vhosts.exotic.sh
        HostName cobalt.exotic.sh
        User sefidel
        Port 22
        IdentityFile ~/.ssh/sefidel.pub
        IdentitiesOnly true
    '';

    programs.helix = {
      enable = true;
      settings = {
        theme = "rasmus-ext";

        editor = {
          statusline = {
            left = [ "mode" "spinner" "file-name" "position" "separator" "spacer" "diagnostics" "file-modification-indicator" ];
            center = [ "version-control" ];
            right = [ "selections" "file-encoding" "file-line-ending" "file-type" ];
            mode.normal = "NORMAL";
            mode.insert = "INSERT";
            mode.select = "SELECT";
          };

          cursor-shape = {
            insert = "bar";
            normal = "block";
            select = "underline";
          };

          # lsp = {
          #   display-inlay-hints = true;
          # };

          line-number = "relative";
          color-modes = true;
          bufferline = "multiple";
        };

        keys.normal = {
          space = {
            q = ":buffer-previous";
            e = ":buffer-next";
            u = ":buffer-close";
            o = ":new";
            ";" = "command_mode";
            "/" = "toggle_comments";
          };
          A-r = [ "extend_to_line_bounds" "delete_selection" "paste_after" ];
          A-e = [ "extend_to_line_bounds" "delete_selection" "move_line_up" "paste_before" ];
        };
      };
      themes = {
        rasmus-ext = {
          inherits = "rasmus";

          # Transparent background
          # "ui.background" = {};
          # Bar cursor
          "ui.virtual" = { fg = "white"; };
          # lightened ui.cursor.{normal,insert,select}
          "ui.cursor.primary.normal" = { bg = "gray045"; };
          "ui.cursor.primary.insert" = { bg = "white"; };
          "ui.cursor.primary.select" = { bg = "gray035"; };
          # TODO: Use proper search group after
          # https://github.com/helix-editor/helix/pull/5702
          # "ui.selection" = { /* fg = "accent01"; */ bg = "accent02"; };
          # "ui.selection.primary" = { /* fg = "accent01"; */ bg = "accent02"; };

          palette = {
            gray035 = "#4b4b49";
            gray045 = "#525250";
            accent01 = "#f0a0c0";
            accent02 = "#302028";
          };
        };
      };
    };

    services.emacs = lib.mkIf pkgs.stdenv.isLinux {
      enable = true;
      client.enable = true;
      socketActivation.enable = true;
    };
    programs.emacs = {
      enable = true;
      package = pkgs.emacs29-pgtk;
    };

    home.activation.installFootEmacsTerminfo = ''
      ${pkgs.ncurses}/bin/tic -x -o $HOME/.terminfo ${
        pkgs.fetchurl {
          url =
            "https://gist.githubusercontent.com/sefidel/5f7f46783ad527ada98caa13e32efd42/raw/509375cc7bff269bb3b906fd417ed3d51b4a1cc5/foot-emacs.src";
          sha256 = "sha256-aR/C40NWbrwYRIAvaRL/6gUAcP7xokChOVJIbyDXAwI=";
        }
      }
    '';

    home.packages = [
      # Launchable graphical emacsclient in bemenu
      (pkgs.writeShellScriptBin "ec" "emacsclient -cna emacs $@")
      # Emacsclient with 24bit colours fix for foot
      (pkgs.writeShellScriptBin "e" ''
        if [[ "$TERM" == "foot" ]]; then
           eprefix="TERM=foot-emacs"
         elif [[ "$TERM" == "foot-direct" ]]; then
           eprefix="TERM=foot-direct-emacs"
         fi
         eval "$eprefix emacsclient -ta emacs $@"
      '')

      pkgs.bfg-repo-cleaner
      pkgs.clang-tools
      pkgs.codespell
      pkgs.colmena
      pkgs.diffoscopeMinimal
      pkgs.du-dust
      pkgs.deploy-rs
      pkgs.dnsutils
      pkgs.gdb
      # TODO: https://github.com/cli/cli/issues/4955
      pkgs.gh
      pkgs.git-annex
      pkgs.git-filter-repo
      pkgs.hyperfine
      pkgs.jq
      pkgs.lsof
      pkgs.ouch
      pkgs.tcpdump
      pkgs.tokei
      pkgs.valgrind
      pkgs.mtr
      pkgs.nil
      pkgs.nixpkgs-fmt
      pkgs.nixpkgs-review
      pkgs.nmap
      pkgs.pyright
      pkgs.ripgrep
      pkgs.rust-analyzer
      pkgs.sd
      pkgs.tig
      pkgs.xh
      pkgs.cargo-play
      pkgs.cargo-edit
      pkgs.cargo-sort
      pkgs.cargo-diet
      pkgs.cargo-deny
      pkgs.lldb
      pkgs.ghc
      pkgs.ghidra
      pkgs.stack
      (pkgs.haskell-language-server.override { supportedGhcVersions = [ (builtins.replaceStrings [ "." ] [ "" ] pkgs.ghc.version) ]; })
      pkgs.sbcl
      pkgs.matrix-synapse-tools.synadm
      # pkgs.lispPackages.quicklisp
      # pkgs.lispPackages.clwrapper
      pkgs.pkg-config
      (pkgs.python3.withPackages (ps: with ps; [ pynvim ]))
      pkgs.gopls
    ];
  };
}