nixos start.sh fix

This commit is contained in:
guruswarupa 2024-07-24 17:12:45 +05:30
parent c995b8deaf
commit 6d1baccca1
2 changed files with 34 additions and 2 deletions

26
nixos_start.sh Executable file
View File

@ -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 '<nixpkgs>' -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"

View File

@ -27,8 +27,14 @@ check $? "Downloading linutil"
chmod +x "$temp_file" chmod +x "$temp_file"
check $? "Making linutil executable" check $? "Making linutil executable"
"$temp_file" #if the script is being run on NixOS
check $? "Executing linutil" 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" rm -f "$temp_file"
check $? "Deleting the temporary file" check $? "Deleting the temporary file"