summaryrefslogtreecommitdiff
path: root/users/ryan/common.nix
blob: 4f692a2b2076b8b0aa2c4b6c3d5b31ac506c92ed (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
{ config, pkgs, lib, ... }:

{
  imports = [ ./modules/nvim ];

  news.display = "silent";

  # My own modules
  ryan.neovim.enable = true;

  programs.starship = {
    enable = true;
    settings = {
      add_newline = false;
      character = {
        success_symbol = "[➜](bold green)";
        error_symbol = "[➜](bold red)";
      };
      time = {
        disabled = false;
        format = "\[ $time \]($style)";
        time_format = "%T";
      };
    };
  };

  # Package/platform overrides (darwinDefaultsId, package = null for homebrew,
  # etc.) live in darwin.nix/linux.nix. Policies/profile are shared.
  programs.zen-browser = {
    enable = true;
    policies = import ./zen/zenPolicies.nix;
    profiles.default = import ./zen/zenProfile.nix;
  };

  programs.eza = {
    enable = true;
    enableZshIntegration = true;
  };

  programs.gpg.enable = true;

  programs.git = {
    enable = true;
    signing.signByDefault = true;
    settings = {
      user = {
        name = "Ryan Schanzenbacher";
        email = "ryan@rschanz.org";
      };
      core.pager = "${pkgs.delta}/bin/delta";
      init.defaultBranch = "main";
      merge.conflictStyle = "zdiff3";
      interactive.diffFilter = "${pkgs.delta}/bin/delta --color-only";
      delta = {
        navigate = true;
        side-by-side = true;
      };
      # Merged from guix-dotfiles' ~/.gitconfig - git-lfs filter and
      # git send-email settings, missing from the darwin config until now.
      filter.lfs = {
        clean = "git-lfs clean -- %f";
        smudge = "git-lfs smudge -- %f";
        process = "git-lfs filter-process";
        required = true;
      };
      sendemail = {
        smtpserver = "mail.rschanz.org";
        smtpuser = "ryan@rschanz.org";
        smtpencryption = "ssl";
        smtpserverport = 465;
      };
    };
  };

  programs.ssh = {
    enable = true;
    package = null; # installed by default

    enableDefaultConfig = false;

    settings = {
      "rocApex" = {
        hostname = "129.158.232.104";
        user = "root";
      };
      "hetzner" = {
        hostname = "5.161.207.21";
        user = "root";
      };
      "rncorepub" = {
        hostname = "5.161.89.186";
        user = "root";
      };
      # Merged from guix-dotfiles' ~/.ssh/config - hosts and quirks missing
      # from the darwin config until now.
      "linode" = {
        hostname = "97.107.142.58";
        user = "root";
      };
      # `settings` has a freeform type, so upstream ssh_config directive
      # names can be set directly - `programs.ssh.settings.*.extraOptions`
      # is explicitly unsupported (hard assertion failure) in this HM version.
      "192.168.216.1" = {
        HostKeyAlgorithms = "+ssh-rsa";
        PubkeyAcceptedAlgorithms = "+ssh-rsa";
      };
      "*" = {
        KexAlgorithms = "-sntrup761x25519-sha512@openssh.com";
      };
    };

    # HM always renders the "*" block last regardless of dag order, so this
    # trailing exec-only Match block (no directives of its own - position
    # relative to the Host blocks above doesn't matter) is safe to append here.
    # `settings."*"` above satisfies the assertion that gates using extraConfig.
    extraConfig = ''
      Match host * exec "gpg-connect-agent UPDATESTARTUPTTY /bye"
    '';
  };

  services.gpg-agent = {
    enable = pkgs.stdenv.isLinux;
    enableSshSupport = true;
  };

  programs.zsh = {
    enable = true;
    initContent = let
      brewPath = if pkgs.stdenv.isDarwin && pkgs.stdenv.isAarch64 then ''
        eval "$(/opt/homebrew/bin/brew shellenv)"
      '' else "";
    in ''
      export GPG_TTY="$(tty)"
      export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
      gpgconf --launch gpg-agent
      gpg-connect-agent updatestartuptty /bye > /dev/null
      ${brewPath}
    '';
    shellAliases = {
      cat = "bat --paging=never";
      diff = "delta";
      brew = "env -u XDG_CONFIG_HOME brew";
      # Merged from guix-dotfiles' bash aliases (home-bash-service-type) -
      # bash is being retired there in favor of this zsh config. `ls`/`spt`/
      # `python` are Linux-only (BSD ls on darwin doesn't take --color/-p,
      # spotify_player and python3 aren't darwin things) - see linux.nix.
      grep = "grep --color=auto";
      ll = "ls -l";
      rebuild =
        if pkgs.stdenv.isDarwin
        then "sudo darwin-rebuild switch --flake ~/.config/nix/."
        else "home-manager switch --flake ~/.config/home-manager/#ryan";
    };
  };

  # Shared across darwin and linux; the guix side already deferred these
  # packages to nix (all commented out of home-configuration.scm's package
  # list), same as the darwin config always has.
  home.packages = with pkgs; [
    yt-dlp
    aerc
    gdu
    taskwarrior3
    delta
    kubectl
    talhelper
    talosctl
    prismlauncher
  ];

  xdg.configFile."aerc" = {
    source = ./aerc;
    recursive = true;
  };

  home.sessionVariables = {
    XDG_CONFIG_HOME = "${config.home.homeDirectory}/.config";
    EDITOR = "${pkgs.neovim}/bin/nvim";
  };

  programs.home-manager.enable = true;
}