Skip to content

Commit

Permalink
also update states.txt in case we use "dry-build"
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Brandes <[email protected]>
  • Loading branch information
gador committed May 26, 2024
1 parent 6418bd6 commit c6c481a
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 c6c481a

Please sign in to comment.