Skip to content

Commit

Permalink
replace "path:" with "./"
Browse files Browse the repository at this point in the history
on newer nix versions (> 2.18) the "path:" settings
will lead to evaluation errors when the flake uses
symbolic links.

a typical error message would be:

`error: access to absolute path '/lib' is forbidden in pure evaluation
mode (use '--impure' to override)`

when `/lib` actually is `./lib`.

When "path:" is replaced by just using the flake's path
no evaluation error is shown. As per the man page of `nix flake`
the "path" attribute reffers to the local path of the flake.

This can just be removed (AFAIK) by referencing to the path as a
positional argument.

Possible related issues:
NixOS/nix#11030
original PR introducing the error message NixOS/nix#9497

Signed-off-by: Florian Brandes <[email protected]>
  • Loading branch information
gador committed Oct 26, 2024
1 parent 4123ae5 commit 59d0795
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bento
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ FLAKES=$(
for flakes in $(find . -name flake.nix)
do
TARGET="$(dirname "${flakes}")"
nix flake show --json "path:$TARGET" | jq -r '.nixosConfigurations | keys[]'
nix flake show --json "./$TARGET" | jq -r '.nixosConfigurations | keys[]'
done
)

Expand All @@ -649,7 +649,7 @@ else
for flakes in $(find . -name flake.nix)
do
TARGET="$(dirname $flakes)"
FLAKES_IN_DIR=$(nix flake show --json "path:$TARGET" | jq -r '.nixosConfigurations | keys[]')
FLAKES_IN_DIR=$(nix flake show --json "./$TARGET" | jq -r '.nixosConfigurations | keys[]')
if echo "${FLAKES_IN_DIR}" | grep "^${NAME}$" >/dev/null
then
# we need to keep the flake directory path
Expand Down Expand Up @@ -705,7 +705,7 @@ then
test -d "$i" || continue
if [ -f "$i/flake.nix" ]
then
for host in $(nix flake show --json "path:${i}" | jq -r '.nixosConfigurations | keys[]')
for host in $(nix flake show --json "./${i}" | jq -r '.nixosConfigurations | keys[]')
do
test -n "${SINGLE_FLAKE}" && ! [ "$host" = "${SINGLE_FLAKE}" ] && continue
printf "%${PRETTY_OUT_COLUMN}s " "${host}"
Expand Down Expand Up @@ -749,7 +749,7 @@ then
do
if [ -f "$i/flake.nix" ]
then
for host in $(nix flake show --json "path:${i}" | jq -r '.nixosConfigurations | keys[]')
for host in $(nix flake show --json "./${i}" | jq -r '.nixosConfigurations | keys[]')
do
test -n "${SINGLE_FLAKE}" && ! [ "$host" = "${SINGLE_FLAKE}" ] && continue
deploy_files "$i" "${host}" "${host}"
Expand Down Expand Up @@ -785,7 +785,7 @@ then
echo "$directory"
if [ -z "$2" ]
then
nix flake update path:"$directory"
nix flake update ./"$directory"
else
cd "$directory" >/dev/null || exit 5
nix flake lock --update-input "$2"
Expand Down

0 comments on commit 59d0795

Please sign in to comment.