main
John Lauer Publish 0.1.0 d8a45ab

name: hydrogen-file-transfer description: >- Move files both ways between the Hydrogen workspace and the Linux computer it runs on: /mnt/host inside the workspace, /files/inject, machinectl copy-to and copy-from on the host, or adom-bridge send_files/pull_file to another machine. Use when asked to copy a file to my desktop, get a file from my computer, move a file in or out, or where my downloads go.

Move files between the workspace and this computer

The workspace is the systemd-nspawn machine Adom-Workspace on this same computer. Your work is at /home/adom/project inside it. The workspace user is adom (uid 1001); the host user is usually a different uid.

Method 1: /mnt/host (from inside the workspace), simplest

Hydrogen binds host folders into the machine:

In the workspace Host path Access
/mnt/host/home /home read-write
/mnt/host/tmp /tmp read-write
/mnt/host/usr /usr read-only
/mnt/host/opt /opt read-only
HOSTUSER=$(ls /mnt/host/home | head -1)        # check with the user if there are several
cp /home/adom/project/report.pdf "/mnt/host/home/$HOSTUSER/Downloads/"
cp "/mnt/host/home/$HOSTUSER/Downloads/data.csv" /home/adom/project/

Host file permissions still apply, to uid 1001. Many distros make home folders private (mode 0750 or 0700), so ls /mnt/host/home/<user> may say "Permission denied". Then use the shared /tmp: ask the user to drop the file in /tmp on the host and copy it from /mnt/host/tmp, or write to /mnt/host/tmp/<name> and tell them where it is. A file you write lands owned by uid 1001: the user can read it (with the default umask) but may need sudo to delete or edit it in place, so tell them to copy it.

The workspace's own /tmp is a private tmpfs, cleared at every machine start. Never leave anything there you want to keep.

Method 2: POST /files/inject (any host program, through Hydrogen)

Writes files into the project as adom:

BASE="$(cat ~/.adom/hydrogen-control-url)"
curl -s -X POST "$BASE/files/inject" -H 'Content-Type: application/json' \
  -d "{\"subdir\":\"downloads\",\"files\":[{\"name\":\"photo.png\",\"data\":\"$(base64 -w0 photo.png)\"}]}"
# -> /home/adom/project/downloads/photo.png

subdir (default downloads) and name must be single path components.

Method 3: from a host terminal

The machine's files are at /var/lib/machines/Adom-Workspace on the host, readable by root only. Use machinectl (the machine must be running):

sudo machinectl copy-from Adom-Workspace /home/adom/project/out.zip ~/Downloads/out.zip
sudo machinectl copy-to   Adom-Workspace ~/Downloads/data.csv /home/adom/project/data.csv

A file copied out with sudo is owned by root; sudo chown $USER it afterwards.

Method 4: the adom-bridge relay (to another machine)

send_files / pull_file talk to a computer running Adom Bridge: this computer once Hydrogen has installed it (when a Linux build is published for the user's account), or the user's other machines through the Adom mesh (for example a laptop). See hydrogen-adom-bridge.

adom-bridge send_files '{"filePaths":["/home/adom/project/out.zip"]}'
adom-bridge pull_file  '{"filePaths":["<path on that machine>"],"saveTo":"/home/adom/project"}'

Notes:

  • Confirm the bridge first: adom-bridge ping answers pong when a bridge is reachable.
  • Files whose basename starts with _ are silently dropped by the relay — use plain names.

Which method to use

Situation Use
Scripting inside the workspace, file in the user's home or /tmp Method 1
A host program or page pushing files in Method 2
The user at a host terminal Method 3
A different computer Method 4

Where things persist

/home/adom/project survives workspace and computer restarts. A virgin reset deletes the whole Adom-Workspace machine and every file in it. Copy anything important out first. See hydrogen-volume.

  • hydrogen-volume — what persists, where files live, backing up before virgin reset
  • hydrogen-adom-bridge — the relay (send_files / pull_file) and OS reach
  • hydrogen-workspace-lifecycle: start, stop and reset the machine