dot

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

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