#+begin_center October 2026. A thin client has only 8GB of MMC. You don't want to clutter it with a Nix install from ports (over 1GB). You don't want to clutter it with even a single BSD base system just for (ez)jails. (Over 1GB). And you don't want to fiddle much with having to =rustup= the cross target. And you don't want to run =cargo= on it, even if it has 2GB of RAM. S3-compatible object store support seems not yet really working in =task sync= /v3.5.0/. /Solutions described incrementally in non-working order — it only worked at the very end./ #+end_center * Building taskchampion with Nix #+begin_src shell nix build \ 'github:NixOS/nixpkgs/nixos-unstable#'\ 'pkgsCross.x86_64-freebsd.taskchampion-sync-server' #+end_src Just a single static binary. : cp result/bin/taskchampion-sync-server champ It has the Nix interpreter. #+begin_quote /$ file champ/ /champ: ELF 64-bit LSB pie executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /nix/store/74p25ds2gfczhjbc37agcr0012rg2m1d-libc-15.0.0/libexec/ld-elf.so.1, for FreeBSD 15.0 (1500068), FreeBSD-style, not stripped/ #+end_quote We patch it back. #+begin_src shell nix run nixpkgs#patchelf -- \ --set-interpreter /libexec/ld-elf.so.1 \ --remove-rpath champ #+end_src Now it's normal. #+begin_quote /$ file champ/ /champ: ELF 64-bit LSB pie executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 15.0 (1500068), FreeBSD-style, not stripped/ #+end_quote Copy the file over. I considered ezjail but it, too, requires unpacking base.txz once. This box has just a small mmc. #+begin_src shell sysrc jails_enable=YES mkdir -p /jails/taskchamp/{etc,var,tmp,root} cd /jails/taskchamp ln /home/user/champ ./ chmod 1777 tmp for d in bin sbin lib libexec usr do mkdir $d; mount -t nullfs -o ro /$d $d done mkdir var/{run,log,db.tmp} #+end_src */etc/jail.conf*: #+begin_src jail taskchamp { path = "/jails/taskchamp"; persist; mount.devfs; exec.clean; exec.consolelog = "/var/log/taskchampion.log" } #+end_src #+begin_src shell service jail onestart taskchamp jexec taskchamp /bin/sh touch /etc/{group,master.passwd} pw_mkdb -p /etc/master.passwd pw useradd champ -d /var/db/taskchampion -s /usr/sbin/nologin mkdir -p /var/db/taskchampion/data chown -R champ:champ /var/db/taskchampion exit service jail onestop taskchamp #+end_src /I start directly helping myself with an LLM from here on./ Set host variable for this document (replace =.html= with =.org= in address bar to see the Org Mode): #+BEGIN_SRC elisp :results none (setq my/host "RR@192.168.R.RR") #+END_SRC * Check current /etc/fstab in */etc*: #+BEGIN_SRC csh :dir (concat "/ssh:" my/host ":/etc") :results output :exports both cat fstab mount #+END_SRC #+RESULTS: #+begin_example # Device Mountpoint FStype Options Dump Pass# /dev/mmcsd0p2 / ufs rw 1 1 /dev/mmcsd0p1 /boot/efi msdosfs rw 2 2 /dev/mmcsd0p3 none swap sw 0 0 /dev/mmcsd0p2 on / (ufs, local, soft-updates, journaled soft-updates) devfs on /dev (devfs) /dev/mmcsd0p1 on /boot/efi (msdosfs, local) … /bin on /jails/taskchamp/bin (nullfs, local, read-only) /sbin on /jails/taskchamp/sbin (nullfs, local, read-only) /lib on /jails/taskchamp/lib (nullfs, local, read-only) /libexec on /jails/taskchamp/libexec (nullfs, local, read-only) /usr on /jails/taskchamp/usr (nullfs, local, read-only) devfs on /jails/taskchamp/dev (devfs) #+end_example * Append nullfs entries if missing #+BEGIN_SRC sh :dir (concat "/ssh:" my/host ":~/") :results output :exports both cp /etc/fstab ./ for d in bin sbin lib libexec usr; do entry="/$d /jails/taskchamp/$d nullfs ro 0 0" if ! grep -qF "$entry" fstab; then echo "$entry" | tee -a fstab fi done #+END_SRC #+RESULTS: : /bin /jails/taskchamp/bin nullfs ro 0 0 : /sbin /jails/taskchamp/sbin nullfs ro 0 0 : /lib /jails/taskchamp/lib nullfs ro 0 0 : /libexec /jails/taskchamp/libexec nullfs ro 0 0 : /usr /jails/taskchamp/usr nullfs ro 0 0 * Add devfs entry (if missing) #+BEGIN_SRC sh :dir (concat "/ssh:" my/host ":~/") :results output :exports both entry="devfs /jails/taskchamp/dev devfs rw 0 0" grep -qF "$entry" fstab || echo "$entry" >> fstab cat fstab #+END_SRC #+RESULTS: #+begin_example # Device Mountpoint FStype Options Dump Pass# /dev/mmcsd0p2 / ufs rw 1 1 /dev/mmcsd0p1 /boot/efi msdosfs rw 2 2 /dev/mmcsd0p3 none swap sw 0 0 /bin /jails/taskchamp/bin nullfs ro 0 0 /sbin /jails/taskchamp/sbin nullfs ro 0 0 /lib /jails/taskchamp/lib nullfs ro 0 0 /libexec /jails/taskchamp/libexec nullfs ro 0 0 /usr /jails/taskchamp/usr nullfs ro 0 0 devfs /jails/taskchamp/dev devfs rw 0 0 #+end_example We can install the fstab as root by hand. (done) * Let's prepare +rc+ files to launch the =daemon= in jail as the user. #+begin_quote All creations/modifications to be done in the home directory of our user and then copied by hand. And it should be done in a minimalistic way, just jexec in host's rc, as small files as possible. #+end_quote Welp, actually better to do it right in jail.conf, no rc not inside and not outside the jail. ** Amend =/etc/jail.conf= #+begin_src csh :dir (concat "/ssh:" my/host ":~/") :results output :exports both ed -s /etc/jail.conf <<'ED' /taskchampion.log/a exec.jail_user = "champ"; exec.start = "/usr/sbin/daemon /champ --data-dir /var/db/taskchampion/data --listen localhost:9000"; . ,p wq jail.conf ED #+end_src #+RESULTS: : taskchamp { : path = "/jails/taskchamp"; : persist; : mount.devfs; : exec.clean; : exec.consolelog = "/var/log/taskchampion.log"; : exec.jail_user = "champ"; : exec.start = "/usr/sbin/daemon /champ --data-dir /var/db/taskchampion/data"; : } #+begin_quote (llm) =exec.start=: override the default (=/etc/rc=) rather than =+== — the jail has no rc system anyway. #+end_quote When you need to jexec into a failing jail, comment out the =exec.start= line of the /jail.conf/. ** =failed to lookup address information: Name could not be resolved at this time= : echo 127.0.0.1 localhost >> /jails/taskchamp/etc/hosts ** =Protocol not supported (os error 43)= : ifconfig lo0 alias 127.0.0.2/32 : sysrc ifconfig_lo0_alias0='inet 127.0.0.2 netmask 255.255.255.255' And append =ip4.addr = "127.0.0.2";= to //etc/jail.conf/. /As it later turned out, apparently prefixing that IP in *jail.conf* like ="lo0|127.0.0.2/32"= should be equivalent to hand-rolling an alias like above./ ** jail doesn't know /0/. jexec can't use /su/. what do? : jexec -U champ taskchamp /bin/sh =-u= won't recognize a user not declared locally. Capital =-U= uses jail users. ** Make it auto-restart See =daemon --help=. Add a =-r= right after =/usr/sbin/daemon= in the =jail.conf=. ** Test local : curl 127.0.0.2:9000 : TaskChampion sync server v0.7.1 ** Doesn't work outside lo #+begin_src shell :result output :exports both curl http://192.168.X.XX:9000 2>&1 #+end_src #+RESULTS: : curl: (7) Failed to connect to 192.168.X.XX:9000 after 13 ms: Could not connect to server I tried *changing the =--listen= to =0.0.0.0:9000= and it still worked* locally, will it work remotely? #+begin_src shell :result output :exports both curl http://192.168.X.XX:9000 2>&1 #+end_src #+RESULTS: : curl: (7) Failed to connect to 192.168.X.XX:9000 after 15 ms: Could not connect to server Worked locally the same, so I left it as an improvement. I then fiddled for a while trying to get /pf/ to do the job, but failed. ** /inetd/ ftw : pkg install rinetd : sysrc rinetd_enable=YES : echo 0.0.0.0 9000 127.0.0.2 9000 >> /usr/local/etc/rinetd.conf : service rinetd start #+begin_src shell :result output :exports both curl http://192.168.X.XX:9000 #+end_src #+RESULTS: : TaskChampion sync server v0.7.1 All there was to it. #+begin_src shell :results output verbatim :exports both echo yes | task config sync.server.url http://192.168.X.XX:9000 echo yes | task config sync.server.client_id `hostname` echo yes | task config sync.aws.bucket '' task sync 2>&1 #+end_src #+RESULTS: #+begin_example Are you sure you want to add 'sync.server.url' with a value of 'http://192.168.X.XX:9000'? (yes/no) Config file /home/user/.taskrc modified. Are you sure you want to add 'sync.server.client_id' with a value of 'XXX'? (yes/no) Config file /home/user/.taskrc modified. Are you sure you want to change the value of 'sync.aws.bucket' from 'taskwarrior' to ''? (yes/no) Config file /home/user/.taskrc modified. thread '' (2269610) panicked at src/taskchampion-cpp/src/lib.rs:599:9: XXX is not a valid UUID note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread '' (2269610) panicked at /build/taskwarrior-3.5.0-vendor/source-registry-0/cxx-1.0.199/src/unwind.rs:37:9: panic in ffi function taskchampion_lib::ffi::uuid_from_string, aborting. stack backtrace: 0: 0x62bde4706138 - <::print::DisplayBacktrace as core[8e00fffe8ffd11c6]::fmt::Display>::fmt 1: 0x62bde4738f9a - core[8e00fffe8ffd11c6]::fmt::write 2: 0x62bde46a158c - core[8e00fffe8ffd11c6]::io::write::default_write_fmt:: 3: 0x62bde46ffdc2 - ::print 4: 0x62bde46d649f - std[fc5bed5d6136bc02]::panicking::default_hook::{closure#0} 5: 0x62bde46d8d28 - std[fc5bed5d6136bc02]::panicking::default_hook 6: 0x62bde46d91c2 - std[fc5bed5d6136bc02]::panicking::panic_with_hook 7: 0x62bde46ff9c2 - std[fc5bed5d6136bc02]::panicking::panic_handler::{closure#0} 8: 0x62bde46feb59 - std[fc5bed5d6136bc02]::sys::backtrace::__rust_end_short_backtrace:: 9: 0x62bde46d709d - __rustc[ce3c72daf7630c0c]::rust_begin_unwind 10: 0x62bde36b5b1c - core[8e00fffe8ffd11c6]::panicking::panic_fmt 11: 0x62bde36b124f - ::drop 12: 0x62bde38dbc7d - tc$cxxbridge1$199$uuid_from_string 13: 0x62bde38293b5 - _ZN7CmdSync7executeERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE 14: 0x62bde36d0d70 - _ZN7Context8dispatchERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE 15: 0x62bde36d48df - _ZN7Context3runEv 16: 0x62bde36c2309 - main 17: 0x7c369be2b391 - __libc_start_call_main 18: 0x7c369be2b4a8 - __libc_start_main_impl 19: 0x62bde36c4cd5 - _start 20: 0x0 - thread '' (2269610) panicked at /rustc/b940084d7eb6a299eb4bfeb8e34901bc051e7ac4/library/core/src/panicking.rs:233:5: panic in a destructor during cleanup thread caused non-unwinding panic. aborting. #+end_example Ah, great. Nothing said it was supposed to be a uuid. #+begin_src shell :results output verbatim :exports both echo yes | task config sync.server.client_id `uuidgen` task sync 2>&1 #+end_src #+RESULTS: : Are you sure you want to change the value of 'sync.server.client_id' from 'XXX' to '2137d567-c8fb-4ac9-80b5-1cdf3dbd913c'? (yes/no) Config file /home/user/.taskrc modified. : Syncing with sync server at http://192.168.X.XX:9000 : Success! : Sent 124 local operations to the server #+LF ** =reboot= Turned out =sysrc jail_enable=YES= was left undone. Funny failure more: the loopback IP alias just makes it perhaps recur infinitely, or maybe it was just waiting to timeout; didn't check. (Locally: waits. Remotely: empty reply from server.) - *** =reboot= *** - *Locally:* /Empty reply from server./ Oh will I really need to give it a non-loopback IP or something? /Fine, unaliases your alias./ : ifconfig lo0 -alias 127.0.0.2 : service jail restart Didn't help. Welp. : # tail /var/log/taskchampion.log : Error: Can't assign requested address (os error 49) ** Create a separate loopback It surprised me to find out that /cloning/ a network interface was meant as /creating a separate distinct unrelated instance of the kind./ : sysrc cloned_interfaces+=" lo1" Mind the load-bearing whitespace after the double-quote. ↑ The command to do it before next /rc/ is a bit more adherent to the meaning: : ifconfig lo1 create Edit the *jail.conf*: : ip4.addr = "lo1|127.0.1.1/32"; Correct the right-hand-side IP in *rinetd.conf*, in ///usr/local/etc//, to =127.0.1.1= likewise. : service jail restart : service rinetd restart #+begin_src shell :result output :exports both curl http://192.168.X.XX:9000 #+end_src #+RESULTS: : TaskChampion sync server v0.7.1 *** =reboot= #+begin_src shell :result output :exports both curl http://192.168.X.XX:9000 #+end_src #+RESULTS: : TaskChampion sync server v0.7.1 Finally. #+LF #+NF