blob: e6ddd86e592054ba273daa320a9a2c948c88ba0f (
plain) (
blame)
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
|
#!/bin/sh
: ${desktop_access_gid:='40000'}
: ${sddm_min_uid:='10000'}
: ${sddm_max_uid:='19999'}
: ${cups_host:='cups'}
: ${ublock_whitelist:=''}
: ${chrome_flags:=''}
sddm_user=sddm
cups_conf_dir=/usr/local/etc/cups
if [ "${enable_idm:-}" = false ]; then
desktop_access_role=operator
else
ldap_add "cn=${desktop_access_role},${roles_basedn}" <<EOF
objectClass: groupOfMembers
objectClass: posixGroup
cn: ${desktop_access_role}
gidNumber: ${desktop_access_gid}
EOF
fi
# Load linux kernel modules.
sysrc -v linux_enable=YES
# Enable FUSE.
sysrc -v kld_list+=fusefs
# Install packages common to all DEs.
pkg install -y $desktop_common_packages
# Install profile script for improving experience on NFS homedirs.
install_file -m 0555 /etc/profile.d/local-homedir.sh
# Create ZFS dataset for local homedirs.
create_dataset -o mountpoint=/usr/local/home "${state_dataset}/home"
zfs set \
com.sun:auto-snapshot:hourly=true \
com.sun:auto-snapshot:daily=true \
com.sun:auto-snapshot:weekly=true \
"${state_dataset}/home"
# Enable sndio.
sysrc -v sndiod_enable=YES
service sndiod status || service sndiod start
# Create local group for desktop-access.
# This is for *local* users that need access to the drm device.
add_group -g "$desktop_access_gid" "$desktop_access_role"
# Create desktop devfs ruleset.
install_template -m 0644 /etc/devfs.rules
sysrc -v "devfs_system_ruleset=${devfs_local_ruleset_name}"
service devfs restart
# Enable webcamd.
sysrc -v webcamd_enable=YES
service webcamd status || service webcamd start
# Create xdg autostart entry to add our Root CA to Chrome's certificate store.
install_file -m 0644 /usr/local/etc/xdg/autostart/nss-trust-root-ca.desktop
install_file -m 0555 /usr/local/libexec/nss-trust-root-ca
# Install gajim desktop file.
install_file -m 0644 /usr/local/share/applications/gajim.desktop
case $desktop_type in
i3)
pkg install -y $desktop_i3_packages
;;
kde)
# Install KDE packages.
pkg install -y $desktop_kde_packages
# Add sddm user to drm access group.
pw groupmod "$desktop_access_role" -m "$sddm_user"
# Configure pam services.
install_file -m 0644 \
/etc/pam.d/sddm \
/etc/pam.d/kde
# Copy SDDM config file.
install_template -m 0644 /usr/local/etc/sddm.conf
# Create profile script for KDE environment variables.
install_file -m 0644 /etc/profile.d/kde.sh
# Create SDDM local homedir.
install_directory -o sddm -g sddm -m 0700 /usr/local/home/sddm
# Create shutdown script to cleanup lingering processes.
install_directory -m 0755 \
/usr/local/etc/xdg/plasma-workspace \
/usr/local/etc/xdg/plasma-workspace/shutdown
install_file -m 0555 /usr/local/etc/xdg/plasma-workspace/shutdown/cleanup.sh
# Disable baloo file search.
# Don't know anyone that uses it, and litters $HOME with .nfs files whenever
# any file is deleted.
install_file -m 0644 /usr/local/etc/xdg/baloofilerc
# Disable user switching
# Broken with consolekit: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=221452
# VT switch causes loss of graphics acceleration: https://github.com/freebsd/drm-kmod/issues/175
install_file -m 0644 /usr/local/etc/xdg/kdeglobals
# Enable sddm.
sysrc -v sddm_enable=YES
;;
esac
# Tune sysctls for desktop usage.
set_sysctl \
net.local.stream.recvspace=65536 \
net.local.stream.sendspace=65536 \
kern.sched.preempt_thresh=224 \
vfs.usermount=1
set_loader_conf \
kern.ipc.shmseg=1024 \
kern.ipc.shmmni=1024 \
kern.maxproc=100000 \
hw.pci.do_power_nodriver=3
# Create policy file for firefox.
install_directory -m 0755 /usr/local/lib/firefox/distribution
install_template -m 0644 /usr/local/lib/firefox/distribution/policies.json
# Create policy file for thunderbird.
install_directory -m 0755 /usr/local/lib/thunderbird/distribution
install_template -m 0644 /usr/local/lib/thunderbird/distribution/policies.json
# Create policy file for chromium.
install_directory -m 0755 \
/usr/local/etc/chromium/policies \
/usr/local/etc/chromium/policies/managed
install_template -m 0644 /usr/local/etc/chromium/policies/managed/policies.json
# Configure libreoffice
install_file -m 0644 /usr/local/lib/libreoffice/program/sofficerc
# Add terminus font to X11
install_file -m 0644 /usr/local/etc/X11/xorg.conf.d/terminus.conf
# Create xdg override directory.
install_directory -m 0755 \
"${xdg_override_dir}" \
"${xdg_override_dir}/applications"
# Create xdg application overrides.
install_template -m 0644 \
"${xdg_override_dir}/applications/signal-desktop.desktop" \
"${xdg_override_dir}/applications/chromium-browser.desktop"
# Create polkit rules for shutdown/reboot/suspend
install_template -m 0644 /usr/local/etc/polkit-1/rules.d/51-desktop.rules
# Enable dbus.
sysrc -v dbus_enable=YES
service dbus status || service dbus start
# Configure CUPS.
pkg install -y cups
install_template -m 0644 "${cups_conf_dir}/client.conf"
# Configure graphics drivers.
case $graphics_type in
intel)
pkg install -y drm-kmod libva-intel-media-driver
sysrc -v kld_list+=i915kms
load_kernel_module i915kms
set_loader_conf \
compat.linuxkpi.i915_enable_fbc=1 \
compat.linuxkpi.i915_fastboot=1
: ${mpv_hwdec:='vaapi-copy'}
;;
esac
# On some graphics cards, kern.vt.suspendswitch=1 (the default) breaks graphics
# acceleration after resuming from sleep.
set_sysctl kern.vt.suspendswitch="${vt_suspendswitch:-1}"
# Generate mpv configuration.
install_template -m 0644 /usr/local/etc/mpv/mpv.conf
# Start login manager.
case $desktop_type in
kde)
# We have to redirect the output here because sddm holds FDs open :(
service sddm status || service sddm start > /dev/null 2>&1 < /dev/null || die 'failed to start sddm'
;;
esac
|