bscpkgs/bsc/garlic/launcher.nix

43 lines
697 B
Nix
Raw Normal View History

2020-08-05 00:38:33 +08:00
{
stdenv
}:
2020-08-12 20:00:04 +08:00
apps: # Each app must be unique
2020-08-10 21:27:46 +08:00
2020-08-05 00:38:33 +08:00
stdenv.mkDerivation {
2020-08-10 21:27:46 +08:00
name = "launcher";
2020-08-05 00:38:33 +08:00
preferLocalBuild = true;
buildInputs = [] ++ apps;
apps = apps;
2020-08-05 00:38:33 +08:00
phases = [ "installPhase" ];
dontPatchShebangs = true;
2020-08-05 00:38:33 +08:00
installPhase = ''
mkdir -p $out/apps
for j in $apps; do
2020-08-12 20:00:04 +08:00
target=$out/apps/$(basename $j)
if [ -e $target ]; then
echo "Duplicated app: $j"
echo
echo "Provided apps: "
printf "%s\n" $apps
echo
exit 1
fi
ln -s $j $target
2020-08-05 00:38:33 +08:00
done
mkdir -p $out/bin
2020-08-10 21:27:46 +08:00
cat > $out/bin/run <<EOF
#!/bin/sh
2020-08-05 00:38:33 +08:00
for j in $out/apps/*; do
\$j/bin/run
2020-08-05 00:38:33 +08:00
done
EOF
2020-08-10 21:27:46 +08:00
chmod +x $out/bin/run
2020-08-05 00:38:33 +08:00
'';
}