]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - lib/private/default.nix
Add phpFpm prestart script to lib
[perso/Immae/Config/Nix.git] / lib / private / default.nix
1 {}:
2 {
3 # This adds header colors to the builds, but it rebuilds the whole
4 # world from scratch, so only use it to debug!
5 # add it as postHook in derivations
6 immaePostHook = ''
7 header() {
8 echo -ne "\033[1;36m"
9 echo -n "$1"
10 echo -e "\033[0m"
11 }
12
13 echoCmd() {
14 printf "\033[1;34m%s:\033[0m" "$1"
15 shift
16 printf ' %q' "$@"
17 echo
18 }
19 '';
20
21 phpFpmPreStart = { app, varDir, keyFiles, actions }: ''
22 if [ ! -f "${varDir}/currentWebappDir" -o \
23 ! -f "${varDir}/currentKey" -o \
24 "${app}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ] \
25 || ! sha512sum -c --status ${varDir}/currentKey; then
26 pushd ${app} > /dev/null
27 ${builtins.concatStringsSep "\n " actions}
28 popd > /dev/null
29 echo -n "${app}" > ${varDir}/currentWebappDir
30 sha512sum ${builtins.concatStringsSep " " keyFiles} > ${varDir}/currentKey
31 fi
32 '';
33 }