Skip to content

Commit

Permalink
build: add devbox 0.13.7 (nixpkgs/71a6392)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjgallag committed Dec 17, 2024
1 parent 5defe7c commit 8c1869e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ scripts_dir="${runhub_dir}"/scripts
. "${scripts_dir}"/run-nix-daemon.sh
"${scripts_dir}"/install-upgrade-nix.sh
. "${scripts_dir}"/run-nix-daemon.sh
"${scripts_dir}"/install-upgrade-devbox.sh
3 changes: 3 additions & 0 deletions devbox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.13.7/.schema/devbox.schema.json"
}
49 changes: 49 additions & 0 deletions scripts/install-upgrade-devbox.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh

set -o errexit
set -o nounset

scripts_dir="$(dirname "$0")"

minimum_required_version='0.13.7'
nixpkgs_commit='71a6392e367b08525ee710a93af2e80083b5b3e2'

is_installed_upgraded() {
if command -v devbox >/dev/null; then
installed_version="$(devbox version)"
"${scripts_dir}"/is-version-greater-equal.sh \
"${installed_version}" "${minimum_required_version}"
else
echo 'no'
fi
}

install_upgrade() {
installed_packages="$(nix profile list --json)"

if echo "${installed_packages}" | grep -Eq '"devbox":'; then
nix profile upgrade devbox --override-flake nixpkgs github:NixOS/nixpkgs/"${nixpkgs_commit}"
else
nix profile install nixpkgs#devbox \
--override-flake nixpkgs github:NixOS/nixpkgs/"${nixpkgs_commit}"
fi
}

main() {
. "${scripts_dir}"/run-nix-daemon.sh
is_installed_upgraded="$(is_installed_upgraded)"

if [ "${is_installed_upgraded}" = 'no' ]; then
"${scripts_dir}"/confirm.sh \
'Install/Upgrade Devbox v'"${minimum_required_version}"' with `nix profile`?'
install_upgrade
was_installed_upgraded="$(is_installed_upgraded)"

if [ "${was_installed_upgraded}" = 'no' ]; then
echo 'Devbox v'"${minimum_required_version}"' or higher is required.'
exit 1
fi
fi
}

main "$@"

0 comments on commit 8c1869e

Please sign in to comment.