Thanks for your help. Now, I ran the runit emacs daemon with your
exec chpst -u <your username> emacs --fg-daemon
and I can see in htop that emacs --fg-daemon is running as my user, not as root. However, it seems emacs is not finding my emacs profile/preferences and is for sure not using root's preferences. So, I changed the runit script to be
exec chpst -u myusername emacs --fg-daemon -u myusername
to see if this would fix it, but I get this warning message in emacs:
Warning (initialization): Unable to create `user-emacs-directory' (~/.emacs.d/).
Any data that would normally be written there may be lost!
If you never want to see this message again,
customize the variable `user-emacs-directory-warning'.
Warning (initialization): An error occurred while loading ‘/home/myusername/.emacs’:
Symbol's function definition is void: ac-config-default
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace.
Is this some kind of permissions issue (from using chpst) that I can fix? It also seems that now emacs thinks that ~/ is /, which I would assume is the main problem, but I am not sure.
Edit: I changed the script to this:
#!/bin/sh
export HOME=/home/myusername
# This makes sure that the emacs daemon runs as user myusername
exec chpst -u myusername emacs --fg-daemon -u myusername
and adding the $HOME variable loads my configuration, but emacs still defaults its path to /etc/runit/sv/emacs when going to load a file, and extensions like tramp (allowing one to edit files over ssh and with sudo) do not connect for some reason.