Skip to content

Commit

Permalink
Merge pull request rapenne-s#11 from gador/fix-states
Browse files Browse the repository at this point in the history
also update states.txt in case we use "dry-build"
  • Loading branch information
rapenne-s authored May 27, 2024
2 parents 6418bd6 + c6c481a commit 4123ae5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bento
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,20 @@ build_config()
sed -i "/^${NAME}/d" "$OLDPWD/../states.txt" >/dev/null
echo "${NAME}=${VERSION}" >> "$OLDPWD/../states.txt"
fi
if [ -f "flake.nix" ] && [ "${COMMAND}" = "dry-build" ]
then
# dry-build doesn't create a result link
# redirect stderr of nixos-rebuild and grep for system config
# this should be a fast and inexpensive operation, so we can run it again here
VERSION="$($SUDO nixos-rebuild dry-build --flake ".#${NAME}" 2>&1 >/dev/null | grep "nixos-system-${NAME}" | tr -d '\n' | sed 's,/nix/store/,,' | sed 's,.drv,,')"
if [ ! -z "VERSION" ]
then
touch "${OLDPWD}/../states.txt"
printf " %s" "${VERSION}"
sed -i "/^${NAME}/d" "$OLDPWD/../states.txt" >/dev/null
echo "${NAME}=${VERSION}" >> "$OLDPWD/../states.txt"
fi
fi
echo ""

cd - >/dev/null || exit 5
Expand Down

0 comments on commit 4123ae5

Please sign in to comment.