2022-09-26 14:59:21 +00:00
|
|
|
# generate s6-rc database, by generating closure of all
|
|
|
|
# config.services and calling s6-rc-compile on them
|
|
|
|
|
|
|
|
{
|
2024-06-30 15:58:29 +00:00
|
|
|
stdenvNoCC,
|
|
|
|
buildPackages,
|
|
|
|
closureInfo,
|
|
|
|
writeText,
|
|
|
|
services ? [ ],
|
2022-09-26 14:59:21 +00:00
|
|
|
}:
|
2025-02-10 21:55:08 +00:00
|
|
|
let
|
|
|
|
closure-info = closureInfo { rootPaths = services; };
|
|
|
|
in
|
|
|
|
stdenvNoCC.mkDerivation {
|
2022-09-26 14:59:21 +00:00
|
|
|
name = "s6-rc-database";
|
2025-02-10 21:55:08 +00:00
|
|
|
nativeBuildInputs = [ buildPackages.s6-rc ];
|
2022-09-26 14:59:21 +00:00
|
|
|
builder = writeText "find-s6-services" ''
|
|
|
|
source $stdenv/setup
|
|
|
|
mkdir -p $out
|
|
|
|
srcs=""
|
|
|
|
shopt -s nullglob
|
|
|
|
for i in $(cat ${closure-info}/store-paths ); do
|
|
|
|
if test -d $i; then
|
|
|
|
for j in $i/* ; do
|
|
|
|
if test -f $j/type ; then
|
2024-04-03 22:07:56 +00:00
|
|
|
if test -e $j/restart-on-upgrade; then
|
|
|
|
flag=force-restart
|
|
|
|
else
|
|
|
|
unset flag
|
|
|
|
fi
|
2024-03-28 23:45:10 +00:00
|
|
|
case $(cat $j/type) in
|
|
|
|
longrun|oneshot)
|
2024-04-03 22:07:56 +00:00
|
|
|
# s6-rc-update only wants atomics in its
|
2024-03-28 23:45:10 +00:00
|
|
|
# restarts file
|
2024-04-03 22:07:56 +00:00
|
|
|
echo $(basename $j) " " ''${flag-$i} >> $out/hashes
|
2024-03-28 23:45:10 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
2022-09-26 14:59:21 +00:00
|
|
|
srcs="$srcs $i"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
s6-rc-compile $out/compiled $srcs
|
2024-03-28 23:45:10 +00:00
|
|
|
s6-rc-db -c $out/compiled contents default
|
|
|
|
mv $out/hashes $out/compiled
|
|
|
|
'';
|
|
|
|
}
|