about summary refs log tree commit diff
path: root/nix/users/fcuny/home-manager.nix
blob: adb3adcbc034cc727e617c20ecf09d904e6a34de (plain) (blame)
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
{ ... }:

{ config, lib, pkgs, ... }:
let isLinux = pkgs.stdenv.isLinux;
in {
  home.stateVersion = "23.05";

  xdg.enable = true;

  home.packages = with pkgs;
    [
      # go
      go-tools
      golangci-lint
      gopls
      delve

      # docker
      dive # explore layers in docker images

      # shell
      shellcheck

      # git
      gitAndTools.pre-commit
      git-credential-manager
      gh

      # shell utils
      coreutils
      direnv
      dust
      procs
      ripgrep
      tree
      wget

      # network
      bandwhich

      # data manipulation
      jless
      jq
      yq

      # encryption
      age

      # media
      mpv
      ffmpeg

      # dicts
      aspell
      aspellDicts.en
      aspellDicts.en-computers
      aspellDicts.en-science

      # nix
      nil
      nix-direnv
      nixd
      nixfmt-classic
      nixpkgs-fmt
      nil # nix lsp

      # k8s
      kind # k8s in docker
      kubebuilder # generate controller
      kubectl
      kubernetes-helm # deploy applications
      kubie # kubeconfig browser https://github.com/sbstp/kubie
      kubelogin-oidc # OIDC plugin
      k9s # object explorer

      # hashicorp
      boundary
      nomad-pack
      tfswitch
    ] ++ (lib.optionals (isLinux) [ htop ]);

  programs.go = {
    enable = true;
    goPath = ".local/share/pkg.go";
    goBin = ".local/bin.go";
    goPrivate = [ "github.rbx.com/*" "github.com/fcuny/*" "git.fcuny.net/*" ];
  };

  # an alternative to ls
  programs.eza = {
    enable = true;
    icons = "never";
    enableFishIntegration = false;
    extraOptions = [
      "--group-directories-first"
      "--no-quotes"
      "--git-ignore"
      "--icons=never"
    ];
  };

  # an alternative to find
  programs.fd = {
    enable = true;
    hidden = true;
    ignores = [ ".git/" ".direnv/" ];
  };

  programs.direnv = {
    enable = true;
    nix-direnv.enable = true;
    enableZshIntegration = true;
    config = {
      global.disable_stdin = true;
      global.strict_env = true;
    };
  };

  programs.fish = {
    enable = true;
    interactiveShellInit = ''
      set fish_greeting ""
    '';

    shellAbbrs = { ncg = "nix-collect-garbage -d"; };
    shellAliases = {
      c = "clear";
      ls = "eza -l -L=1 --git --color=always --group-directories-first";
      la = "eza -la --git --color=always --group-directories-first";
      ll = "eza -la -L=1 --git --color=always --group-directories-first";
      lt = "eza -aT -L=2 --git --color=always --group-directories-first";
      k = "kubectl";
      kctx = "kubie ctx";
    };
  };

  programs.git = {
    enable = true;
    userName = "Franck Cuny";
    userEmail = "franck@fcuny.net";

    aliases = { amend = "commit --amend"; };

    includes = [
      {
        condition = "hasconfig:remote.*.url:git@github.rbx.com:**";
        path = pkgs.writeText "finsitGitConfig"
          (lib.generators.toGitINI { user.email = "fcuny@roblox.com"; });
      }
      {
        condition = "hasconfig:remote.*.url:git@github.com:Roblox/**";
        path = pkgs.writeText "finsitGitConfig"
          (lib.generators.toGitINI { user.email = "fcuny@roblox.com"; });
      }
    ];

    extraConfig = {
      core.whitespace = "trailing-space,space-before-tab";
      color.ui = "true";

      # abort if the remote branch does not match the local one
      push.default = "simple";

      # https://adamj.eu/tech/2024/01/18/git-improve-diff-histogram/
      diff.algorithm = "histogram";

      init.defaultBranch = "main";

      pull.rebase = true;
      rebase = {
        # Automatically create a temporary stash entry before the
        # operation begins, and apply it after the operation ends.
        autoStash = true;
        # Print a warning if some commits are removed
        missingCommitsCheck = "warn";
      };

      branch.autosetuprebase = "remote";
      branch.sort = "authordate";

      url = {
        "ssh://git@github.rbx.com/" = {
          insteadOf = "https://github.rbx.com/";
        };
      };
    };
  };

  programs.ssh = {
    enable = true;
    forwardAgent = true;
    serverAliveInterval = 60;
    controlMaster = "auto";
    controlPersist = "30m";
    extraConfig = ''
      IdentityAgent "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"
    '';
    matchBlocks = {
      "personal" = {
        hostname = "github.com";
        user = "git";
        forwardAgent = false;
        extraOptions = { preferredAuthentications = "publickey"; };
      };
      "github.com" = {
        hostname = "github.com";
        user = "git";
        forwardAgent = false;
        extraOptions = { preferredAuthentications = "publickey"; };
      };
      "github.rbx.com" = {
        hostname = "github.rbx.com";
        user = "git";
        forwardAgent = false;
        extraOptions = { preferredAuthentications = "publickey"; };
      };
    };
  };

  home.sessionPath = [ config.home.sessionVariables.GOBIN ];

  home.sessionVariables = with config.xdg; {
    ASPELL_CONF = "conf ${config.xdg.configHome}/aspell/config;";
    EDITOR = "emacsclient -a=";
    HOMEBREW_NO_AUTO_UPDATE = 1;
    IPYTHONDIR = "${cacheHome}/ipython";
    LESS = "-FRSXM";
    LESSCHARSET = "utf-8";
    MYPY_CACHE_DIR = "${cacheHome}/mypy";
    PAGER = "less";
    PIP_LOG = "${cacheHome}/pip/pip.log";
    PYLINTHOME = "${cacheHome}/pylint";
    PYTHON_EGG_CACHE = "${cacheHome}/python-eggs";
    SHELL = "${pkgs.fish}/bin/fish";
    VISUAL = "emacsclient -a=";
  };

  # Generate ssh agent config for 1Password
  # I want both my personal and work keys
  home.file.".config/1Password/ssh/agent.toml".text = ''
    [[ssh-keys]]
    account = "my.1password.com"

    [[ssh-keys]]
    account = "roblox.1password.com"
    item = "GitHub ssh key"
    vault = "Private"
  '';

  home.file.kubie = {
    target = ".kube/kubie.yaml";
    text = ''
      shell: fish
      configs:
        include:
          - ~/.kube/rksconfig
      prompt:
        fish_use_rprompt: true
    '';
  };
}