blob: 1904cdb1ddfd6769c001dd29d2e5d448a5bd8ac9 (
plain) (
blame)
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
|
{
config,
lib,
pkgs,
...
}:
with lib;
{
imports = attrValues (modulesIn ./.);
nixfiles.modules = {
ark.enable = true;
wireguard.client.enable = true;
syncthing.enable = true;
openssh.server.enable = true;
android.enable = true;
beets.enable = true;
bluetooth.enable = true;
games = {
lutris.enable = true;
minecraft.client.enable = true;
steam.enable = true;
steam-run.quirks.blackIsleStudios = true;
};
libvirtd.enable = true;
incus.enable = true;
mpd.enable = true;
qutebrowser.enable = true;
};
hm = {
home.packages = with pkgs; [
anki
gzdoom
iaito
kdenlive
krita
obs-studio
openmw
openttd
qbittorrent
qolibri
qzdl
radeontop
vcmi
vesktop
vial
wacomtablet
xonotic
];
programs = {
beets.settings.directory = mkForce "/mnt/udata/music";
mpv = {
profiles =
let
mapShaders = shaders: map (args: toString (pkgs.fetchurl args)) shaders;
cfl-prediction = mapShaders [
{
url = "https://raw.githubusercontent.com/Artoriuz/glsl-chroma-from-luma-prediction/471c65dd3915d39e7ef69957ab63e006125fbb88/CfL_Prediction.glsl";
sha256 = "sha256-Mgb1KqF1EPPzR3SCVr9S4XzVmZkYEEFIHSp59RZ9wq8=";
}
];
ravu-lite-ar-r4 = mapShaders [
{
url = "https://raw.githubusercontent.com/bjin/mpv-prescalers/b3f0a59d68f33b7162051ea5970a5169558f0ea2/compute/ravu-lite-ar-r4.hook";
sha256 = "sha256-gyBAv/Sf75CobVUugeTOhy54B9z8iIoJSJgnLopfMsY=";
}
];
ssimdownscaler = mapShaders [
{
url = "https://gist.githubusercontent.com/igv/36508af3ffc84410fe39761d6969be10/raw/575d13567bbe3caa778310bd3b2a4c516c445039/SSimDownscaler.glsl";
sha256 = "sha256-AEq2wv/Nxo9g6Y5e4I9aIin0plTcMqBG43FuOxbnR1w=";
}
];
in
{
# TODO Profile conditionals on width are not working.
"qhd-downscale" = {
dscale = "lanczos";
linear-downscaling = false;
glsl-shaders-append = ssimdownscaler;
};
"qhd-upscale" = {
glsl-shaders-append = cfl-prediction ++ ravu-lite-ar-r4;
};
};
config = {
profile = "gpu-hq";
vo = "gpu-next";
gpu-api = "vulkan";
hwdec = "auto";
deband = true;
deband-iterations = 4;
deband-threshold = 35;
deband-range = 16;
deband-grain = 5;
temporal-dither = true;
dither-depth = "auto";
dither = "fruit";
interpolation = true;
video-sync = "display-resample";
tscale = "oversample";
target-prim = "auto";
target-trc = "auto";
vf = "format=colorlevels=full:colormatrix=auto";
video-output-levels = "full";
glsl-shaders-append = map (text: toString (pkgs.writeText "shader.hook" text)) [
''
//!HOOK LUMA
//!BIND HOOKED
#define STRENGTH 48.0
float mod289(float x) { return x - floor(x / 289.0) * 289.0; }
float permute(float x) { return mod289((34.0*x + 1.0) * x); }
float rand(float x) { return fract(x / 41.0); }
vec4 hook() {
vec3 _m = vec3(HOOKED_pos, 1.0) + vec3(1.0);
float h = permute(permute(permute(_m.x)+_m.y)+_m.z);
vec4 noise;
noise.x = rand(h);
return HOOKED_tex(HOOKED_pos) + vec4(STRENGTH/8192.0) * (noise - 0.5);
}
''
''
//!HOOK CHROMA
//!BIND HOOKED
#define STRENGTH 48.0
float mod289(float x) { return x - floor(x / 289.0) * 289.0; }
float permute(float x) { return mod289((34.0*x + 1.0) * x); }
float rand(float x) { return fract(x / 41.0); }
vec4 hook() {
vec3 _m = vec3(HOOKED_pos, 0.5) + vec3(1.0);
float h = permute(permute(permute(_m.x)+_m.y)+_m.z);
vec4 noise;
noise.x = rand(h); h = permute(h);
noise.y = rand(h);
return HOOKED_tex(HOOKED_pos) + vec4(STRENGTH/8192.0) * (noise - 0.5);
}
''
];
};
};
};
services = {
mpd.musicDirectory = mkForce "/mnt/udata/music";
xsettingsd.settings."Xft/DPI" = "93";
};
};
services = {
smartd = {
enable = true;
notifications.mail = {
enable = true;
sender = "admin+smartd@${my.domain.shire}";
recipient = "admin+smartd@${my.domain.shire}";
};
};
openssh.settings = {
KbdInteractiveAuthentication = mkForce true;
PasswordAuthentication = mkForce true;
};
udev.packages = with pkgs; [ vial ];
xserver.wacom.enable = true;
};
# Usually stuff that is going to be compiled on this machine is going to have
# parallelisation support enabled, so we will make sure that all cores are
# utilised and limit the job queue to one.
nix.settings = {
max-jobs = 1;
cores = 32;
};
# Required[1] for using ZFS kernel modules with "unsupported" kernels.
#
# [1]: https://github.com/NixOS/nixpkgs/pull/121113#issuecomment-830003344
# [1]: https://github.com/NixOS/nixpkgs/pull/230498#issuecomment-1551328615
nixpkgs.config.allowBroken = true;
boot = {
kernelPackages = pkgs.linuxPackages_xanmod_latest;
kernelParams = [
# Silence benign MCE errors:
# ```
# mce: [Hardware Error]: CPU 1: Machine Check: 0 Bank 29: ffffffffffffffff
# mce: [Hardware Error]: TSC 0 MISC ff1fffffffffffff SYND ffffffffffffffff IPID ffffffffffffffff
# mce: [Hardware Error]: PROCESSOR 2:a60f12 TIME 1669988017 SOCKET 0 APIC 2 microcode a601201
# ```
"mce=nobootlog"
# This disables[1] User Mode Instruction Protection (UMIP)[2]. This is
# required for some games to run via Wine.
#
# [1]: https://docs.kernel.org/x86/cpuinfo.html
# [2]: https://en.wikichip.org/wiki/x86/umip
"clearcpuid=514"
];
# https://wiki.archlinux.org/title/improving_performance#Watchdogs
blacklistedKernelModules = [ "sp5100_tco" ];
# The boot drive is Samsung SSD 980 PRO 2TB.
initrd.kernelModules = [ "nvme" ];
# These pools were configured manually with a specific mountpoint.
zfs.extraPools = [
"udata"
"vdata"
];
};
# Filesystem creation:
# ```
# mkfs.vfat -F 32 -l nixos-boot /dev/nvmeXnYpZ
#
# zpool create
# -o ashift=12
# -o autotrim=on
# -O acltype=posixacl
# -O xattr=sa
# -O compression=zstd
# -O mountpoint=none
# nixos
# /dev/nvmeXnYpZ
#
# zfs create
# nixos/root
#
# zfs create
# -o encryption=aes-256-gcm
# -o keyformat=passphrase
# -o mountpoint=legacy
# nixos/root/ark
#
# zfs create
# -o mountpoint=legacy
# nixos/root/nix
# ```
#
# physical structure (backside):
# [ 1 ] [ 2 ] [ 3 ]
# 1: disk/by-id/ata-WDC_WD20SPZX-22UA7T0_WD-WXP2E3163YW6
# 2: disk/by-id/ata-WDC_WD20SPZX-22UA7T0_WD-WXN2E312R5HP
# 3: disk/by-id/ata-WDC_WD20SPZX-22UA7T0_WD-WXP2E311E6P2
#
# physical structure (mobo M.2):
# [ 1 ]
# [ 2 ]
# 1: disk/by-id/nvme-Samsung_SSD_980_PRO_2TB_S69ENF0R872526A
# 2: disk/by-id/nvme-Samsung_SSD_980_PRO_2TB_S69ENX0T807723X
fileSystems = {
"/" = {
device = "none";
fsType = "tmpfs";
options = [
"size=8G"
"mode=755"
];
};
"/boot" = {
device = "/dev/disk/by-uuid/1363-02E6";
fsType = "vfat";
};
"/nix" = {
device = "nixos/root/nix";
fsType = "zfs";
options = [ "noatime" ];
};
${config.ark.path} = {
device = "nixos/root/ark";
fsType = "zfs";
neededForBoot = true; # Required by impermanence.
};
# Required[1] when using impermanence with agenix. Filesystem itself is
# defined as an `ark.directory` in `nixos/common/users.nix`.
#
# [1]: https://github.com/ryantm/agenix/issues/45#issuecomment-847852593
# [1]: https://github.com/nix-community/impermanence/issues/22
# [1]: https://github.com/NixOS/nixpkgs/pull/86967#pullrequestreview-667929259
"/home/${my.username}" = {
depends = [ config.ark.path ];
neededForBoot = true;
};
};
# No swap space is declared here because the system already has 128Gb of RAM.
# I've only manage to hit around 100Gb mark when running large
# computations/compiling something big. Pretty sure that a hefty chunk of it
# was just cache and it wouldn't make me get to OOM situations.
}
|