blob: 95e6b9f2e522e1c4679c3cf4d4cb06d8e2297dbd (
plain)
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
|
{ pkgs, ... }: {
imports = [
./hardware-configuration.nix
];
services.xserver.videoDrivers = [ "nvidia" ];
hardware.nvidia = {
modesetting.enable = true;
powerManagement.enable = false;
powerManagement.finegrained = false;
open = false;
nvidiaSettings = true;
};
hardware.graphics = {
enable = true;
enable32Bit = true;
};
networking.interfaces.enp4s0.wakeOnLan.enable = true;
services.sunshine = {
enable = true;
openFirewall = true;
settings = {
sunshine_name = "phosphophyllite";
output_name = "DP-2";
capture = "wlr";
origin_web_ui_allowed = "lan";
global_prep_cmd = ''[{"do":"${pkgs.sudo}/bin/sudo ${pkgs.systemd}/bin/systemctl stop sunshine-poweroff.timer","undo":"${pkgs.sudo}/bin/sudo ${pkgs.systemd}/bin/systemctl start sunshine-poweroff.timer"}]'';
};
};
security.sudo.extraRules = [
{
users = [ "phos" ];
commands = [
{
command = "${pkgs.systemd}/bin/systemctl start sunshine-poweroff.timer";
options = [ "NOPASSWD" ];
}
{
command = "${pkgs.systemd}/bin/systemctl stop sunshine-poweroff.timer";
options = [ "NOPASSWD" ];
}
];
}
];
systemd.timers.sunshine-poweroff = {
description = "Shutdown desktop 15 minutes after Sunshine disconnect";
timerConfig = {
OnActiveSec = "15m";
AccuracySec = "30s";
Unit = "sunshine-poweroff.service";
};
};
systemd.services.sunshine-poweroff = {
description = "Power off if machine stays idle after Sunshine disconnect";
serviceConfig.Type = "oneshot";
script = ''
set -euo pipefail
sessions="$(${pkgs.systemd}/bin/loginctl list-sessions --no-legend || true)"
if [ -n "$sessions" ]; then
while read -r session _; do
[ -z "$session" ] && continue
seat="$(${pkgs.systemd}/bin/loginctl show-session "$session" -p Seat --value)"
[ -z "$seat" ] && continue
active="$(${pkgs.systemd}/bin/loginctl show-session "$session" -p Active --value)"
idle="$(${pkgs.systemd}/bin/loginctl show-session "$session" -p IdleHint --value)"
if [ "$active" = "yes" ] && [ "$idle" = "no" ]; then
exit 0
fi
done <<EOF
$sessions
EOF
fi
exec ${pkgs.systemd}/bin/systemctl poweroff
'';
};
services.pipewire.wireplumber.extraConfig."10-rename-devices" = {
"monitor.alsa.rules" = [
{
matches = [
{
"node.name" = "alsa_output.pci-0000_0a_00.4.analog-stereo";
}
];
actions = {
update-props = {
"node.description" = "Speakers";
};
};
}
{
matches = [
{
"node.name" = "alsa_output.pci-0000_08_00.1.hdmi-stereo";
}
];
actions = {
update-props = {
"device.disabled" = true;
};
};
}
{
matches = [
{
"node.name" = "alsa_output.usb-HP__Inc_HyperX_Cloud_II_Core_Wireless-00";
}
];
actions = {
update-props = {
"node.description" = "HyperX Cloud II";
};
};
}
];
};
}
|