# Manjaro Gaming Server

## Setup

Tested on Truenas with libvirt.

1. Do not boot the instance with a virtual display
2. Pass through usb mouse/keyboard
3. Pass through the graphics card
4. Walk through the installer as normal
5. Reboot into the installation
6. Settings -> Screen Locking -> Never
7. Settings -> Power Management -> When power button pressed: Shut Down
8. Settings -> Power Management -> Turn off screen: Never
9. Settings -> Session -> Desktop Session -> On login, launch apps that were open: Start with an empty session
10. `sudo systemctl enable --now sshd`

## SSH

Make sure you forward 127.0.0.1:47990. That way you can access sunshine on your local machine
at <https://127.0.0.1:47990> for entering the pin.

```conf
Host gamebox2
    HostName gamebox2.reeselink.com
    User gamer
    KeepAlive yes
    IdentityFile ~/.ssh/id_gamebox_rsa
    LocalForward 47990 127.0.0.1:47990
```

## Basic Apps

```bash
sudo pacman -S vim
sudo flatpak install io.missioncenter.MissionCenter
```

## Install Sunshine

```bash
# Update the system
sudo pacman -Syu

# Install nvidia drivers
sudo mhwd -i pci video-nvidia

# Install sunshine
#The flatpak seems to work well. The arch package keeps breaking due to
#deps. See boost-libs and then libicuuc.so.76.
#<https://docs.lizardbyte.dev/projects/sunshine/latest/md_docs_2getting__started.html#install-system-level>
sudo flatpak install --system flathub dev.lizardbyte.app.Sunshine
flatpak run --command=additional-install.sh dev.lizardbyte.app.Sunshine
systemctl --user enable --now sunshine
sudo reboot
```

If you need to uninstall

```bash
systemctl --user disable --now sunshine
sudo flatpak uninstall --system --delete-data dev.lizardbyte.app.Sunshine
```

## Steam

Play games.

```bash
sudo flatpak install com.valvesoftware.Steam
```

## MangoHud

<https://github.com/flightlessmango/MangoHud?tab=readme-ov-file#flatpak>

Pretty Numbers for your Games.

```bash
sudo flatpak install org.freedesktop.Platform.VulkanLayer.MangoHud
flatpak override --user --env=MANGOHUD=1 com.valvesoftware.Steam

# Allow flatpak apps to read Mangohud config
flatpak override --user --filesystem=xdg-config/MangoHud:ro
```

Edit `~/.config/MangoHud/MangoHud.conf`

```conf
## pre defined presets
# -1 = default
#  0 = no display
#  1 = fps only
#  2 = horizontal view
#  3 = extended
#  4 = high detailed information
preset=2

## Enable most of the toggleable parameters (currently excludes `histogram`)
# full
```

## Snapshot

I would recommend creating a "working install" snapshot you can roll back to.

```bash
# Take a snapshot
zfs list -d 1 enc1/vms
export ZFS_VOL='enc1/vms/Gambox1-z4e0t'
zfs snapshot $ZFS_VOL@manual-$(date --iso-8601)

# Restore a snapshot
zfs list -t snapshot $ZFS_VOL
export ZFS_SNAPSHOT='enc1/vms/Gambox1-z4e0t@init-no-drivers-2025-03-03_05-35'
zfs rollback $ZFS_SNAPSHOT
```
