pkgs/factorio-launcher: Add wrapper to launch factorio
This commit is contained in:
25
pkgs/factorio-launcher/default.nix
Normal file
25
pkgs/factorio-launcher/default.nix
Normal file
@@ -0,0 +1,25 @@
|
||||
{ pkgs, lib, ... }:
|
||||
|
||||
pkgs.buildFHSEnv {
|
||||
name = "factorio-launcher";
|
||||
targetPkgs = pkgs: (with pkgs; [
|
||||
alsa-lib
|
||||
libGL
|
||||
libpulseaudio
|
||||
libxkbcommon
|
||||
wayland
|
||||
]) ++ (with pkgs.xorg; [
|
||||
libICE
|
||||
libSM
|
||||
libX11
|
||||
libXcursor
|
||||
libXext
|
||||
libXi
|
||||
libXinerama
|
||||
libXrandr
|
||||
]);
|
||||
runScript = lib.getExe (pkgs.writeShellApplication {
|
||||
name = "launch-factorio";
|
||||
text = builtins.readFile ./launch-factorio.sh;
|
||||
});
|
||||
}
|
28
pkgs/factorio-launcher/launch-factorio.sh
Normal file
28
pkgs/factorio-launcher/launch-factorio.sh
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "Pass path to factorio install directory as first argument"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FACTORIO_BINARY_PATH=""
|
||||
|
||||
for suffix in "" "/factorio" "/x64/factorio" "/bin/x64/factorio" "/factorio/bin/x64/factorio"; do
|
||||
if [[ -f "$1${suffix}" && -x "$1${suffix}" ]]; then
|
||||
FACTORIO_BINARY_PATH="$1${suffix}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z $FACTORIO_BINARY_PATH ]]; then
|
||||
echo "No factorio executable found below $1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
shift
|
||||
|
||||
set -- "${FACTORIO_BINARY_PATH}" "$@"
|
||||
|
||||
exec "$@"
|
Reference in New Issue
Block a user