#!/usr/bin/env nix-shell
#!nix-shell -i bash -p licensee jq atool
for p in $@; do
tmp=""
src="$(nix-build -A "$p.src" --no-out-link)"
if [[ $? ]]; then
if [[ ! -d "$src" ]]; then
tmp="$(mktemp -d)" && \
aunpack -X "$tmp" "$src" 2>&1 > /dev/null && \
srcfolders=( "$tmp"/* ) && \
src="${srcfolders[0]}"
fi
license="$(licensee detect --json "$src" | jq -c -M ".licenses[0] | .key")"
nixLicense="$(nix eval "(import ./. {}).$p.meta.license.spdxId")"
echo "$p: $license $nixLicense"
if [[ ! -z "$tmp" ]]; then
rm -rf "$tmp"
fi
fi
done