diff options
author | Félix Baylac-Jacqué <felix@alternativebit.fr> | 2022-03-16 10:22:25 +0100 |
---|---|---|
committer | Félix Baylac-Jacqué <felix@alternativebit.fr> | 2022-03-17 15:21:52 +0100 |
commit | 8b7845fee9097594ac84745a959528cae5dd0187 (patch) | |
tree | 20ff52d5c4180751e37da41fd950ea1b574851c9 /pkgs | |
parent | 40a3103c0f5847ab193299f0275dbb32c2920b8b (diff) | |
download | nixpkgs-8b7845fee9097594ac84745a959528cae5dd0187.tar nixpkgs-8b7845fee9097594ac84745a959528cae5dd0187.tar.gz nixpkgs-8b7845fee9097594ac84745a959528cae5dd0187.tar.bz2 nixpkgs-8b7845fee9097594ac84745a959528cae5dd0187.tar.lz nixpkgs-8b7845fee9097594ac84745a959528cae5dd0187.tar.xz nixpkgs-8b7845fee9097594ac84745a959528cae5dd0187.tar.zst nixpkgs-8b7845fee9097594ac84745a959528cae5dd0187.zip |
pleroma: Potentially wrap binaries with RELEASE_COOKIE
Pleroma_ctl and pleroma depend on mix_release to run which itself depends on a RELEASE_COOKIE. It'll fail to run without such a cookie. Allowing the user to wrap this binary with a RELEASE_COOKIE. We don't set any by default, meaning this diff is no-op for the existing deployments relying on the pleroma package but not on the NixOS module.
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/servers/pleroma/default.nix | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/pkgs/servers/pleroma/default.nix b/pkgs/servers/pleroma/default.nix index ec7de2ac57c..dd4025a76c0 100644 --- a/pkgs/servers/pleroma/default.nix +++ b/pkgs/servers/pleroma/default.nix @@ -1,7 +1,8 @@ { lib, beamPackages , fetchFromGitHub, fetchFromGitLab -, file, cmake +, file, cmake, bash , nixosTests, writeText +, cookieFile ? null , ... }: @@ -17,6 +18,34 @@ beamPackages.mixRelease rec { sha256 = "sha256-RcqqNNNCR4cxETUCyjChkpq+cQ1QzNOHHzdqBLtOc6g="; }; + preFixup = if (cookieFile != null) then '' + # There's no way to use a subprocess to cat the content of the + # file cookie using wrapProgram: it gets escaped (by design) with + # a pair of backticks :( + # We have to come up with our own custom wrapper to do this. + function wrapWithCookie () { + local hidden + hidden="$(dirname "$1")/.$(basename "$1")"-wrapped + while [ -e "$hidden" ]; do + hidden="''${hidden}_" + done + mv "$1" "''${hidden}" + + cat > "$1" << EOF + #!${bash}/bin/bash + export RELEASE_COOKIE="\$(cat "${cookieFile}")" + exec -a "\$0" "''${hidden}" "\$@" + EOF + chmod +x "$1" + } + + for f in "$out"/bin/*; do + if [[ -x "$f" ]]; then + wrapWithCookie "$f" + fi + done + '' else ""; + mixNixDeps = import ./mix.nix { inherit beamPackages lib; overrides = (final: prev: { |