chromium-nice
1 #!/bin/sh 2 # Wrapper script to launch chromium with nice priority 3 # This only affects chromium instances spawned by our automation code 4 # Uses absolute path for NixOS compatibility 5 # Written in POSIX sh (not bash) so it works with NixOS's /bin/sh stub 6 7 # Ensure standard paths are available (pipeline service has minimal PATH) 8 export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PATH:-}" 9 10 # Get the real chromium path 11 CHROMIUM_BIN="" 12 13 if [ -d "/nix/store" ]; then 14 # NixOS host: find chromium in the nix store 15 # Directories have format: HASH-chromium-VERSION/bin/chromium 16 for dir in /nix/store/*-chromium-*/bin/chromium; do 17 if [ ! -x "$dir" ]; then 18 continue 19 fi 20 # Skip unwrapped and sandbox variants using case (POSIX sh, no bash regex needed) 21 case "$dir" in 22 *unwrapped* | *sandbox*) 23 continue 24 ;; 25 *) 26 CHROMIUM_BIN="$dir" 27 break 28 ;; 29 esac 30 done 31 32 if [ -z "$CHROMIUM_BIN" ] || [ ! -x "$CHROMIUM_BIN" ]; then 33 echo "ERROR: chromium not found in NixOS store at /nix/store/*-chromium-*/bin/chromium" >&2 34 exit 1 35 fi 36 else 37 # Non-NixOS (Docker/Linux): try Playwright's bundled chromium 38 # Playwright bundled binaries won't work on NixOS (glibc linking issue) 39 for dir in "$HOME/.cache/ms-playwright/chromium_headless_shell-"*/chrome-headless-shell-linux64/chrome-headless-shell; do 40 if [ -x "$dir" ]; then 41 CHROMIUM_BIN="$dir" 42 break 43 fi 44 done 45 46 if [ -z "$CHROMIUM_BIN" ] || [ ! -x "$CHROMIUM_BIN" ]; then 47 for dir in "$HOME/.cache/ms-playwright/chromium-"*/chrome-linux64/chrome; do 48 if [ -x "$dir" ]; then 49 CHROMIUM_BIN="$dir" 50 break 51 fi 52 done 53 fi 54 55 if [ -z "$CHROMIUM_BIN" ] || [ ! -x "$CHROMIUM_BIN" ]; then 56 echo "ERROR: chromium not found in Playwright cache at ~/.cache/ms-playwright/" >&2 57 exit 1 58 fi 59 fi 60 61 # Launch chromium with nice priority 19 (lowest priority) 62 exec nice -n 19 "$CHROMIUM_BIN" "$@"