diff --git a/nixos_start.sh b/nixos_start.sh new file mode 100755 index 00000000..b42bfb67 --- /dev/null +++ b/nixos_start.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +RC='\033[0m' +RED='\033[0;31m' + +temp_file=$1 + +# Function to check command exit status and print error message if failed +check() { + local exit_code=$1 + local message=$2 + + if [ $exit_code -ne 0 ]; then + echo -e "${RED}ERROR: $message${RC}" + exit 1 + fi +} + +# Use patchelf to execute linutil on NixOS +nix-shell -p patchelf -p glibc --run " +patchelf --set-interpreter $(nix-build --no-out-link '' -A glibc)/lib/ld-linux-x86-64.so.2 --set-rpath /run/current-system/sw/lib $temp_file +" +check $? "Patching linutil" + +$temp_file +check $? "Executing linutil" diff --git a/start.sh b/start.sh index 2590d9d3..863ffd66 100755 --- a/start.sh +++ b/start.sh @@ -27,8 +27,14 @@ check $? "Downloading linutil" chmod +x "$temp_file" check $? "Making linutil executable" -"$temp_file" -check $? "Executing linutil" +#if the script is being run on NixOS +if [ -f /etc/NIXOS ]; then + ./nixos_start.sh "$temp_file" + check $? "Executing linutil on NixOS" +else + "$temp_file" + check $? "Executing linutil" +fi rm -f "$temp_file" check $? "Deleting the temporary file"