dot

vizie's NixOS desktop: Hyprland, CachyOS kernel and gaming tweaks

130 lines3574 bytesNix
1# zsh as CachyOS set it up (cachyos-zsh-config: oh-my-zsh, Powerlevel10k and the
2# fish-like plugins), plus git, gh and ssh.
3{
4 config,
5 lib,
6 pkgs,
7 ...
8}:
9{
10 programs.zsh = {
11 enable = true;
12
13 # Same history file and sizes as before (oh-my-zsh's defaults), so your
14 # history carries over.
15 history = {
16 path = "${config.home.homeDirectory}/.zsh_history";
17 size = 50000;
18 save = 10000;
19 ignoreSpace = true;
20 ignoreDups = true;
21 };
22
23 oh-my-zsh = {
24 enable = true;
25 plugins = [
26 "git"
27 "fzf"
28 "extract"
29 ];
30 extraConfig = ''
31 DISABLE_MAGIC_FUNCTIONS="true"
32 ENABLE_CORRECTION="true"
33 COMPLETION_WAITING_DOTS="true"
34 '';
35 };
36
37 syntaxHighlighting.enable = true;
38 autosuggestion.enable = true;
39 historySubstringSearch.enable = true;
40
41 plugins = [
42 {
43 name = "powerlevel10k";
44 src = pkgs.zsh-powerlevel10k;
45 file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
46 }
47 ];
48
49 shellAliases = {
50 make = "make -j$(nproc)";
51 ninja = "ninja -j$(nproc)";
52 n = "ninja";
53 c = "clear";
54 please = "sudo";
55 tb = "nc termbin.com 9999";
56 jctl = "journalctl -p 3 -xb";
57
58 # The pacman ones, for NixOS.
59 update = "nix flake update --flake ${config.dot.repoPath} && sudo nixos-rebuild switch --flake ${config.dot.repoPath}";
60 rebuild = "sudo nixos-rebuild switch --flake ${config.dot.repoPath}";
61 cleanup = "sudo nix-collect-garbage --delete-older-than 14d";
62 };
63
64 initContent = lib.mkMerge [
65 # Powerlevel10k instant prompt. Must stay at the very top: anything that
66 # may ask for input goes above it, everything else below.
67 (lib.mkOrder 500 ''
68 if [[ -r "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh" ]]; then
69 source "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh"
70 fi
71 '')
72 ''
73 export HISTCONTROL=ignoreboth
74 export HISTORY_IGNORE="(\&|[bf]g|c|clear|history|exit|q|pwd|* --help)"
75
76 # Bold green headings in man pages.
77 export LESS_TERMCAP_md="$(tput bold 2> /dev/null; tput setaf 2 2> /dev/null)"
78 export LESS_TERMCAP_me="$(tput sgr0 2> /dev/null)"
79
80 [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
81 POWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD=true
82 ''
83 ];
84 };
85
86 programs.fzf.enable = true;
87
88 # "command not found" suggests the package to install, like pkgfile did.
89 programs.nix-index.enable = true;
90 programs.nix-index.enableZshIntegration = true;
91
92 programs.bash.enable = true;
93
94 programs.git = {
95 enable = true;
96 settings.user = {
97 name = "Gustaf Granström";
98 email = "gustaf@granstrm.com";
99 };
100 };
101
102 # Also makes git use gh for GitHub credentials, as in your old .gitconfig.
103 programs.gh = {
104 enable = true;
105 gitCredentialHelper.enable = true;
106 };
107
108 # ~/.ssh/config. Your keys, known_hosts and authorized_keys stay where they are
109 # in ~/.ssh and are not part of this repo.
110 programs.ssh = {
111 enable = true;
112 enableDefaultConfig = false;
113 settings = {
114 granstrm = {
115 HostName = "granstrm.com";
116 User = "root";
117 IdentityFile = "~/.ssh/id_ed25519";
118 };
119 # Media center laptop, behind the Google Wifi (10.0.0.100), which
120 # forwards port 2222 to the laptop's SSH.
121 tv = {
122 HostName = "10.0.0.100";
123 Port = 2222;
124 User = "tv";
125 IdentityFile = "~/.ssh/id_ed25519";
126 };
127 };
128 };
129
130}