about summary refs log tree commit diff
path: root/home/profiles/base/default.nix
blob: 80457f95d33bd10bfc9a1e23c9deea2db8a8d821 (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
{ config, lib, inputs, pkgs, self, ... }:
let
  cfg = config.profiles.base;

  neotheme = config.neotheme;
in
{
  imports = [
    ../../modules/programs/nixpkgs
    ../../modules/programs/zshell
    #../../modules/programs/zellij
  ];

  options.profiles.base.enable = lib.mkEnableOption
    "The base profile, contains general configurations.";

  config = lib.mkIf cfg.enable {
    home.sessionVariables = rec {
      # NIXOS_OZONE_WL = 1; # FIXME: interface 'wl_output' has no event 4
      EDITOR = "nvim";
      VISUAL = "nvim";
      GIT_EDITOR = EDITOR;

      # Airport
      AIRPORT_USER = "20963";
      AIRPORT_HOST = "hk-s020.rsync.net";
    };

    home.keyboard.layout = "us";
    home.packages = [
      # Nix Tools
      pkgs.nix-index
      pkgs.nix-tree
      pkgs.nix-top
      pkgs.nix-update
      pkgs.hydra-check

      pkgs.age
      pkgs.aria2
      pkgs.bottom
      pkgs.croc
      pkgs.fd

      pkgs.fzf
      pkgs.libnotify
      pkgs.procs
      pkgs.sops
      pkgs.tree
      pkgs.neovim

      pkgs.yubikey-manager
      pkgs.age-plugin-yubikey

      # Common build tools
      (pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override { extensions = [ "rust-src" ]; }))
      pkgs.go
      pkgs.gcc

      (pkgs.writeShellScriptBin "0x0" (import ./scripts/0x0.nix))
      (pkgs.writeShellScriptBin "airport" (import ./scripts/airport.nix))
    ] ++ lib.optionals (pkgs.stdenv.isDarwin) [
      pkgs.iterm2
      pkgs.rsync
    ];


    programs = {
      bat.enable = true;
      direnv.enable = true;
      direnv.nix-direnv.enable = true;
      exa.enable = true;
      exa.enableAliases = true;
      gpg.enable = true;
      gpg.settings.keyserver = "keys.openpgp.org";
      home-manager.enable = true;
      htop.enable = true;

      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";
            };
          };
        };
        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"; };

            palette = {
              gray035 = "#4b4b49";
              gray045 = "#525250";
            };
          };
        };
      };

      tmux = {
        enable = true;

        prefix = "C-f";
        terminal = "xterm-256color";
        shell = "${pkgs.zsh}/bin/zsh";
        baseIndex = 1;
        keyMode = "vi";

        escapeTime = 0;

        extraConfig = import ./config/tmux.nix;
      };



      zsh = {
        enable = true;

        enableCompletion = true;
        enableAutosuggestions = true;

        autocd = true;

        dotDir = ".config/zsh";

        plugins = [
          {
            name = "powerlevel10k";
            src = pkgs.zsh-powerlevel10k;
            file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
          }

          {
            name = "powerlevel10k-config";
            src = lib.cleanSource ./p10k-config;
            file = "p10k.zsh";
          }

          {
            name = "zsh-syntax-highlighting";
            src = pkgs.fetchFromGitHub {
              owner = "zsh-users";
              repo = "zsh-syntax-highlighting";
              rev = "0.7.1";
              sha256 = "03r6hpb5fy4yaakqm3lbf4xcvd408r44jgpv4lnzl9asp4sb9qc0";
            };
          }

          {
            name = "doas-zsh-plugin";
            src = pkgs.fetchFromGitHub {
              owner = "anatolykopyl";
              repo = "doas-zsh-plugin";
              rev = "17d0b55ca2acd12f7acc9e38c4ecaf413725be18";
              sha256 = "sha256-10rcF9cho9GuZCFQVIdFjvHCAlTLHNaLY4twxjT2jcE=";
            };
            file = "doas.plugin.zsh";
          }
        ];

        shellAliases = config.programs.zshell.aliases;
      } // lib.optionalAttrs (pkgs.stdenv.isDarwin) {
        initExtra = import ./config/zsh-darwin-gpg-ssh.nix;
      };

      zshell.aliases = {
        vim = "nvim";
        nvimdiff = "nvim -d";
      } // lib.optionalAttrs (pkgs.stdenv.isDarwin) {
        # <nixpkgs>/nixos/modules/config/shells-environment.nix
        clear = "clear && printf '\\e[3J'";
        l = "ls -alh";
      };

      zoxide = {
        enable = true;
        enableZshIntegration = true;
      };

      zellij = {
        enable = true;

        settings = {
          default_mode = "normal";
          pane_frames = false;
          simplified_ui = true; # bitmap fonts

          themes = {
            default = {
              # Industrial Jellybeans theme
              bg = [ 21 21 21 ];
              fg = [ 136 136 136 ];
              black = [ 28 28 28 ];
              gray = [ 64 64 64 ];
              white = [ 232 232 211 ];
              red = [ 141 61 38 ];
              orange = [ 250 187 110 ];
              yellow = [ 250 208 122 ];
              green = [ 153 173 106 ];
              blue = [ 129 151 191 ];
              cyan = [ 143 191 220 ];
              magenta = [ 198 182 238 ];
            };
          };
        };
      };
    };

    xdg.configFile."zellij/layouts/sdev.kdl".text = ''
      layout {
          pane size=1 borderless=true {
              plugin location="zellij:tab-bar"
          }
          pane split_direction="vertical" {
              pane size="80%" command="hx"
              pane size="20%"
          }
          pane size=2 borderless=true {
              plugin location="zellij:status-bar"
          }
      }
    '';

    services = {
      gpg-agent = lib.mkIf pkgs.stdenv.isLinux {
        enable = true;
        pinentryFlavor = "gtk2";
        defaultCacheTtl = 3600;
        defaultCacheTtlSsh = 3600;
        maxCacheTtl = 86400;
        maxCacheTtlSsh = 86400;
        enableSshSupport = true;
        sshKeys = [ "3C79004101E524D10B94F9EE9D3744F4B25F8795" "159371696FD285FF0811692FBFAA6E4AF017CDDE" ];
        extraConfig = ''
          allow-preset-passphrase
        '';
      };
    };

    home.file."${config.programs.gpg.homedir}/gpg-agent.conf".text = lib.mkIf pkgs.stdenv.isDarwin ''
      default-cache-ttl 3600
      default-cache-ttl-ssh 3600
      pinentry-program ${pkgs.pinentry_mac}/Applications/pinentry-mac.app/Contents/MacOS/pinentry-mac
      allow-preset-passphrase
      enable-ssh-support
    '';

    home.file."${config.programs.gpg.homedir}/sshcontrol".text = lib.mkIf pkgs.stdenv.isDarwin ''
      3C79004101E524D10B94F9EE9D3744F4B25F8795
      159371696FD285FF0811692FBFAA6E4AF017CDDE
    '';
  };
}