Open lambdadog opened 2 years ago
Obviously the easiest solution for this is to simply generate a cookie by default for interactive use on first run, but I'm unsure if this behavior would be undesireable for anyone's real-world use-case.
Instinctively I want to say it would be fine, though.
Somewhat unrelated, but https://github.com/NixOS/nixpkgs/blob/4ee88025c2e84139b42d44e9e1c1746c0e0e538d/pkgs/servers/pleroma/default.nix#L22-L25 is false.
You just have to use wrapProgram
's --run
flag rather than --set
. You can run arbitrary commands, including setting an environmental variable with export
.
ex. (from a since deprecated hack I wrote to load my emacs config from nix)
makeWrapper "$prog" "$out/bin/$progname" \
--run 'test -a "$HOME/.emacs" && echo "~/.emacs exists, failing to load config." && exit 1' \
--run 'test -d "$HOME/.emacs.d" && echo "~/.emacs.d exists, failing to load config." && exit 1' \
--run 'export NIX_STORED_XDG_CONFIG_HOME=$XDG_CONFIG_HOME' \
--run 'export EMACSNATIVELOADPATH="$EMACSNATIVELOADPATH:$HOME/.local/share/emacs/eln-cache/"' \
--set XDG_CONFIG_HOME '${xdg-config-home}' \
--set NIX_EMACS_INIT_PACKAGE '${configPkg.pname}'
Ah, I didn't notice that issue, ty!
Not only pleroma_ctl
fails. If configs are provided manually, pleroma fails to start. The only line in log is about that cookie.
On NixOS 21.11 pleroma didn't crash, and pleroma_ctl instance gen
worked too. But it also had the line about cookie. Maybe it fails not because of cookie file?
@inexcode If you wish to run a pleroma instance you can run it using the NixOS service, which overloads the cookieFile
, but you're correct in that the server fails to start too with RELEASE_COOKIE unset.
If you desperately need to run for testing purposes, you should be able to set RELEASE_COOKIE to a file in the command-line.
ex.
$ dd if=/dev/urandom bs=1 count=16 | hexdump -e '16/1 "%02x"' > /path/to/your/release/cookie
$ RELEASE_COOKIE=/path/to/your/release/cookie pleroma
I struggled to run database maintenance tasks like pleroma_ctl database prune_objects
, but I finally found a way to run them: sudo -u pleroma env RELEASE_COOKIE=/var/lib/pleroma/.cookie pleroma_ctl database prune_objects
. Thanks @lambdadog for pointing me in the right direction.
I am unable to start the NixOS pleroma module while its config is missing:
error: The option 'services.pleroma.configs' is used but not defined.
and the description in the configs option for the pleroma module sent me to the Pleroma section of the NixOS manual:
Have a look to Pleroma section in the NixOS manual for more informations.
However, the first instruction there resulted in the failing to generate due to missing COOKIE error:
pleroma_ctl instance gen --output config.exs --output-psql setup.psql
cat: /nix/store/4hwmq96g9qb2dbvmfssnvppsafjwnx2x-pleroma-2.4.3/releases/COOKIE: No such file or directory
so I'm a little lost on how to get the module running in the first place if I'm unable to generate the necessary configs for it, and I ended up here while searching duckduckgo for the no such COOKIE message.
This should work as a workaround for the time being @wolfsprite.
$ dd if=/dev/urandom bs=1 count=16 | hexdump -e '16/1 "%02x"' > /tmp/pleroma-cookie
$ export RELEASE_COOKIE=/tmp/pleroma-cookie
then you should be able to run any pleroma_ctl
commands needed freely, at least in that terminal window.
That worked! Thanks for the assistance there. :3
edit: I did also have to manually make the /var/lib/pleroma/static
folder for pleroma_ctl to write robots.txt into, otherwise the whole generation was failing.
Do you want to deduplicate uploaded files? (y/n) [n] y
** (File.Error) could not make directory (with -p) "/var/lib/pleroma/static": no such file or directory
(elixir 1.13.4) lib/file.ex:316: File.mkdir_p!/1
(elixir 1.13.4) lib/enum.ex:1593: Enum."-map/2-lists^map/1-0-"/2
(pleroma 2.4.3) lib/mix/tasks/pleroma/instance.ex:250: Mix.Tasks.Pleroma.Instance.run/1
(stdlib 3.17) erl_eval.erl:685: :erl_eval.do_apply/6
(elixir 1.13.4) lib/code.ex:404: Code.validated_eval_string/3
For anyone else that may encounter this: just make sure that the directory you tell pleroma_ctl gen
to use for static files actually exists first. I thought I was safe using the default. >.>;
Describe the bug
Pleroma fails to run due to missing cookie file. This causes no issues with the NixOS module as it overloads the pleroma derivation's
cookieFile
argument, but renders the default build unusable without explicitly settingRELEASE_COOKIE
.This is an issue due to
pleroma_ctl instance gen
, the intended way to generate a config for a fresh instance, calling into pleroma in order to run. It's worth noting usingpleroma_ctl instance gen
is the intended way to generate a config for the NixOS module and set up the postgresql database as per the NixOS docs for the module.Steps To Reproduce
On nixpkgs master:
Expected behavior
pleroma_ctl
running and generating the config.exs and setup.psql files.Notify maintainers
@petabyteboy @ninjatrappeur @yu-re-ka @kloenk
Metadata
I did however explicitly use nixpkgs master for testing this, as so: