dot
vizie's NixOS desktop: Hyprland, CachyOS kernel and gaming tweaks
4ec10ba
4 files changed +159 −8
modifiedMIGRATION.md
@@ -18,12 +18,18 @@ | ||
| 18 | 18 | - |
| 19 | 19 | |
| 20 | 20 | |
| 21 | - | |
| 21 | + | |
| 22 | 22 | |
| 23 | 23 | |
| 24 | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 25 | 31 | |
| 26 | - | |
| 32 | + | |
| 27 | 33 | |
| 28 | 34 | |
| 29 | 35 | |
@@ -51,7 +57,7 @@ | ||
| 51 | 57 | |
| 52 | 58 | |
| 53 | 59 | |
| 54 | - | |
| 60 | + | |
| 55 | 61 | |
| 56 | 62 | |
| 57 | 63 | |
@@ -62,11 +68,13 @@ | ||
| 62 | 68 | |
| 63 | 69 | |
| 64 | 70 | |
| 65 | - | |
| 71 | + | |
| 66 | 72 | |
| 67 | 73 | |
| 68 | 74 | |
| 69 | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 70 | 78 | |
| 71 | 79 | |
| 72 | 80 | |
modifiedREADME.md
@@ -31,6 +31,7 @@ | ||
| 31 | 31 | packages.nix tools the scripts call; imsh-clients, philly |
| 32 | 32 | |
| 33 | 33 | |
| 34 | + | |
| 34 | 35 | |
| 35 | 36 | |
| 36 | 37 | |
modifiedmodules/nixos/nvidia.nix
@@ -8,6 +8,26 @@ | ||
| 8 | 8 | }: |
| 9 | 9 | let |
| 10 | 10 | cfg = config.dot.nvidia; |
| 11 | + | |
| 12 | + # The driver CachyOS runs: 615.78.08. The kernel's package set comes from the | |
| 13 | + # nixpkgs the CachyOS kernel flake pins (cachyos.nix), which can be a driver | |
| 14 | + # release behind the system's nixpkgs. Then the driver is built from the | |
| 15 | + # system nixpkgs' definition instead (pkgs/os-specific/linux/nvidia-x11), | |
| 16 | + # against the same kernel. Once the pinned set catches up, its own driver is | |
| 17 | + # used again and this can go. | |
| 18 | + pinnedDriver = config.boot.kernelPackages.nvidiaPackages.latest; | |
| 19 | + nvidiaDriver = | |
| 20 | + if lib.versionAtLeast pinnedDriver.version "615.78.08" then | |
| 21 | + pinnedDriver | |
| 22 | + else | |
| 23 | + config.boot.kernelPackages.nvidiaPackages.mkDriver { | |
| 24 | + version = "615.78.08"; | |
| 25 | + sha256_64bit = "sha256-Pj9t3cLudnoIGFMAr3vjyyhuznZpjS3eNSRZl4LQf/4="; | |
| 26 | + sha256_aarch64 = "sha256-UHYBE1AYHoGgMfD9AS/jX+S+N8eCDWUft6qolK9Eejc="; | |
| 27 | + openSha256 = "sha256-HBINiOjL0ZJLIAJeNIBYHBnwgUXtNwPPtnFpAI1YwF4="; | |
| 28 | + settingsSha256 = "sha256-inDRpG02sdDgHmlqgu/DsgK8OFdOt1fZIYyXdhlGC/c="; | |
| 29 | + persistencedSha256 = "sha256-RzeR6Ldct6MUxjnXRyThdh5Y3jjMehTVg85MtwuWNX4="; | |
| 30 | + }; | |
| 11 | 31 | in |
| 12 | 32 | { |
| 13 | 33 | options.dot.nvidia.enable = lib.mkEnableOption "the NVIDIA driver" // { |
@@ -27,8 +47,7 @@ | ||
| 27 | 47 | |
| 28 | 48 | hardware.nvidia = { |
| 29 | 49 | open = true; |
| 30 | - # 615.x, the same branch CachyOS has. | |
| 31 | - package = config.boot.kernelPackages.nvidiaPackages.latest; | |
| 50 | + package = nvidiaDriver; | |
| 32 | 51 | modesetting.enable = true; |
| 33 | 52 | nvidiaSettings = true; |
| 34 | 53 | # Not set up on CachyOS either (no nvidia-suspend services enabled). |
addedtools/bench-compare
@@ -1,0 +1,123 @@ | ||
| 1 | +#!/usr/bin/env python3 | |
| 2 | +"""Compare MangoHud frame logs from CachyOS and NixOS (see MIGRATION.md). | |
| 3 | + | |
| 4 | + tools/bench-compare every log in ~/benchmarks | |
| 5 | + tools/bench-compare DIR|FILE ... the logs given | |
| 6 | + | |
| 7 | +Logs are grouped by the OS MangoHud wrote into each file's header, so logs | |
| 8 | +from both systems can sit in one folder. For each run it shows the average | |
| 9 | +FPS, the 1% and 0.1% lows (the FPS of the slowest 1% and 0.1% of frames) and | |
| 10 | +the longest frame; then each system's average over its runs, and how far | |
| 11 | +NixOS is from CachyOS. | |
| 12 | + | |
| 13 | +Record with log_interval=0 so every frame is logged; with sampled logs the | |
| 14 | +lows are only estimates. | |
| 15 | +""" | |
| 16 | +import csv | |
| 17 | +import statistics | |
| 18 | +import sys | |
| 19 | +from pathlib import Path | |
| 20 | + | |
| 21 | + | |
| 22 | +def read_log(path): | |
| 23 | + """Return (os name, frame times in ms) from one MangoHud CSV log.""" | |
| 24 | + rows = list(csv.reader(path.open(newline="", errors="replace"))) | |
| 25 | + os_name = "unknown" | |
| 26 | + frametimes = None | |
| 27 | + for i, row in enumerate(rows): | |
| 28 | + cols = [c.strip().lower() for c in row] | |
| 29 | + if cols[:1] == ["os"] and i + 1 < len(rows) and rows[i + 1]: | |
| 30 | + os_name = rows[i + 1][0].strip() or os_name | |
| 31 | + elif "frametime" in cols: | |
| 32 | + col = cols.index("frametime") | |
| 33 | + frametimes = [] | |
| 34 | + for data in rows[i + 1 :]: | |
| 35 | + try: | |
| 36 | + frametimes.append(float(data[col])) | |
| 37 | + except (IndexError, ValueError): | |
| 38 | + continue | |
| 39 | + break | |
| 40 | + if not frametimes: | |
| 41 | + return os_name, [] | |
| 42 | + # Older MangoHud versions log microseconds, newer ones milliseconds. | |
| 43 | + if statistics.median(frametimes) > 200: | |
| 44 | + frametimes = [t / 1000 for t in frametimes] | |
| 45 | + return os_name, [t for t in frametimes if t > 0] | |
| 46 | + | |
| 47 | + | |
| 48 | +def low(frametimes, fraction): | |
| 49 | + """FPS of the slowest `fraction` of frames (averaged, as MangoHud does).""" | |
| 50 | + worst = sorted(frametimes, reverse=True) | |
| 51 | + n = max(1, int(len(worst) * fraction)) | |
| 52 | + return 1000 / statistics.fmean(worst[:n]) | |
| 53 | + | |
| 54 | + | |
| 55 | +def stats(frametimes): | |
| 56 | + return { | |
| 57 | + "avg": 1000 / statistics.fmean(frametimes), | |
| 58 | + "1%": low(frametimes, 0.01), | |
| 59 | + "0.1%": low(frametimes, 0.001), | |
| 60 | + "max ms": max(frametimes), | |
| 61 | + } | |
| 62 | + | |
| 63 | + | |
| 64 | +def short_os(name): | |
| 65 | + lower = name.lower() | |
| 66 | + if "cachyos" in lower: | |
| 67 | + return "CachyOS" | |
| 68 | + if "nixos" in lower: | |
| 69 | + return "NixOS" | |
| 70 | + return name | |
| 71 | + | |
| 72 | + | |
| 73 | +def main(args): | |
| 74 | + targets = [Path(a) for a in args] or [Path.home() / "benchmarks"] | |
| 75 | + files = [] | |
| 76 | + for target in targets: | |
| 77 | + if target.is_dir(): | |
| 78 | + files += sorted(target.rglob("*.csv")) | |
| 79 | + elif target.exists(): | |
| 80 | + files.append(target) | |
| 81 | + else: | |
| 82 | + sys.exit(f"bench-compare: {target} doesn't exist") | |
| 83 | + files = [f for f in files if not f.stem.endswith("_summary")] | |
| 84 | + if not files: | |
| 85 | + sys.exit("bench-compare: no MangoHud logs found") | |
| 86 | + | |
| 87 | + keys = ["avg", "1%", "0.1%", "max ms"] | |
| 88 | + header = f"{'':38}" + "".join(f"{k:>9}" for k in keys) | |
| 89 | + groups = {} | |
| 90 | + print(header) | |
| 91 | + for f in files: | |
| 92 | + os_name, frametimes = read_log(f) | |
| 93 | + if len(frametimes) < 100: | |
| 94 | + print(f"{f.name[:38]:38} skipped: {len(frametimes)} frames") | |
| 95 | + continue | |
| 96 | + s = stats(frametimes) | |
| 97 | + system = short_os(os_name) | |
| 98 | + groups.setdefault(system, []).append(s) | |
| 99 | + label = f"{system} {f.name}"[:38] | |
| 100 | + print(f"{label:38}" + "".join(f"{s[k]:9.1f}" for k in keys)) | |
| 101 | + | |
| 102 | + print() | |
| 103 | + print(f"{'average of runs':38}" + "".join(f"{k:>9}" for k in keys)) | |
| 104 | + means = {} | |
| 105 | + for system, runs in groups.items(): | |
| 106 | + means[system] = {k: statistics.fmean(r[k] for r in runs) for k in keys} | |
| 107 | + label = f"{system} ({len(runs)} runs)" | |
| 108 | + print(f"{label:38}" + "".join(f"{means[system][k]:9.1f}" for k in keys)) | |
| 109 | + | |
| 110 | + if "CachyOS" in means and "NixOS" in means: | |
| 111 | + a, b = means["CachyOS"], means["NixOS"] | |
| 112 | + diff = "".join(f"{(b[k] - a[k]) / a[k] * 100:+8.1f}%" for k in keys) | |
| 113 | + print(f"{'NixOS vs CachyOS':38}{diff}") | |
| 114 | + print("(higher is better for FPS columns, lower is better for max ms)") | |
| 115 | + # Run-to-run noise on the same system, to judge whether a gap is real. | |
| 116 | + for system, runs in groups.items(): | |
| 117 | + if len(runs) > 1: | |
| 118 | + spread = statistics.pstdev(r["avg"] for r in runs) | |
| 119 | + print(f"{system}: average FPS varies ±{spread:.1f} between runs") | |
| 120 | + | |
| 121 | + | |
| 122 | +if __name__ == "__main__": | |
| 123 | + main(sys.argv[1:]) |