aboutsummaryrefslogtreecommitdiffhomepage
path: root/home-manager/home.nix
blob: fbd38c5f853c61822ce6a2e11019966e1216b66a (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
{ pkgs, specialArgs, ... }:
let
  username = specialArgs.env.username;
  homeDirectory = specialArgs.env.homeDirectory;
  clipboardCopyCommand = specialArgs.env.gui.clipboard.copyCommand;
  requiresWlClipboard = clipboardCopyCommand == "wl-copy";
in
{
  home.username = username;
  home.homeDirectory = homeDirectory;

  home.stateVersion = "23.11";

  programs.home-manager.enable = true;

  home.packages = [
    # pkgs.alacritty
    pkgs.bat
    pkgs.cmake
    pkgs.curl
    pkgs.deno
    pkgs.fd
    pkgs.fzf
    pkgs.gcc
    pkgs.git
    pkgs.go
    pkgs.gopls
    pkgs.jq
    pkgs.neovim
    pkgs.nodejs_18
    pkgs.pandoc
    pkgs.php
    pkgs.pwgen
    pkgs.python311
    pkgs.ripgrep
    pkgs.ruby_3_1
    pkgs.rustup
    pkgs.sqlite
    pkgs.tokei
    pkgs.tree
    pkgs.zig

    pkgs.nodePackages.typescript-language-server
  ] ++ pkgs.lib.optional requiresWlClipboard pkgs.wl-clipboard;

  home.file = {
    # "hoge".source = dotfiles/piyo;
  };

  home.sessionVariables = rec {
    # XDG Base Directories
    # See: https://wiki.archlinux.org/title/XDG_Base_Directory
    XDG_CONFIG_HOME = "${homeDirectory}/.config";
    XDG_CACHE_HOME = "${homeDirectory}/.cache";
    XDG_DATA_HOME = "${homeDirectory}/.local/share";
    XDG_STATE_HOME = "${homeDirectory}/.local/state";
    # XDG Base Directories: Node.js
    NODE_REPL_HISTORY = "${XDG_CACHE_HOME}/node_repl_history";
    # XDG Base Directories: SQLite
    SQLITE_HISTORY = "${XDG_CACHE_HOME}/sqlite_history";

    # Local
    LANG = "en_US.UTF-8";
    LC_ALL = "";
    # Locale: Less
    LESSCHARSET = "utf-8";
  };

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

  programs.tmux = {
    enable = true;

    sensibleOnTop = false;

    aggressiveResize = true;
    baseIndex = 1;
    clock24 = true;
    escapeTime = 0;
    historyLimit = 50000;
    mouse = false;
    prefix = "C-t";
    terminal = "tmux-256color";

    extraConfig =
      let
        commonConfig = builtins.readFile ./config/tmux/tmux.conf;
        extraConfig = if clipboardCopyCommand != null then
          ''
            bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "${clipboardCopyCommand}"
          ''
        else
          "";
      in
      commonConfig + extraConfig;
  };

  programs.zsh = {
    enable = true;

    envExtra = ''
      export PATH="$HOME/bin:$HOME/.local/bin:$PATH"
    '';

    initExtra = builtins.readFile ../.zshrc;
  };

  programs.starship = {
    enable = true;

    settings = {
      add_newline = true;
      format = "[$directory$git_branch$git_commit$git_status$git_state](bold fg:75)$fill$cmd_duration$time$line_break$character";
      continuation_prompt = "[❯](fg:63)[❯](fg:62)[❯](fg:61) ";
      character = {
        success_symbol = "[❯](fg:150)[❯](fg:153)[❯](fg:159)";
        error_symbol = "[❯](fg:172)[❯](fg:173)[❯](fg:174)";
      };
      directory = {
        format = "$path ";
        use_os_path_sep = false;
        truncate_to_repo = false;
        truncation_length = 99;
      };
      git_branch = {
        format = "\\($branch\\)";
      };
      git_commit = {
        format = "($hash$tag)";
        tag_disabled = false;
        tag_symbol = " @";
      };
      git_status = {
        format = "$conflicted$modified$untracked$staged$stashed";
        conflicted = "!";
        modified = "~";
        untracked = "?";
        staged = "*";
        stashed = " \\[$count\\]";
      };
      git_state = {
        format = " - $state ($progress_current/$progress_total) ";
      };
      cmd_duration = {
        format = "~$duration ";
      };
      time = {
        disabled = false;
        format = "\\[$time\\] ";
        time_format = "%T";
      };
      fill = {
        symbol = " ";
      };
    };
  };
}