#!/usr/bin/env bash

set -euo pipefail
shopt -s lastpipe

nix-prefetch-url --print-path --type sha256 file://"$PWD/$1" | readarray -t X
hash=${X[0]}
nix_store_path=${X[1]}
nix-store --add-root "./$1.gcroot" --indirect --realise "$nix_store_path"
echo "Hash: $hash"
