DeterminateSystems / nix-installer

Install Nix and flakes with the fast and reliable Determinate Nix Installer, with over 7 million installs.
https://determinate.systems
GNU Lesser General Public License v2.1
2.14k stars 53 forks source link

Steam Deck: Installing nix on an sd card #509

Open dpatterbee opened 1 year ago

dpatterbee commented 1 year ago

Due to the base model Steam Deck only having 64GB storage, I thought it would be a good idea to install nix to an SD card. I installed with nix-installer install steam-deck --persistence /run/media/mmcblk0p1/nix and this worked fine, right up until I rebooted. After a reboot, the nix.mount service claims to work, but /nix points to nowhere. This leads to ensure-symlinked-units-resolve.service failing with nix-daemon.service not existing etc.

I assume the issue is that the nix services run before the sd card has mounted or something and we need to wait, but I can't figure out the correct incantations to make this happen. I tried adding RequiresMountsFor=/run/media/mmcblk0p1 to nix.mount but this didn't help. Tbh it even looks like nix.mount waits for the sd card mount but still it doesn't seem to work.

(deck@steamdeck ~)$ systemd-analyze critical-chain nix.mount
The time when unit became active or started is printed after the "@" character.
The time the unit took to start is printed after the "+" character.

nix.mount +19ms
└─run-media-mmcblk0p1.mount @2.415s
  └─dev-mmcblk0p1.device @584542y 2w 2d 20h 1min 49.185s +2.782s

I would imagine that this would be quite useful for a lot of steam deck users so help would be appreciated.

Hoverbear commented 1 year ago

This would indeed be a useful feature! I would note in upcoming versions of SteamOS there is a vendor-provisioned nix offload in /home/.steamos/offload so the --persistence flag is actually planned to be deprecated.

I am now wondering if there is some way to still support --persistence even so...

Nephyrin commented 1 year ago

This would indeed be a useful feature! I would note in upcoming versions of SteamOS there is a vendor-provisioned nix offload in /home/.steamos/offload so the --persistence flag is actually planned to be deprecated.

I am now wondering if there is some way to still support --persistence even so...

The upsteam /nix setup also provides a nix.mount to perform the bind-mounting of /nix, while the rootfs itself contains the empty directory. It should remain possible to mask nix.mount under /etc and provide your path for /nix elsewhere without anything Steam Deck-specific.

Relying on external media like an sdcard of course requires getting your units setup right to wait for said device to appear and perhaps blocking the daemon until it does.