-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.nix
148 lines (131 loc) · 3.99 KB
/
common.nix
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
{ lib, config, pkgs, ... }:
let
secrets = import ./secrets;
ms2ns = a: a * 1000 * 1000;
in {
# use bfq on all spinning disks
# TODO: add rules for Sata SSDs (mq-deadline or "none")
services.udev.extraRules = ''
ACTION=="add|change", KERNEL=="[sv]d[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="kyber", ATTR{queue/iosched/write_lat_nsec}="${
toString (ms2ns 400)
}", ATTR{queue/iosched/read_lat_nsec}="${toString (ms2ns 100)}"
ACTION=="add|change", KERNEL=="[sv]d[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="kyber", ATTR{queue/iosched/write_lat_nsec}="${
toString (ms2ns 40)
}", ATTR{queue/iosched/read_lat_nsec}="${toString (ms2ns 10)}"
'';
# Use the systemd-boot EFI boot loader.
boot.kernelPackages = pkgs.linuxPackages_latest;
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.kernelParams = [ "zswap.enabled=1" "zswap.compressor=lz4" "zswap.max_pool_percent=15" "zswap.zpool=z3fold" "hid_apple.fnmode=0" ];
boot.kernelModules = [ "z3fold" "lz4" ];
# Set your time zone.
time.timeZone = "Pacific/Auckland";
# Select internationalisation properties.
i18n.defaultLocale = "en_NZ.UTF-8";
console = {
font = "Lat2-Terminus16";
keyMap = "dvorak";
};
users.defaultUserShell = pkgs.zsh;
users.users.daniel = {
isNormalUser = true;
initialPassword = secrets.daniel.initialPass;
extraGroups =
[ "wheel" "audio" "networkmanager" ]; # Enable ‘sudo’ for the user.
openssh.authorizedKeys.keys = [ secrets.daniel.sshKey ];
};
environment.systemPackages = with pkgs; [
lm_sensors
pciutils
killall
file
schedtool
nix-prefetch-github
usbutils
lsof
smem
sysstat
wget
gnupg
direnv
starship
tmux
gist
home-manager
cachix
(aspellWithDicts (d: [ d.en d.en-computers d.en-science ]))
screen
weechat
irssi
vim
htop
rclone
git
age
git-crypt
syncthing
];
systemd.network.enable = true;
systemd.network.wait-online.timeout = 5;
networking.useDHCP = false;
systemd.network.networks."wired" = {
enable = true;
name = "en*";
DHCP = "yes";
networkConfig = {
IPv6AcceptRA = true;
IPv6PrivacyExtensions = "yes";
};
linkConfig.RequiredForOnline = "routable";
};
programs.zsh = with pkgs; {
enable = true;
enableCompletion = true;
autosuggestions.enable = true;
promptInit = ''
eval "$(${direnv}/bin/direnv hook zsh)"
eval "$(${starship}/bin/starship init zsh)"
'';
};
services.openssh.enable = true;
services.openssh.extraConfig = ''
TrustedUserCAKeys ${secrets.userCA}
'';
services.fail2ban = {
enable = false;
ignoreIP = [ "127.0.0.0/8" "::1" "home.gluo.nz" ];
# jails.DEFAULT = lib.mkAfter ''
# bantime = 3mo
# '';
};
#services.zerotierone.enable = true;
#services.zerotierone.joinNetworks = lib.attrValues secrets.zt;
services.smartd.enable = true;
services.smartd.defaults.autodetected = "-a -o off -s (O/../.././(01|07|13|19)|S/../.././04|L/../../0/05)";
nix = {
daemonCPUSchedPolicy = "idle";
settings = {
# generally we don't need more than one build running at once
# can sometimes cause OOM when jobs demand too much memory
max-jobs = 1;
auto-optimise-store = true;
trusted-users = [ "@wheel" ];
substituters = [
"https://yo-nur.cachix.org"
"https://nix-community.cachix.org"
"https://nix-gaming.cachix.org"
"https://cache.garnix.io"
];
trusted-public-keys = [
"yo-nur.cachix.org-1:E/RHfQMAZ90mPhvsaqo/GrQ3M1xzXf5Ztt0o+1X3+Bs="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4="
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
];
};
extraOptions = ''
experimental-features = nix-command flakes
'';
};
}