diff options
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/build-support/auto-patchelf/default.nix | 16 | ||||
-rw-r--r-- | pkgs/build-support/auto-patchelf/setup-hook.sh (renamed from pkgs/games/build-support/setup-hooks/auto-patchelf.sh) | 24 | ||||
-rw-r--r-- | pkgs/default.nix | 3 | ||||
-rw-r--r-- | pkgs/games/build-support/build-game.nix | 6 | ||||
-rw-r--r-- | pkgs/games/build-support/default.nix | 2 |
5 files changed, 32 insertions, 19 deletions
diff --git a/pkgs/build-support/auto-patchelf/default.nix b/pkgs/build-support/auto-patchelf/default.nix new file mode 100644 index 00000000..c7a055cb --- /dev/null +++ b/pkgs/build-support/auto-patchelf/default.nix @@ -0,0 +1,16 @@ +{ stdenv, substituteAll, patchelf, binutils-unwrapped, findutils, file, glibc +, gnugrep, gnused +}: + +substituteAll { + src = ./setup-hook.sh; + + inherit (stdenv) shell; + file = "${file}/bin/file"; + find = "${findutils}/bin/find"; + grep = "${gnugrep}/bin/grep"; + ldd = "${glibc.bin}/bin/ldd"; + objdump = "${binutils-unwrapped}/bin/objdump"; + patchelf = "${patchelf}/bin/patchelf"; + sed = "${gnused}/bin/sed"; +} diff --git a/pkgs/games/build-support/setup-hooks/auto-patchelf.sh b/pkgs/build-support/auto-patchelf/setup-hook.sh index e24e278f..6e34b4ef 100644 --- a/pkgs/games/build-support/setup-hooks/auto-patchelf.sh +++ b/pkgs/build-support/auto-patchelf/setup-hook.sh @@ -7,13 +7,13 @@ gatherLibraries() { addEnvHooks "$targetOffset" gatherLibraries isExecutable() { - [ "$(file -b -N --mime-type "$1")" = application/x-executable ] + [ "$(@file@ -b -N --mime-type "$1")" = application/x-executable ] } findElfs() { - find "$1" -type f -exec "$SHELL" -c ' + @find@ "$1" -type f -exec @shell@ -c ' while [ -n "$1" ]; do - mimeType="$(file -b -N --mime-type "$1")" + mimeType="$(@file@ -b -N --mime-type "$1")" if [ "$mimeType" = application/x-executable \ -o "$mimeType" = application/x-sharedlib ]; then echo "$1" @@ -38,12 +38,12 @@ declare -gi doneRecursiveSearch=0 declare -g foundDependency getDepsFromSo() { - ldd "$1" 2> /dev/null | sed -n -e 's/[^=]*=> *\(.\+\) \+([^)]*)$/\1/p' + @ldd@ "$1" 2> /dev/null | @sed@ -n -e 's/[^=]*=> *\(.\+\) \+([^)]*)$/\1/p' } checkElfDep() { - local errors ldout="$(ldd "$1" 2> /dev/null)" - if errors="$(echo "$ldout" | grep -F "not found")"; then + local errors ldout="$(@ldd@ "$1" 2> /dev/null)" + if errors="$(echo "$ldout" | @grep@ -F "not found")"; then echo -e "Library dependencies missing for $1:\n$errors" fi } @@ -63,7 +63,7 @@ populateCacheWithRecursiveDeps() { } getSoArch() { - objdump -f "$1" | sed -ne 's/^architecture: *\([^,]\+\).*/\1/p' + @objdump@ -f "$1" | @sed@ -ne 's/^architecture: *\([^,]\+\).*/\1/p' } findDependency() { @@ -101,7 +101,7 @@ autoPatchelfFile() { local interpreter="$(< "$NIX_CC/nix-support/dynamic-linker")" if isExecutable "$toPatch"; then - patchelf --set-interpreter "$interpreter" "$toPatch" + @patchelf@ --set-interpreter "$interpreter" "$toPatch" if [ -n "$runtimeDependencies" ]; then for dep in $runtimeDependencies; do rpath="$rpath${rpath:+:}$dep/lib" @@ -111,11 +111,11 @@ autoPatchelfFile() { echo "searching for dependencies of $toPatch:" >&2 - patchelf --remove-rpath "$toPatch" + @patchelf@ --remove-rpath "$toPatch" local missing="$( - ldd "$toPatch" 2> /dev/null | \ - sed -n -e 's/^[\t ]*\([^ ]\+\) => not found.*/\1/p' + @ldd@ "$toPatch" 2> /dev/null | \ + @sed@ -n -e 's/^[\t ]*\([^ ]\+\) => not found.*/\1/p' )" for dep in $missing; do @@ -130,7 +130,7 @@ autoPatchelfFile() { if [ -n "$rpath" ]; then echo "setting RPATH to: $rpath" >&2 - patchelf --set-rpath "$rpath" "$toPatch" + @patchelf@ --set-rpath "$rpath" "$toPatch" fi } diff --git a/pkgs/default.nix b/pkgs/default.nix index 5e6530ab..cd4eb76c 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -13,11 +13,12 @@ let self.vuizvui = pkgs.recurseIntoAttrs { mkChannel = callPackage ./build-support/channel.nix { }; buildSandbox = callPackage build-support/build-sandbox {}; + autoPatchelfHook = callPackage build-support/auto-patchelf {}; list-gamecontrollers = callPackage ./list-gamecontrollers { }; games = import ./games { - inherit pkgs; + pkgs = pkgs // self.vuizvui; config = pkgs.config.vuizvui.games or null; }; diff --git a/pkgs/games/build-support/build-game.nix b/pkgs/games/build-support/build-game.nix index b04309a5..e4d019af 100644 --- a/pkgs/games/build-support/build-game.nix +++ b/pkgs/games/build-support/build-game.nix @@ -1,4 +1,4 @@ -{ stdenv, lib, file, unzip, buildSandbox +{ stdenv, lib, file, unzip, buildSandbox, autoPatchelfHook , withPulseAudio ? true, libpulseaudio ? null , alsaLib @@ -19,9 +19,7 @@ assert withPulseAudio -> libpulseaudio != null; buildSandbox (stdenv.mkDerivation ({ buildInputs = [ stdenv.cc.cc ] ++ buildInputs; - nativeBuildInputs = [ - unzip file ./setup-hooks/auto-patchelf.sh - ] ++ nativeBuildInputs; + nativeBuildInputs = [ unzip autoPatchelfHook ] ++ nativeBuildInputs; preUnpack = preUnpack + '' mkdir "$name" diff --git a/pkgs/games/build-support/default.nix b/pkgs/games/build-support/default.nix index e739c25f..8e227afc 100644 --- a/pkgs/games/build-support/default.nix +++ b/pkgs/games/build-support/default.nix @@ -4,7 +4,5 @@ buildGame = callPackage ./build-game.nix { withPulseAudio = config.pulseaudio or true; }; - # XXX: Pass through from parent scope! - buildSandbox = callPackage ../../build-support/build-sandbox {}; buildUnity = callPackage ./build-unity.nix {}; } |