Skip to content

Commit 1d85672

Browse files
authored
Add readlink check (#44)
1 parent 071610a commit 1d85672

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

deploy_nixos/nixos-instantiate.sh

+13-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,19 @@ command=(nix-instantiate --show-trace --expr '
2121
inherit (builtins) currentSystem;
2222
}')
2323

24+
if readlink --version | grep GNU; then
25+
readlink="readlink -f"
26+
else
27+
if command -v greadlink &> /dev/null; then
28+
readlink="greadlink -f"
29+
else
30+
echo "Warning: symlinks not supported because readlink is non GNU" >&2
31+
readlink="realpath"
32+
fi
33+
fi
34+
2435
if [[ -f "$config" ]]; then
25-
config=$(readlink -f "$config")
36+
config=$($readlink "$config")
2637
command+=(--argstr configuration "$config")
2738
else
2839
command+=(--arg configuration "$config")
@@ -37,7 +48,7 @@ if [[ -n "$nix_path" && "$nix_path" != "-" ]]; then
3748
fi
3849

3950
# Changing directory
40-
cd "$(readlink -f "$config_pwd")"
51+
cd "$($readlink "$config_pwd")"
4152

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

0 commit comments

Comments
 (0)