]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - lib/private/default.nix
Add phpFpm prestart script to lib
[perso/Immae/Config/Nix.git] / lib / private / default.nix
index c7d753a30e8ffb7542ef905d0b23abc167c71a38..b04f7b3902b1bf1556a98e5acb6334b7e843dbb3 100644 (file)
       echo
     }
   '';
+
+  phpFpmPreStart = { app, varDir, keyFiles, actions }: ''
+    if [ ! -f "${varDir}/currentWebappDir" -o \
+        ! -f "${varDir}/currentKey" -o \
+        "${app}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ] \
+        || ! sha512sum -c --status ${varDir}/currentKey; then
+      pushd ${app} > /dev/null
+      ${builtins.concatStringsSep "\n  " actions}
+      popd > /dev/null
+      echo -n "${app}" > ${varDir}/currentWebappDir
+      sha512sum ${builtins.concatStringsSep " " keyFiles} > ${varDir}/currentKey
+    fi
+  '';
 }