-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdesktop.nix
More file actions
194 lines (163 loc) · 5.04 KB
/
desktop.nix
File metadata and controls
194 lines (163 loc) · 5.04 KB
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
let
desktop = "niri"; # one of: "sway", "niri"
in
{
hostname,
config,
lib,
localpkgs,
pkgs,
...
}:
let
# bash script to let dbus know about important env variables and
# propagate them to relevent services run at the end of sway config
# see
# https://github.com/emersion/xdg-desktop-portal-wlr/wiki/"It-doesn't-work"-Troubleshooting-Checklist
# note: this is pretty much the same as /etc/sway/config.d/nixos.conf but also restarts
# some user services to make sure they have the correct environment variables
dbus-sway-environment = pkgs.writeTextFile {
name = "dbus-sway-environment";
destination = "/bin/dbus-sway-environment";
executable = true;
text = ''
dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway
systemctl --user restart pipewire wireplumber xdg-desktop-portal xdg-desktop-portal-wlr
'';
};
webcamlog = pkgs.writeScriptBin "webcam-log" ''
log_to="$HOME/Pictures/webcamlog/$HOSTNAME"
mkdir -p "$log_to"
out_file="$log_to/$(date "+%Y_%m_%d_%H:%M:%S").jpg"
${pkgs.fswebcam}/bin/fswebcam -r 640x480 --jpeg 85 -D 1 --no-banner "$out_file"
'';
# currently, there is some friction between sway and gtk:
# https://github.com/swaywm/sway/wiki/GTK-3-settings-on-Wayland
# the suggested way to set gtk settings is with gsettings
# for gsettings to work, we need to tell it where the schemas are
# using the XDG_DATA_DIR environment variable
# run at the end of sway config
configure-gtk = pkgs.writeTextFile {
name = "configure-gtk";
destination = "/bin/configure-gtk";
executable = true;
text =
let
schema = pkgs.gsettings-desktop-schemas;
datadir = "${schema}/share/gsettings-schemas/${schema.name}";
in
''
export XDG_DATA_DIRS=${datadir}:$XDG_DATA_DIRS
gnome_schema=org.gnome.desktop.interface
gsettings set $gnome_schema gtk-theme 'Dracula'
'';
};
in
{
options.isDesktop = lib.mkOption {
type = lib.types.bool;
default = false;
};
config = lib.mkIf config.isDesktop {
# chromecast
networking.firewall = {
allowedUDPPorts = [ 5353 ]; # For device discovery
allowedUDPPortRanges = [
{
from = 32768;
to = 61000;
}
]; # For Streaming
allowedTCPPorts = [ 8010 ]; # For gnomecast server
};
services.playerctld.enable = true;
services.usbmuxd.enable = true;
powerManagement.powertop.enable = true;
services.automatic-timezoned.enable = true;
services.speechd.enable = false;
programs.wireshark.enable = true;
programs.wireshark.package = pkgs.wireshark;
# automount attached storage
services.gvfs.enable = true;
services.udisks2.enable = true;
services.devmon.enable = true;
hardware.saleae-logic.enable = true;
services.tzupdate.enable = true;
systemd.timers."webcam-log" = lib.mkIf (hostname != "itoh") {
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "1m";
OnUnitActiveSec = "1m";
Unit = "webcam-log.service";
};
};
systemd.services."webcam-log" = {
script = "${webcamlog}/bin/webcam-log";
serviceConfig = {
Type = "oneshot";
User = "turbio";
};
};
services.journald.extraConfig = ''
MaxRetentionSec=1week
'';
environment.systemPackages = (pkgs.callPackage ./packages.nix { inherit localpkgs; }).desktop ++ [
(lib.mkIf (desktop == "sway") dbus-sway-environment)
(lib.mkIf (desktop == "sway") configure-gtk)
];
environment.sessionVariables = {
GDK_BACKEND = "wayland";
};
programs.steam.enable = true;
programs.dconf.enable = true;
services.pulseaudio.enable = false;
hardware.graphics.enable = true;
networking.networkmanager.enable = true;
services.pcscd.enable = true;
fonts.packages = with pkgs; [
terminus_font
terminus_font_ttf
nerd-fonts.terminess-ttf
noto-fonts
noto-fonts-color-emoji
roboto
];
programs.adb.enable = true;
users.users.turbio.extraGroups = [ "adbusers" ];
#programs.niri.enable = desktop == "niri";
programs.sway = lib.mkIf (desktop == "sway") {
enable = true;
wrapperFeatures.gtk = true;
};
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
};
security.polkit.enable = true;
services.dbus.enable = true;
xdg.portal = {
enable = true;
wlr.enable = true;
xdgOpenUsePortal = true;
extraPortals = with pkgs; [
xdg-desktop-portal-gtk
xdg-desktop-portal-gnome
];
config = {
niri = {
default = [
"gnome"
"gtk"
];
"org.freedesktop.impl.portal.Access" = [ "gtk" ];
"org.freedesktop.impl.portal.Notification" = [ "gtk" ];
"org.freedesktop.impl.portal.Secret" = [ "gnome-keyring" ];
};
};
};
};
}