shrub/sh/image
Brendan Hay 578adc9363
build: move ops debug conditional usage to drv metadata
Rather than conditional reconstructing the "urbit/bin/urbit-debug -g"
string everytime using the debug conditional, this information has been
added to the derivation's .meta attribute.
2019-10-14 10:25:34 +02:00

31 lines
698 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
say() {
echo "$1" >&2
}
git_sha="$(git rev-parse HEAD)"
git_sha="${git_sha:0:8}"
git_branch="$(git branch --show-current)"
git_tag="${git_branch}-${git_sha}"
say "Building nix/ops/image..."
nix_out="$(nix-build nix/ops -A image --no-out-link "$@")"
say "Loading $nix_out into Docker..."
nix_name="$(docker load --quiet --input $nix_out)"
nix_name="${nix_name#Loaded image: }"
say "Re-tagging with git metadata..."
image_repo="$(docker images $nix_name --format '{{.Repository}}')"
image_name="${image_repo}:${git_tag}"
docker tag $nix_name $image_name
# Output only the new tag on stdout for subsequent pipes/tooling.
say $nix_name
echo $image_name