diff --git a/flake.nix b/flake.nix index bcd41ea..9ca4456 100644 --- a/flake.nix +++ b/flake.nix @@ -126,6 +126,7 @@ clerie-sops-config clerie-sops-edit chromium-incognito + factorio-launcher git-checkout-github-pr git-diff-word git-pp diff --git a/hosts/krypton/programs.nix b/hosts/krypton/programs.nix index 79aae6b..a58eb0b 100644 --- a/hosts/krypton/programs.nix +++ b/hosts/krypton/programs.nix @@ -29,6 +29,8 @@ chromium-incognito print-afra + + factorio-launcher ]; # Wireshark diff --git a/hosts/zinc/programs.nix b/hosts/zinc/programs.nix index edf86ea..34808b1 100644 --- a/hosts/zinc/programs.nix +++ b/hosts/zinc/programs.nix @@ -9,6 +9,8 @@ #cura # libarcus library is currently broken, required for curaengine mumble + + factorio-launcher ]; } diff --git a/pkgs/factorio-launcher/default.nix b/pkgs/factorio-launcher/default.nix new file mode 100644 index 0000000..958882b --- /dev/null +++ b/pkgs/factorio-launcher/default.nix @@ -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; + }); +} diff --git a/pkgs/factorio-launcher/launch-factorio.sh b/pkgs/factorio-launcher/launch-factorio.sh new file mode 100644 index 0000000..a331c7f --- /dev/null +++ b/pkgs/factorio-launcher/launch-factorio.sh @@ -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 "$@" diff --git a/pkgs/overlay.nix b/pkgs/overlay.nix index d4bf798..3bc8eb6 100644 --- a/pkgs/overlay.nix +++ b/pkgs/overlay.nix @@ -7,6 +7,7 @@ final: prev: { clerie-sops-edit = final.callPackage ./clerie-sops/clerie-sops-edit.nix {}; clerie-update-nixfiles = final.callPackage ./clerie-update-nixfiles/clerie-update-nixfiles.nix {}; chromium-incognito = final.callPackage ./chromium-incognito {}; + factorio-launcher = final.callPackage ./factorio-launcher {}; git-checkout-github-pr = final.callPackage ./git-checkout-github-pr {}; git-diff-word = final.callPackage ./git-diff-word {}; git-pp = final.callPackage ./git-pp {};