Skip to content

Commit

Permalink
Add readlink check (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
pingiun committed Mar 10, 2021
1 parent 071610a commit 1d85672
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions deploy_nixos/nixos-instantiate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,19 @@ command=(nix-instantiate --show-trace --expr '
inherit (builtins) currentSystem;
}')

if readlink --version | grep GNU; then
readlink="readlink -f"
else
if command -v greadlink &> /dev/null; then
readlink="greadlink -f"
else
echo "Warning: symlinks not supported because readlink is non GNU" >&2
readlink="realpath"
fi
fi

if [[ -f "$config" ]]; then
config=$(readlink -f "$config")
config=$($readlink "$config")
command+=(--argstr configuration "$config")
else
command+=(--arg configuration "$config")
Expand All @@ -37,7 +48,7 @@ if [[ -n "$nix_path" && "$nix_path" != "-" ]]; then
fi

# Changing directory
cd "$(readlink -f "$config_pwd")"
cd "$($readlink "$config_pwd")"

# Instantiate
echo "running (instantiating): ${NIX_PATH:+NIX_PATH=$NIX_PATH} ${command[*]@Q}" -A out_path >&2
Expand Down

0 comments on commit 1d85672

Please sign in to comment.