dot

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

132 lines3727 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. Built as you, with sudo only for the switch:
59 # Nix won't read a git checkout owned by someone else, so a root build
60 # of this one fails.
61 update = "nix flake update --flake ${config.dot.repoPath} && nixos-rebuild switch --sudo --flake ${config.dot.repoPath}";
62 rebuild = "nixos-rebuild switch --sudo --flake ${config.dot.repoPath}";
63 cleanup = "sudo nix-collect-garbage --delete-older-than 14d";
64 };
65
66 initContent = lib.mkMerge [
67 # Powerlevel10k instant prompt. Must stay at the very top: anything that
68 # may ask for input goes above it, everything else below.
69 (lib.mkOrder 500 ''
70 if [[ -r "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh" ]]; then
71 source "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh"
72 fi
73 '')
74 ''
75 export HISTCONTROL=ignoreboth
76 export HISTORY_IGNORE="(\&|[bf]g|c|clear|history|exit|q|pwd|* --help)"
77
78 # Bold green headings in man pages.
79 export LESS_TERMCAP_md="$(tput bold 2> /dev/null; tput setaf 2 2> /dev/null)"
80 export LESS_TERMCAP_me="$(tput sgr0 2> /dev/null)"
81
82 [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
83 POWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD=true
84 ''
85 ];
86 };
87
88 programs.fzf.enable = true;
89
90 # "command not found" suggests the package to install, like pkgfile did.
91 programs.nix-index.enable = true;
92 programs.nix-index.enableZshIntegration = true;
93
94 programs.bash.enable = true;
95
96 programs.git = {
97 enable = true;
98 settings.user = {
99 name = "Gustaf Granström";
100 email = "gustaf@granstrm.com";
101 };
102 };
103
104 # Also makes git use gh for GitHub credentials, as in your old .gitconfig.
105 programs.gh = {
106 enable = true;
107 gitCredentialHelper.enable = true;
108 };
109
110 # ~/.ssh/config. Your keys, known_hosts and authorized_keys stay where they are
111 # in ~/.ssh and are not part of this repo.
112 programs.ssh = {
113 enable = true;
114 enableDefaultConfig = false;
115 settings = {
116 granstrm = {
117 HostName = "granstrm.com";
118 User = "root";
119 IdentityFile = "~/.ssh/id_ed25519";
120 };
121 # Media center laptop, behind the Google Wifi (10.0.0.100), which
122 # forwards port 2222 to the laptop's SSH.
123 tv = {
124 HostName = "10.0.0.100";
125 Port = 2222;
126 User = "tv";
127 IdentityFile = "~/.ssh/id_ed25519";
128 };
129 };
130 };
131
132}