JMM’s notes on the

Librem 5

Misc

Haptic motor

I have an example of how to use the haptic/vibration motor from Guile Scheme and C in my Guile notes.

Reflashing

So I updated from Byzantium to Crimson, then the next day I tried updating from Crimson to Dawn (which I didn’t really hear anybody really suggesting, but I wanted newer packages). Updating didn’t go well, haha, and I ended up in a boot loop. So I had to figure out how to reflash it on NixOS.

Getting Nix in the PATH under PureOS

If you install Nix in PureOS using the curl | bash incantation, you may notice that although you have a /etc/profile.d/nix.sh, your PATH environment variable doesn’t include any Nix directories. What may be weirder is that you notice that __ETC_PROFILE_NIX_SOURCED=1 is set when looking at systemctl --user show-environment. I think what’s happening involves phosh.service using PAMName=login, which uses /etc/login.defs to reset the PATH after profile scripts have already been called. (I think that the way phosh.service does this auto-login may also be why the keyring isn’t unlocked when unlocking the screen. Yet, I don’t know how to do a “real” PAM login without this. I think later versions of phosh have a real greeter that does a real login.) (See also setting environment variables for gnome session.)

Okay, what seems to be happening is that the way phosh.service calls /usr/bin/phosh-session, it basically calls bash -lc '${GNOME_SESSION} […]' which re-sources /etc/profile.d/nix.sh. /etc/profile resets the PATH, then goes through *.sh files in /etc/profile.d/. But because you already have __ETC_PROFILE_NIX_SOURCED set, it won’t re-load changes from /etc/profile.d/nix.sh, so it doesn’t try altering the PATH again. I think gnome-session itself may also source /etc/profile, so you maybe get a case of double sourcing it. But since sourcing /etc/profile isn’t idempotent, the second time it’s sourced it clobbers the PATH. So what we want to do is unset __ETC_PROFILE_NIX_SOURCED after bash -lc but before gnome-session. You can kind of hack around this by putting the following in ~/.phoshdebug:

# Run gnome-session through a login shell so it picks
# variables from /etc/profile.d (XDG_*)
# BUT (!) unset __ETC_PROFILE_NIX_SOURCED so we don’t clobber PATH.
# This is otherwise edited from /usr/bin/phosh-session.
[ -n "$WLR_BACKENDS" ] || WLR_BACKENDS=drm,libinput
export WLR_BACKENDS
exec "${COMPOSITOR}" -S -C "${PHOC_INI}" -E "bash -lc 'unset __ETC_PROFILE_NIX_SOURCED; ${GNOME_SESSION} --disable-acceleration-check --session=phosh --systemd'"

Phosh will warn about .phoshdebug. Perhaps a better fix would be to alter /etc/profile to be more idempotent and not reset PATH? Or see also this nix issue.

Fun stuff about the L5

Here are just some fun things I like about the Librem 5, that you don’t see much with other phones.

To-do