Skip to content

Commit 2d2f05c

Browse files
committed
fixup! wip: refactor to snowfall
1 parent 5742527 commit 2d2f05c

File tree

6 files changed

+209
-125
lines changed

6 files changed

+209
-125
lines changed

nix/modules/home/programs/zsh/default.nix

Lines changed: 110 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
}:
77
{
88
programs = {
9+
fzf = {
10+
enable = true;
11+
enableZshIntegration = true;
12+
};
13+
914
starship = {
1015
enable = true;
1116
enableZshIntegration = true;
@@ -44,98 +49,118 @@
4449
syntaxHighlighting = {
4550
enable = true;
4651
};
47-
initExtraFirst = # bash
52+
# initExtraFirst = # bash
53+
# ''
54+
# # avoid duplicated entries in PATH
55+
# typeset -U PATH
56+
#
57+
# # try to correct the spelling of commands
58+
# setopt correct
59+
# # disable C-S/C-Q
60+
# setopt noflowcontrol
61+
# # disable "no matches found" check
62+
# unsetopt nomatch
63+
#
64+
# # autosuggests otherwise breaks these widgets.
65+
# # <https://github.com/zsh-users/zsh-autosuggestions/issues/619>
66+
# ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(history-beginning-search-backward-end history-beginning-search-forward-end)
67+
#
68+
# # Do this early so fast-syntax-highlighting can wrap and override this
69+
# if autoload history-search-end; then
70+
# zle -N history-beginning-search-backward-end history-search-end
71+
# zle -N history-beginning-search-forward-end history-search-end
72+
# fi
73+
#
74+
# source <(${lib.getExe config.programs.fzf.package} --zsh)
75+
# source ${config.programs.git.package}/share/git/contrib/completion/git-prompt.sh
76+
#
77+
# # Prevent the command from being written to history before it's
78+
# # executed; save it to LASTHIST instead. Write it to history
79+
# # in precmd.
80+
# #
81+
# # called before a history line is saved. See zshmisc(1).
82+
# function zshaddhistory() {
83+
# # Remove line continuations since otherwise a "\" will eventually
84+
# # get written to history with no newline.
85+
# LASTHIST=''${1//\\$'\n'/}
86+
# # Return value 2: "... the history line will be saved on the internal
87+
# # history list, but not written to the history file".
88+
# return 2
89+
# }
90+
#
91+
# # zsh hook called before the prompt is printed. See zshmisc(1).
92+
# function precmd() {
93+
# # Write the last command if successful, using the history buffered by
94+
# # zshaddhistory().
95+
# if [[ $? == 0 && -n ''${LASTHIST//[[:space:]\n]/} && -n $HISTFILE ]] ; then
96+
# print -sr -- ''${=''${LASTHIST%%'\n'}}
97+
# fi
98+
# }
99+
# '';
100+
initExtra = # sh
48101
''
49-
# avoid duplicated entries in PATH
50-
typeset -U PATH
102+
setopt inc_append_history
51103
52-
# try to correct the spelling of commands
53-
setopt correct
54-
# disable C-S/C-Q
55-
setopt noflowcontrol
56-
# disable "no matches found" check
57-
unsetopt nomatch
104+
source "${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh"
105+
source "${pkgs.zsh-fzf-tab}/share/fzf-tab/fzf-tab.plugin.zsh"
106+
source "${pkgs.fzf}/share/fzf/key-bindings.zsh"
58107
59-
# autosuggests otherwise breaks these widgets.
60-
# <https://github.com/zsh-users/zsh-autosuggestions/issues/619>
61-
ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(history-beginning-search-backward-end history-beginning-search-forward-end)
108+
_zsh_cli_fg() { fg; }
109+
zle -N _zsh_cli_fg
110+
bindkey '^Z' _zsh_cli_fg
62111
63-
# Do this early so fast-syntax-highlighting can wrap and override this
64-
if autoload history-search-end; then
65-
zle -N history-beginning-search-backward-end history-search-end
66-
zle -N history-beginning-search-forward-end history-search-end
67-
fi
68-
69-
source <(${lib.getExe config.programs.fzf.package} --zsh)
70-
source ${config.programs.git.package}/share/git/contrib/completion/git-prompt.sh
71-
72-
# Prevent the command from being written to history before it's
73-
# executed; save it to LASTHIST instead. Write it to history
74-
# in precmd.
75-
#
76-
# called before a history line is saved. See zshmisc(1).
77-
function zshaddhistory() {
78-
# Remove line continuations since otherwise a "\" will eventually
79-
# get written to history with no newline.
80-
LASTHIST=''${1//\\$'\n'/}
81-
# Return value 2: "... the history line will be saved on the internal
82-
# history list, but not written to the history file".
83-
return 2
112+
function set_win_title(){
113+
echo -ne "\033]0; $(basename "$PWD") \007"
84114
}
85115
86-
# zsh hook called before the prompt is printed. See zshmisc(1).
87-
function precmd() {
88-
# Write the last command if successful, using the history buffered by
89-
# zshaddhistory().
90-
if [[ $? == 0 && -n ''${LASTHIST//[[:space:]\n]/} && -n $HISTFILE ]] ; then
91-
print -sr -- ''${=''${LASTHIST%%'\n'}}
92-
fi
93-
}
116+
precmd_functions+=(set_win_title)
117+
118+
source "${pkgs.kubectl}/share/zsh/site-functions/_kubectl"
94119
'';
95-
plugins = [
96-
{
97-
# Must be before plugins that wrap widgets, such as zsh-autosuggestions or fast-syntax-highlighting
98-
name = "fzf-tab";
99-
file = "share/fzf-tab/fzf-tab.plugin.zsh";
100-
src = pkgs.zsh-fzf-tab;
101-
}
102-
{
103-
name = "zsh-nix-shell";
104-
file = "share/zsh-nix-shell/nix-shell.plugin.zsh";
105-
src = pkgs.zsh-nix-shell;
106-
}
107-
{
108-
name = "zsh-vi-mode";
109-
src = pkgs.zsh-vi-mode;
110-
file = "share/zsh-vi-mode/zsh-vi-mode.plugin.zsh";
111-
}
112-
{
113-
name = "fast-syntax-highlighting";
114-
file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh";
115-
src = pkgs.zsh-fast-syntax-highlighting;
116-
}
117-
{
118-
name = "zsh-autosuggestions";
119-
file = "share/zsh-autosuggestions/zsh-autosuggestions.zsh";
120-
src = pkgs.zsh-autosuggestions;
121-
}
122-
{
123-
name = "zsh-better-npm-completion";
124-
src = pkgs.zsh-better-npm-completion;
125-
}
126-
{
127-
name = "zsh-command-time";
128-
src = pkgs.zsh-command-time;
129-
}
130-
{
131-
name = "zsh-history-to-fish";
132-
src = pkgs.zsh-history-to-fish;
133-
}
134-
{
135-
name = "zsh-you-should-use";
136-
src = pkgs.zsh-you-should-use;
137-
}
138-
];
120+
# plugins = [
121+
# {
122+
# # Must be before plugins that wrap widgets, such as zsh-autosuggestions or fast-syntax-highlighting
123+
# name = "fzf-tab";
124+
# file = "share/fzf-tab/fzf-tab.plugin.zsh";
125+
# src = pkgs.zsh-fzf-tab;
126+
# }
127+
# {
128+
# name = "zsh-nix-shell";
129+
# file = "share/zsh-nix-shell/nix-shell.plugin.zsh";
130+
# src = pkgs.zsh-nix-shell;
131+
# }
132+
# {
133+
# name = "zsh-vi-mode";
134+
# src = pkgs.zsh-vi-mode;
135+
# file = "share/zsh-vi-mode/zsh-vi-mode.plugin.zsh";
136+
# }
137+
# {
138+
# name = "fast-syntax-highlighting";
139+
# file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh";
140+
# src = pkgs.zsh-fast-syntax-highlighting;
141+
# }
142+
# {
143+
# name = "zsh-autosuggestions";
144+
# file = "share/zsh-autosuggestions/zsh-autosuggestions.zsh";
145+
# src = pkgs.zsh-autosuggestions;
146+
# }
147+
# {
148+
# name = "zsh-better-npm-completion";
149+
# src = pkgs.zsh-better-npm-completion;
150+
# }
151+
# {
152+
# name = "zsh-command-time";
153+
# src = pkgs.zsh-command-time;
154+
# }
155+
# {
156+
# name = "zsh-history-to-fish";
157+
# src = pkgs.zsh-history-to-fish;
158+
# }
159+
# {
160+
# name = "zsh-you-should-use";
161+
# src = pkgs.zsh-you-should-use;
162+
# }
163+
# ];
139164
};
140165
};
141166
}

nix/modules/nixos/nix/default.nix

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
config,
3+
lib,
4+
namespace,
5+
...
6+
}:
7+
let
8+
inherit (lib.${namespace}) mkModule;
9+
in
10+
mkModule ./. false config { } (_cfg: {
11+
documentation = {
12+
man.generateCaches = true;
13+
14+
nixos = {
15+
options = {
16+
warningsAreErrors = true;
17+
splitBuild = true;
18+
};
19+
};
20+
};
21+
22+
nix = {
23+
settings = {
24+
experimental-features = [
25+
"flakes"
26+
"nix-command"
27+
];
28+
};
29+
30+
generateNixPathFromInputs = true;
31+
generateRegistryFromInputs = true;
32+
linkInputs = true;
33+
};
34+
})
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
{
2+
config,
3+
lib,
4+
namespace,
5+
...
6+
}:
7+
let
8+
inherit (lib.${namespace}) mkModule;
9+
in
10+
mkModule ./. false config { } (_cfg: {
211
boot = {
312
supportedFilesystems.btrfs = true;
413
initrd.supportedFilesystems.btrfs = true;
514
};
6-
}
15+
})

nix/modules/nixos/storage/impermanence/default.nix

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,29 @@
88
let
99
inherit (lib.${namespace}) mkModule;
1010
in
11-
mkModule ./. false config
12-
{
13-
boot.initrd.postResumeCommands = lib.mkAfter ''
14-
mkdir /btrfs_tmp
15-
mount /dev/root_vg/root /btrfs_tmp
16-
if [[ -e /btrfs_tmp/root ]]; then
17-
mkdir -p /btrfs_tmp/old_roots
18-
timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/root)" "+%Y-%m-%-d_%H:%M:%S")
19-
mv /btrfs_tmp/root "/btrfs_tmp/old_roots/$timestamp"
20-
fi
11+
mkModule ./. false config { } (_cfg: {
12+
boot.initrd.postResumeCommands = lib.mkAfter ''
13+
mkdir /btrfs_tmp
14+
mount /dev/root_vg/root /btrfs_tmp
15+
if [[ -e /btrfs_tmp/root ]]; then
16+
mkdir -p /btrfs_tmp/old_roots
17+
timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/root)" "+%Y-%m-%-d_%H:%M:%S")
18+
mv /btrfs_tmp/root "/btrfs_tmp/old_roots/$timestamp"
19+
fi
2120
22-
delete_subvolume_recursively() {
23-
IFS=$'\n'
24-
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
25-
delete_subvolume_recursively "/btrfs_tmp/$i"
26-
done
27-
btrfs subvolume delete "$1"
28-
}
21+
delete_subvolume_recursively() {
22+
IFS=$'\n'
23+
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
24+
delete_subvolume_recursively "/btrfs_tmp/$i"
25+
done
26+
btrfs subvolume delete "$1"
27+
}
2928
30-
for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do
31-
delete_subvolume_recursively "$i"
32-
done
29+
for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do
30+
delete_subvolume_recursively "$i"
31+
done
3332
34-
btrfs subvolume create /btrfs_tmp/root
35-
umount /btrfs_tmp
36-
'';
37-
}
38-
(_cfg: {
39-
})
33+
btrfs subvolume create /btrfs_tmp/root
34+
umount /btrfs_tmp
35+
'';
36+
})

nix/systems/x86_64-linux/pve0/default.nix

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
(with inputs.nixos-hardware.nixosModules; [
1111
common-pc
1212
common-pc-ssd
13+
common-cpu-amd
1314
common-cpu-amd-pstate
1415
common-cpu-amd-zenpower
1516
])
@@ -36,13 +37,6 @@
3637

3738
system.stateVersion = "25.05";
3839

39-
services.openssh = {
40-
enable = true;
41-
settings = {
42-
PasswordAuthentication = true;
43-
};
44-
};
45-
4640
powerManagement = {
4741
cpuFreqGovernor = "powersave";
4842
powertop.enable = true;
@@ -52,6 +46,7 @@
5246
with pkgs;
5347
[
5448
htop
49+
ethtool
5550
pciutils
5651
powertop
5752
]
@@ -67,11 +62,32 @@
6762

6863
security.sudo.wheelNeedsPassword = false;
6964

70-
boot.kernelParams = [ "pcie_aspm.policy=powersave" ];
65+
boot.kernelParams = [
66+
"iommy=soft"
67+
"pcie_aspm.policy=powersave"
68+
"rcu_nocbs=all"
69+
"rcutree.enable_rcu_lazy=1"
70+
];
71+
programs = {
72+
neovim.enable = true;
73+
nix-ld.enable = true;
74+
};
7175

72-
services.udev.extraRules = ''
73-
ACTION=="add", SUBSYSTEM=="pci", ATTR{power/control}="auto"
74-
ACTION=="add", SUBSYSTEM=="scsi_host", KERNEL=="host*", ATTR{link_power_management_policy}="min_power"
75-
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/control", ATTR{power/control}="auto"
76-
'';
76+
services = {
77+
openssh = {
78+
enable = true;
79+
settings = {
80+
PasswordAuthentication = true;
81+
};
82+
};
83+
84+
udev.extraRules = ''
85+
ACTION=="add", SUBSYSTEM=="pci", ATTR{power/control}="auto"
86+
ACTION=="add", SUBSYSTEM=="scsi_host", KERNEL=="host*", ATTR{link_power_management_policy}="min_power"
87+
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/control", ATTR{power/control}="auto"
88+
'';
89+
90+
auto-cpufreq.enable = true;
91+
thermald.enable = true;
92+
};
7793
}

0 commit comments

Comments
 (0)