dotfiles/zsh/zsh_helpers/nixos.sh
2025-04-16 16:58:29 +00:00

23 lines
470 B
Bash
Executable File

#!/bin/bash
prepend_host() {
local path="$1"
if [[ "${path:0:1}" == "/" ]]; then
echo "/host$path"
else
echo "$path"
fi
}
# Process each argument and prepend /host to paths starting with /
for arg in "$@"; do
if [[ "$arg" =~ ^/ ]]; then
ARGUMENTS+=" $(prepend_host "$arg")"
else
ARGUMENTS+=" $arg"
fi
done
# Run Docker container with modified arguments
docker run --rm -it -v /:/host "nixos/nix" $ARGUMENTS