forked from DGNum/infrastructure
57 lines
1.5 KiB
Bash
Executable file
57 lines
1.5 KiB
Bash
Executable file
# SPDX-FileCopyrightText: 2024 Ryan Lahfa <ryan.lahfa@dgnum.eu>
|
|
# SPDX-FileCopyrightText: 2024 Tom Hubrecht <tom.hubrecht@dgnum.eu>
|
|
#
|
|
# SPDX-License-Identifier: EUPL-1.2
|
|
|
|
set -o errexit
|
|
set -o nounset
|
|
set -o pipefail
|
|
shopt -s lastpipe
|
|
|
|
# Remove the `nixpkgs=` default input.
|
|
export NIX_PATH="nixpkgs="
|
|
|
|
system_type="$(colmena eval -E "{ nodes, ... }: nodes.${BUILD_NODE}.config.deployment.systemType" --show-trace)"
|
|
# Get rid of surrounding quotes.
|
|
system_type="${system_type%\"}"
|
|
system_type="${system_type#\"}"
|
|
|
|
case "$system_type" in
|
|
nixos)
|
|
toplevel_path="config.system.build.toplevel"
|
|
;;
|
|
zyxel-nwa50ax)
|
|
toplevel_path="config.system.outputs.zyxel-nwa-fit"
|
|
;;
|
|
netconf)
|
|
toplevel_path="config.netconf.rpc"
|
|
;;
|
|
*)
|
|
echo "Unsupported system type '$system_type' for caching; add an entry in 'scripts/cache-node.sh'"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
drv=$(colmena eval --instantiate -E "{ nodes, ... }: nodes.${BUILD_NODE}.${toplevel_path}" --show-trace)
|
|
|
|
# Build the derivation and send it to the great beyond
|
|
nix-store --query --requisites --force-realise --include-outputs "$drv" | grep -v '.*\.drv' >paths.txt
|
|
|
|
if [ "$STORE_PASSWORD" == "" ]; then
|
|
echo "No password given for the remote cache, uploading cannot take place."
|
|
exit 0
|
|
fi
|
|
|
|
cat <<EOF >.netrc
|
|
default
|
|
login $STORE_USER
|
|
password $STORE_PASSWORD
|
|
EOF
|
|
|
|
nix copy \
|
|
--extra-experimental-features nix-command \
|
|
--to "$STORE_ENDPOINT?compression=none" \
|
|
--netrc-file .netrc \
|
|
"$(nix-store --realise "$drv")"
|
|
|
|
rm .netrc
|