Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions home-config/applications/graphical/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
apvlv
feh
yubioath-flutter
obsidian
];

programs.alacritty = {
Expand Down
2 changes: 2 additions & 0 deletions home-config/dotfiles/sway.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ output "Dell Inc. DELL G2723HN 5B0C3H3" {
max_render_time 3
}

output "GSS edid.build 0x00000001" disable

# Window decorations

client.focused $lavender $base $text $lavender $lavender
Expand Down
1 change: 1 addition & 0 deletions nixos-config/desktop/greeter/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ let

sway-gtkgreet = pkgs.writeText "sway-gtkgreet" ''
output '*' background #fafafa solid_color
output 'GSS edid.build 0x00000001' disable
seat seat0 xcursor_theme Bibata-Original-Ice 24

exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK
Expand Down
13 changes: 10 additions & 3 deletions nixos-config/hosts/yui/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, flake-inputs, ... }:
{ lib, flake-inputs, ... }:
{
imports = [
flake-inputs.disko.nixosModules.disko
Expand All @@ -19,14 +19,21 @@

nixpkgs.config.allowUnfreePredicate =
pkg:
builtins.elem (pkgs.lib.getName pkg) [
(builtins.elem (lib.getName pkg) [
"steam"
"steam-run"
# Required to get the steam controller to work (i.e., for hardware.steam-hardware)
"steam-original"
"steam-unwrapped"
"nvidia-x11"
];
"obsidian"
# For sunshine streams with nvenc
"cuda-merged"
"libnpp"
])
|| (lib.strings.hasPrefix "cuda_" (lib.getName pkg))
|| (lib.strings.hasPrefix "libcu" (lib.getName pkg))
|| (lib.strings.hasPrefix "libnv" (lib.getName pkg));

home-manager.users.tlater = import "${flake-inputs.self}/home-config/hosts/yui.nix";

Expand Down
2 changes: 2 additions & 0 deletions nixos-config/hosts/yui/games.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ in
nix-gaming.nixosModules.pipewireLowLatency
nix-gaming.nixosModules.platformOptimizations
nix-gaming.nixosModules.wine

./sunshine.nix
];

environment.systemPackages =
Expand Down
123 changes: 123 additions & 0 deletions nixos-config/hosts/yui/sunshine.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
flake-inputs,
config,
pkgs,
lib,
...
}:
let
inherit (flake-inputs.self.packages.${pkgs.stdenv.hostPlatform.system}) edid-generator;
in
{
nix.settings = {
substituters = [ "https://cache.nixos-cuda.org" ];
trusted-public-keys = [ "cache.nixos-cuda.org:74DUi4Ye579gUqzH4ziL9IyiJBlDpMRn9MBN8oNan9M=" ];
};

# Create a virtual display to render games for sunshine on
hardware.display = {
edid.packages = [
(pkgs.runCommand "VTCL65C825.bin"
{
nativeBuildInputs = [ edid-generator ];
settings = pkgs.writers.writeJSON "edid.json" {
defaultMode = {
width = 1920;
height = 1080;
refresh = 120;
};
modes = [
{
width = 1920;
height = 1080;
refresh = 120;
}
{
width = 1920;
height = 1080;
refresh = 60;
}
{
width = 3840;
height = 2160;
refresh = 120;
}
{
width = 3840;
height = 2160;
refresh = 60;
}
];
audio = false;
hdr = true;
deepColor = true;
dsc = false;
vrr = false;
listedModesOnly = false;
};
}
''
mkdir -p "$out/lib/firmware/edid"
edid-generator $settings > "$out/lib/firmware/edid/VTCL65C825.bin"
''
)
];

# The port (DP-2) to be used must be free on the GPU, use
# `ls /sys/class/drm/*/status` to find free ports.
#
# Using DP-2 because HDMI doesn't support 3840x2160@120.
outputs."DP-2" = {
edid = "VTCL65C825.bin";
mode = "e";
};
};

services.sunshine = {
enable = true;
package = pkgs.sunshine.override { cudaSupport = true; };

openFirewall = true;
settings = {
sunshine_name = config.networking.hostName;
system_tray = false;
encoder = "nvenc";

# TODO(tlater): Switch to portalgrab once released:
# https://github.com/LizardByte/Sunshine/pull/4417
capture = "wlr";
output_name = 1;
};

applications.apps = [
(
let
setsid = lib.getExe' pkgs.util-linux "setsid";
steam = lib.getExe config.programs.steam.package;
swaymsg = lib.getExe' pkgs.sway "swaymsg";

run-steam = pkgs.writers.writeNu "run-steam" /* nu */ ''
try {
${steam} steam://open/bigpicture
} catch {
print 'Steam failed to run'
sleep 30sec
}
'';
in
{
name = "Steam Big Picture";
cmd = "${pkgs.alacritty}/bin/alacritty --command ${run-steam}";
auto-detach = false;
prep-cmd = [
{
do = "${swaymsg} output DP-2 enable";
undo = "${setsid} ${steam} steam://close/bigpicture";
}
];
}
)
];
};

}
18 changes: 18 additions & 0 deletions pkgs/packages/custom-edid.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
runCommand,
xorg,
edid-generator,
}:
edid-generator.overrideAttrs (old: {
# passAsFile = [ ];
clean = true;

# modelines = ''Modeline "3840x2160" 712.34 3840 4152 4576 5312 2160 2161 2164 2235 -HSync +Vsync'';

modelinesPath =
(runCommand "modelines" { nativeBuildInputs = [ xorg.xorgserver ]; } ''
gtf 3840 2160 120 > modeline
sed -i 's/"3840x2160_120.00"/"VTCL65C825"/' modeline
grep -v '# ' modeline > $out
'').outPath;
})
45 changes: 45 additions & 0 deletions pkgs/packages/edid-generator.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
fetchFromGitHub,
runCommand,
writers,
}:
let
edid-core =
runCommand "edid-core"
{
src = fetchFromGitHub {
owner = "goncalossilva";
repo = "edid-generator";
rev = "bc311cb7d5d4900a1bdad8fa967125c8e50c0174";
hash = "sha256-90yzP0wxVms/6+sLa8zOkZbuBkqnBMQS0WyEn2poWUM=";
};
}
/* sh */ ''
mkdir -p "$out/lib/node_modules/edid-core/"
cp "$src/assets/js/edid-core.js" "$out/lib/node_modules/edid-core/index.js"
'';
in
writers.writeJSBin "edid-generator" { libraries = [ edid-core ]; } /* js */ ''
const { readFile } = require("node:fs/promises");
const { resolve } = require("node:path");
const { stdout, stderr } = require("node:process");

const { generateEdid } = require("edid-core");

async function main() {
const settings = JSON.parse(await readFile(resolve(process.argv[2])));
const edid = generateEdid(settings);

if (edid.warnings) {
console.warn("EDID wasn't generated cleanly:");

for (warning of edid.warnings) {
console.warn("- " + warning);
}
}

stdout.write(edid.bytes);
}

main();
''
Loading