nixos/pleroma: inject release cookie path to the pleroma package
We inject the release cookie path to the pleroma derivation in order to wrap pleroma_ctl with it. Doing this allows us to remove the systemd-injected RELEASE_COOKIE path, which was sadly buggy (RELEASE_COOKIE should point to the *content* of the cookie, not the file containing it). We take advantage of this to factor out the cookie path.
This commit is contained in:
parent
8b7845fee9
commit
71d9048f72
1 changed files with 4 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
|||
{ config, options, lib, pkgs, stdenv, ... }:
|
||||
let
|
||||
cfg = config.services.pleroma;
|
||||
cookieFile = "/var/lib/pleroma/.cookie";
|
||||
in {
|
||||
options = {
|
||||
services.pleroma = with lib; {
|
||||
|
@ -8,7 +9,7 @@ in {
|
|||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.pleroma;
|
||||
default = pkgs.pleroma.override { inherit cookieFile; };
|
||||
defaultText = literalExpression "pkgs.pleroma";
|
||||
description = "Pleroma package to use.";
|
||||
};
|
||||
|
@ -100,7 +101,6 @@ in {
|
|||
after = [ "network-online.target" "postgresql.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
restartTriggers = [ config.environment.etc."/pleroma/config.exs".source ];
|
||||
environment.RELEASE_COOKIE = "/var/lib/pleroma/.cookie";
|
||||
serviceConfig = {
|
||||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
|
@ -118,10 +118,10 @@ in {
|
|||
# Better be safe than sorry migration-wise.
|
||||
ExecStartPre =
|
||||
let preScript = pkgs.writers.writeBashBin "pleromaStartPre" ''
|
||||
if [ ! -f /var/lib/pleroma/.cookie ]
|
||||
if [ ! -f "${cookieFile}" ]
|
||||
then
|
||||
echo "Creating cookie file"
|
||||
dd if=/dev/urandom bs=1 count=16 | hexdump -e '16/1 "%02x"' > /var/lib/pleroma/.cookie
|
||||
dd if=/dev/urandom bs=1 count=16 | ${pkgs.hexdump}/bin/hexdump -e '16/1 "%02x"' > "${cookieFile}"
|
||||
fi
|
||||
${cfg.package}/bin/pleroma_ctl migrate
|
||||
'';
|
||||
|
|
Loading…
Reference in a new issue