bscpkgs/bsc/garlic/launcher.nix

43 lines
697 B
Nix
Raw Normal View History

2020-08-04 18:38:33 +02:00
{
stdenv
}:
2020-08-12 14:00:04 +02:00
apps: # Each app must be unique
2020-08-10 15:27:46 +02:00
2020-08-04 18:38:33 +02:00
stdenv.mkDerivation {
2020-08-10 15:27:46 +02:00
name = "launcher";
2020-08-04 18:38:33 +02:00
preferLocalBuild = true;
buildInputs = [] ++ apps;
apps = apps;
2020-08-04 18:38:33 +02:00
phases = [ "installPhase" ];
dontPatchShebangs = true;
2020-08-04 18:38:33 +02:00
installPhase = ''
mkdir -p $out/apps
for j in $apps; do
2020-08-12 14:00:04 +02: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-04 18:38:33 +02:00
done
mkdir -p $out/bin
2020-08-10 15:27:46 +02:00
cat > $out/bin/run <<EOF
#!/bin/sh
2020-08-04 18:38:33 +02:00
for j in $out/apps/*; do
\$j/bin/run
2020-08-04 18:38:33 +02:00
done
EOF
2020-08-10 15:27:46 +02:00
chmod +x $out/bin/run
2020-08-04 18:38:33 +02:00
'';
}