I'm working on packaging Lemmy for Alpine Linux. Since it would become part of a regular distribution, the config file can not be in /config/ as packages are not allowed to write to that directory. Please allow specifying an alternative config location, for example with a simple command-line switch (e.g. /usr/bin/lemmy_server -c /etc/lemmy/config.hjson), or look in /etc by default.
One tricky part is that we also need defaults.hjson at runtime. Maybe we could embed that in the binary to make things easier, but I'm not sure how to do that.
Just parsing command line paramaters should be pretty easy though, there are plenty of crates. I'd prefer to use one with few dependencies cause our compile time is already too long.
I'm not against having this configurable of course, but wouldn't it be pretty easy to just put the executable somewhere else, or run it from somewhere else, like /app/lemmy and /app/config?
That is not an option for a distribution package, binaries _have_ to be installed to /usr/bin
One tricky part is that we also need defaults.hjson at runtime.
Just have a command-line switch for that too? --default-config or -d or something.
Would an env var work? Then we wouldn't have to include clap just for one var, all of the others being in that config.
Yeah that'd be fine for me. I can stick that in an init script :wink:
Well, the problem isn't really fixed as it still tries to find the default config next to the binary.
✔︎ lemmy (testing_lemmy) ✗ LEMMY_CONFIG_LOCATION=/etc/lemmy/config.hjson /usr/bin/lemmy_server
thread 'main' panicked at 'configuration file "config/defaults.hjson" not found', lemmy_utils/src/settings.rs:70:15
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Panic in Arbiter thread.
Ah dang, must've just worked for me because I ran it from the code :( . I'll fix this in a min.