Skip to content

Instantly share code, notes, and snippets.

@zot
Last active December 20, 2022 13:01
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zot/6e34c0bc739a1679e4b352acf7192761 to your computer and use it in GitHub Desktop.
Save zot/6e34c0bc739a1679e4b352acf7192761 to your computer and use it in GitHub Desktop.
shell script to prepare steamdeck for development
#!/bin/sh
# use this to prep remote development
#
# ensures sshd is active and multiuser nix is installed
#
# the most common activity here is mounting the local vault
# other activities happen only on installation or after upgrades
#
# activate ssh if it's not activated
if ! systemctl is-active sshd > /dev/null 2>&1; then
echo Activating sshd...
sudo systemctl activate sshd
sudo systemctl start sshd
fi
# prep nix if it's not there
if ! [ -d /nix ]; then
echo Installing Nix...
sudo steamos-readonly disable
sudo mkdir /nix
sudo steamos-readonly enable
if ! [ -d /home/nix ]; then
mkdir /home/nix
fi
if ! grep -q /nix /etc/fstab; then
sudo sh -c 'echo "/home/nix /nix none defaults,bind 0 2" >> /etc/fstab'
fi
sudo mount /nix
sh <(curl -L https://nixos.org/nix/install) --daemon
fi
# check separately for /etc/systemd/system/nix-daemon.* because upgrades might delete it
if ! [ -f /etc/systemd/system/nix-daemon.service ] || [ "$(realpath /etc/systemd/system/nix-daemon.service)" = /nix/var/nix/profiles/default/lib/systemd/system/nix-daemon.service ]; then
# copy systemd files so they are present at systemd startup
echo Copying systemd files...
sudo rm -f /etc/systemd/system/nix-daemon.service /etc/systemd/system/nix-daemon.socket
sudo cp /home/nix/var/nix/profiles/default/lib/systemd/system/nix-daemon.service /etc/systemd/system
sudo cp /home/nix/var/nix/profiles/default/lib/systemd/system/nix-daemon.socket /etc/systemd/system
sudo systemctl enable nix-daemon
sudo systemctl start nix-daemon
fi
# mount local vault if it's not mounted
! [ -d ~/Vaults/local ] && umount ~/Vaults/local
if ! mount | grep -q /home/deck/Vaults/local; then
echo Mounting vault...
gocryptfs /home/deck/.local/share/plasma-vault/local.enc /home/deck/Vaults/local
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment