From 71d9048f72e4ec7afffbcd562f14d53714110522 Mon Sep 17 00:00:00 2001 From: Félix Baylac-Jacqué Date: Wed, 16 Mar 2022 10:25:41 +0100 Subject: 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. --- nixos/modules/services/networking/pleroma.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'nixos/modules') diff --git a/nixos/modules/services/networking/pleroma.nix b/nixos/modules/services/networking/pleroma.nix index 9b8382392c0..d94cfb17999 100644 --- a/nixos/modules/services/networking/pleroma.nix +++ b/nixos/modules/services/networking/pleroma.nix @@ -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 ''; -- cgit 1.4.1 From b205832efe0c92c58576ffe47851c90cd405ee4b Mon Sep 17 00:00:00 2001 From: Félix Baylac-Jacqué Date: Thu, 17 Mar 2022 13:21:56 +0100 Subject: nixos/pleroma: regenerate empty release cookie files Since b9cfbcafdf0ca9573de1cdc06137c020e70e44a8, the lack of hexdump in the closure lead to the generation of empty cookie files. This empty cookie file is making pleroma to crash at startup now we correctly read it. We introduce a migration forcing these empty cookies to be re-generated to something not empty. --- nixos/modules/services/networking/pleroma.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nixos/modules') diff --git a/nixos/modules/services/networking/pleroma.nix b/nixos/modules/services/networking/pleroma.nix index d94cfb17999..c6d4c14dcb7 100644 --- a/nixos/modules/services/networking/pleroma.nix +++ b/nixos/modules/services/networking/pleroma.nix @@ -118,7 +118,7 @@ in { # Better be safe than sorry migration-wise. ExecStartPre = let preScript = pkgs.writers.writeBashBin "pleromaStartPre" '' - if [ ! -f "${cookieFile}" ] + if [ ! -f "${cookieFile}" ] || [ ! -s "${cookieFile}" ] then echo "Creating cookie file" dd if=/dev/urandom bs=1 count=16 | ${pkgs.hexdump}/bin/hexdump -e '16/1 "%02x"' > "${cookieFile}" -- cgit 1.4.1