2020-10-18 04:41:57 -07:00
|
|
|
#!/usr/bin/env bash
|
2022-08-16 12:00:00 -07:00
|
|
|
set -euo pipefail
|
2020-10-18 04:41:57 -07:00
|
|
|
|
2021-09-23 07:51:34 -07:00
|
|
|
if [[ ! -v NIX_BITCOIN_EXAMPLES_DIR ]]; then
|
|
|
|
echo "Running script in nix shell env..."
|
|
|
|
cd "${BASH_SOURCE[0]%/*}"
|
|
|
|
exec nix-shell --run "./${BASH_SOURCE[0]##*/} $*"
|
|
|
|
else
|
|
|
|
cd "$NIX_BITCOIN_EXAMPLES_DIR"
|
|
|
|
fi
|
|
|
|
|
|
|
|
tmpDir=$(mktemp -d /tmp/nix-bitcoin-minimal-container.XXX)
|
2022-08-16 12:00:00 -07:00
|
|
|
trap 'rm -rf $tmpDir' EXIT
|
2021-09-23 07:51:34 -07:00
|
|
|
|
|
|
|
# Modify importable-configuration.nix to use the local <nix-bitcoin>
|
|
|
|
# source instead of fetchTarball
|
|
|
|
<importable-configuration.nix sed '
|
|
|
|
s|nix-bitcoin = .*|nix-bitcoin = toString <nix-bitcoin>;|;
|
|
|
|
s|system.extraDependencies = .*||
|
2022-08-16 12:00:00 -07:00
|
|
|
' > "$tmpDir/importable-configuration.nix"
|
2021-09-23 07:51:34 -07:00
|
|
|
|
2022-08-16 12:00:00 -07:00
|
|
|
cat > "$tmpDir/configuration.nix" <<EOF
|
2021-09-23 07:51:34 -07:00
|
|
|
{
|
|
|
|
imports = [ $tmpDir/importable-configuration.nix ];
|
|
|
|
users.users.main = {
|
|
|
|
isNormalUser = true;
|
|
|
|
password = "a";
|
|
|
|
};
|
|
|
|
# When WAN is disabled, DNS bootstrapping slows down service startup by ~15 s
|
|
|
|
services.clightning.extraConfig = "disable-dns";
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2022-08-16 12:00:00 -07:00
|
|
|
"${BASH_SOURCE[0]%/*}/deploy-container.sh" "$tmpDir/configuration.nix" "$@"
|