Skip to content

Commit 991c12b

Browse files
committed
feat: add sunshine
wait until LizardByte/Sunshine#2885 for output_name
1 parent ff6d684 commit 991c12b

File tree

3 files changed

+114
-39
lines changed

3 files changed

+114
-39
lines changed

Diff for: modules/profiles/sway.nix

+103-37
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,39 @@
11
s@{ config, pkgs, lib, self, ... }:
2+
let
3+
modifier = "Mod4";
4+
systemctl = lib.getExe' config.systemd.package "systemctl";
5+
swaymsg = lib.getExe' config.myhomecfg.wayland.windowManager.sway.package "swaymsg";
6+
status = lib.getExe config.myhomecfg.programs.i3status-rust.package;
7+
swayr = lib.getExe config.myhomecfg.programs.swayr.package;
8+
pavucontrol = lib.getExe pkgs.pavucontrol;
9+
grim = lib.getExe pkgs.grim;
10+
slurp = lib.getExe pkgs.slurp;
11+
status-config = "${config.myhomecfg.xdg.configHome}/i3status-rust/config-default.toml";
12+
wallpaper = self + "/resources/wallpapers/wr.jpg";
13+
wpctl = lib.getExe' pkgs.wireplumber "wpctl";
14+
bento = lib.getExe' self.packages.${pkgs.system}.bbscripts "bento";
15+
curl = lib.getExe pkgs.curl;
16+
jq = lib.getExe pkgs.jq;
17+
swaylock = lib.getExe config.myhomecfg.programs.swaylock.package;
18+
loginctl = lib.getExe' pkgs.systemd "loginctl";
19+
wl-copy = lib.getExe' pkgs.wl-clipboard "wl-copy";
20+
fcitx5 = lib.getExe config.i18n.inputMethod.package;
21+
blueman-applet = lib.getExe' pkgs.blueman "blueman-applet";
22+
23+
monitor = {
24+
main = "Dell Inc. DELL U2718QM MYPFK89J15HL";
25+
internal = "California Institute of Technology 0x1303 Unknown";
26+
headless = "HEADLESS-1";
27+
};
28+
29+
queryCoin = symbol: {
30+
block = "custom";
31+
command = "${curl} --silent https://api.coinbase.com/v2/prices/${symbol}-USD/spot | ${jq} -r .data.amount";
32+
hide_when_empty = true;
33+
interval = 300;
34+
format = " ${symbol} $text ";
35+
};
36+
in
237
lib.mkProfile s "sway"
338
{
439
myos.desktop.enable = true;
@@ -35,40 +70,57 @@ lib.mkProfile s "sway"
3570
};
3671
};
3772

38-
myhome = { config, lib, osConfig, ... }:
39-
let
40-
modifier = config.wayland.windowManager.sway.config.modifier;
41-
status = lib.getExe config.programs.i3status-rust.package;
42-
swayr = lib.getExe config.programs.swayr.package;
43-
pavucontrol = lib.getExe pkgs.pavucontrol;
44-
grim = lib.getExe pkgs.grim;
45-
slurp = lib.getExe pkgs.slurp;
46-
status-config = "${config.xdg.configHome}/i3status-rust/config-default.toml";
47-
wallpaper = self + "/resources/wallpapers/wr.jpg";
48-
wpctl = lib.getExe' pkgs.wireplumber "wpctl";
49-
bento = lib.getExe' self.packages.${pkgs.system}.bbscripts "bento";
50-
curl = lib.getExe pkgs.curl;
51-
jq = lib.getExe pkgs.jq;
52-
swaylock = lib.getExe config.programs.swaylock.package;
53-
loginctl = lib.getExe' pkgs.systemd "loginctl";
54-
wl-copy = lib.getExe' pkgs.wl-clipboard "wl-copy";
55-
fcitx5 = lib.getExe' osConfig.i18n.inputMethod.package "fcitx5";
56-
blueman-applet = lib.getExe' pkgs.blueman "blueman-applet";
57-
58-
monitor = {
59-
main = "Dell Inc. DELL U2718QM MYPFK89J15HL";
60-
side = "ICD Inc GX259F Unknown";
61-
internal = "California Institute of Technology 0x1303 Unknown";
62-
};
73+
sops.secrets.sunshine-pass = {
74+
sopsFile = self + "/secrets/secrets.yaml";
75+
};
6376

64-
queryCoin = symbol: {
65-
block = "custom";
66-
command = "${curl} --silent https://api.coinbase.com/v2/prices/${symbol}-USD/spot | ${jq} -r .data.amount";
67-
hide_when_empty = true;
68-
interval = 300;
69-
format = " ${symbol} $text ";
70-
};
71-
in
77+
sops.secrets.sunshine-salt = {
78+
sopsFile = self + "/secrets/secrets.yaml";
79+
};
80+
81+
sops.templates.sunshine-cred = {
82+
content = builtins.toJSON {
83+
username = config.myos.user.mainUser;
84+
password = config.sops.placeholder.sunshine-pass;
85+
salt = config.sops.placeholder.sunshine-salt;
86+
};
87+
owner = config.myos.user.mainUser;
88+
};
89+
90+
services.sunshine = {
91+
enable = true;
92+
# package = (lib.addPatches pkgs.sunshine [
93+
# (pkgs.fetchpatch {
94+
# url = "https://github.com/LizardByte/Sunshine/pull/2885.patch";
95+
# hash = "sha256-bMFmnHGosFOfStbeTBHxdfkYHDZFoWytMuZ9+O6W0LQ=";
96+
# })
97+
# ]);
98+
autoStart = false;
99+
capSysAdmin = true;
100+
openFirewall = true;
101+
settings = {
102+
# TODO wait https://github.com/LizardByte/Sunshine/pull/2885
103+
# output_name = monitor.headless;
104+
output_name = 2;
105+
credentials_file = config.sops.templates.sunshine-cred.path;
106+
};
107+
applications = {
108+
apps = [
109+
{
110+
name = "tablet monitor";
111+
auto-detach = "true";
112+
prep-cmd = [
113+
{
114+
do = "${swaymsg} output HEADLESS-1 enable";
115+
undo = "${swaymsg} output HEADLESS-1 disable";
116+
}
117+
];
118+
}
119+
];
120+
};
121+
};
122+
123+
myhome = { config, lib, osConfig, ... }:
72124
{
73125
home.pointerCursor = {
74126
package = pkgs.adwaita-icon-theme;
@@ -205,17 +257,19 @@ lib.mkProfile s "sway"
205257
};
206258

207259
config = {
260+
inherit modifier;
261+
208262
workspaceAutoBackAndForth = true;
209263

210-
modifier = "Mod4";
211264

212265
terminal = lib.getExe config.programs.alacritty.package;
213266

214267
startup = [
215268
{ command = "emacs"; }
269+
{ command = "\"${swaymsg} create_output; ${swaymsg} output ${monitor.headless} disable\""; }
216270
] ++ (lib.optional config.services.kanshi.enable
217271
# workaround for https://github.com/emersion/kanshi/issues/43
218-
{ command = "systemctl --user restart kanshi.service"; always = true; }
272+
{ command = "${systemctl} --user restart kanshi.service"; always = true; }
219273
) ++ (lib.optional osConfig.services.blueman.enable
220274
{ command = "${blueman-applet}"; always = true; }
221275
) ++ (lib.optional osConfig.i18n.inputMethod.enable
@@ -265,6 +319,10 @@ lib.mkProfile s "sway"
265319
resolution = "2160x1350";
266320
scale = "1.5";
267321
};
322+
"${monitor.headless}" = {
323+
resolution = "2800x1752@60Hz";
324+
scale = "2.0";
325+
};
268326
};
269327

270328
workspaceOutputAssign = [
@@ -276,7 +334,7 @@ lib.mkProfile s "sway"
276334
{ workspace = "6"; output = monitor.internal; }
277335
{ workspace = "7"; output = monitor.internal; }
278336
{ workspace = "8"; output = monitor.internal; }
279-
{ workspace = "9"; output = monitor.internal; }
337+
{ workspace = "9"; output = monitor.headless; }
280338
];
281339

282340
input = {
@@ -339,7 +397,7 @@ lib.mkProfile s "sway"
339397
timeouts = [
340398
{
341399
timeout = 3600;
342-
command = "systemctl suspend";
400+
command = "${systemctl} suspend";
343401
}
344402
];
345403
events = [
@@ -366,6 +424,10 @@ lib.mkProfile s "sway"
366424
position = "0,0";
367425
scale = 1.5;
368426
}
427+
{
428+
criteria = "${monitor.headless}";
429+
status = "disable";
430+
}
369431
];
370432
}
371433
{
@@ -381,6 +443,10 @@ lib.mkProfile s "sway"
381443
position = "1920,0";
382444
scale = 1.5;
383445
}
446+
{
447+
criteria = "${monitor.headless}";
448+
status = "disable";
449+
}
384450
];
385451
}
386452
];

Diff for: modules/profiles/user.nix

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ in
1212
default = { };
1313
};
1414

15+
options.myhomecfg = lib.mkOption {
16+
type = with lib.types; attrsOf anything;
17+
default = { };
18+
};
19+
1520
options.myos.user = {
1621
mainUser = mkOption {
1722
type = types.str;
@@ -46,6 +51,8 @@ in
4651

4752
home-manager.users."${cfg.mainUser}" = lib.mkAliasDefinitions options.myhome;
4853

54+
myhomecfg = config.home-manager.users."${cfg.mainUser}";
55+
4956
myhome = {
5057
home.stateVersion = state-version;
5158
systemd.user.startServices = "sd-switch";

Diff for: secrets/secrets.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ github-pat: ENC[AES256_GCM,data:reRhhYADhVIqOwHtRve/G85sGiu0IvYFimxzfvBEFQQajP4V
2828
atuin-key: ENC[AES256_GCM,data:TKuFfQxlfriiCeVYn/f/jeUTuPhFxQ4tbEhgDWvu/LTRLQbA6H+dZN1P1gXm7SRkQ0bjg26A69FBSJtaKjfbWN8GX0xmZcag,iv:PXqfx2Hj0axFK8B+IeD887cldeMcRCUoS9Bm54XWum8=,tag:lsZWRzHphi6GA43TJGkfow==,type:str]
2929
atuin-session: ENC[AES256_GCM,data:0mLZFenCeLJSPa5ZCjjwbtQwhcpD8zcayATNHuL3guw=,iv:YUUCs9gCz8KuPdFWAyAl6gdbQVbftpLkSWyj7gMlcBk=,tag:G7z1gsG9rvoxLdSROGM2aw==,type:str]
3030
github-ai-pat: ENC[AES256_GCM,data:7NnIq6acA1fB4BB3e4MZj/FUu7SunEFRMn8KMRXhzBEEZ4RcIhcvlQ==,iv:XBffDj2vzLaklWzNm3okMXqIroaSd9F0stFNT70omEg=,tag:bFL0AYiRsnRTQ3Es3r3FOQ==,type:str]
31+
sunshine-pass: ENC[AES256_GCM,data:uwKV3OazIR4TAsCQqYa0yMzgVvFJDoIBwXCfRnxOdazVYnPNNhpyyZpngCK73e9jiak/So1KtNeiBm55O852EQ==,iv:1UAUQM/PEy/kwpD3i6/NMGHvgAUSOh/nKt2jmzUbju8=,tag:RjLYNGm3rvrlUTeuyZyW7A==,type:str]
32+
sunshine-salt: ENC[AES256_GCM,data:FOJoLUYP6KksGbaIfgFfJQ==,iv:hXbDrR4it+EumLxZJXf3p/zHV69d+pzDqFUXEOZ9QK4=,tag:8/1P15y4gfv1x+QXSfTL5g==,type:str]
3133
sops:
3234
kms: []
3335
gcp_kms: []
@@ -79,8 +81,8 @@ sops:
7981
WXVrSkdkbEJ2WlR3ZEpjSHJmcWNIWkUK7z6Vpqufg9qO0sG3djOq4zEL3MkxJ96a
8082
K1/t08qZt2OfqykutJ00lo0rQe7U16qw8BNPJEQjEnHwwdRsPtm71A==
8183
-----END AGE ENCRYPTED FILE-----
82-
lastmodified: "2025-02-11T18:30:43Z"
83-
mac: ENC[AES256_GCM,data:K/rvCxIFOkudnnAGYq7qfvwBbf8M5RnHKvVLItGexXiM7sAJx5YyXHSfNro3hofCdfxfQ/kAx+hPDixb9vKFbIJA7+zCR5DqvrRY6UOor/vE3Thn8PLaQHFKk/p8WozoYL2jGnMvC/dLXkotTPNaJnif2S5EULU1veafiw9eoZE=,iv:LJprW4YTtyUuDDVHm7RdKnNA351MoUYUxasUIXCOj8k=,tag:G8Q8xbJA0Zdu+uSld1GnKQ==,type:str]
84+
lastmodified: "2025-02-22T19:38:27Z"
85+
mac: ENC[AES256_GCM,data:K2Qi/6a3OOXvl7bEk3PKanSB0BiF7KCs4DgLcuekHLfYUZxmCu3hHInupCZgU8it28F47z7ajYoJqgX5qEVv28L2josu8S4fKRDCPfkdEpEFlO93Mz3/38es9oXQsTsFdJlFsAuVks7I7UcvE8GngWCa/sm07fqvOWoBVAtUNOw=,iv:xIujHkXArGkTeYvg5+Cffk2Si4XTwYmHpd84qCRzsHc=,tag:cU4Sevo9Eykl8en7sNa7ZA==,type:str]
8486
pgp:
8587
- created_at: "2024-10-31T18:23:15Z"
8688
enc: |-

0 commit comments

Comments
 (0)