krops: enable evaluating nodes with non-native systems

This commit is contained in:
Erik Arvstedt 2022-07-17 10:33:23 +02:00
parent fe2df830a2
commit 2926fc27dc
No known key found for this signature in database
GPG key ID: 33312B944DD97846
2 changed files with 35 additions and 3 deletions

View file

@ -109,11 +109,25 @@ pkgs.stdenv.mkDerivation {
$(nix-build --no-out-link "${cfgDir}/krops/deploy.nix")
)}
eval-config() {
eval-config() {(
set -euo pipefail
system=$(getNodeSystem)
NIXOS_CONFIG="${cfgDir}/krops/krops-configuration.nix" \
nix-instantiate --eval ${nixpkgs}/nixos -A system.outPath | tr -d '"'
nix-instantiate --eval ${nixpkgs}/nixos $system -A system.outPath | tr -d '"'
echo
}
)}
getNodeSystem() {
if [[ -e '${cfgDir}/krops/system' ]]; then
echo -n "--argstr system "; cat '${cfgDir}/krops/system'
elif [[ $OSTYPE == darwin* ]]; then
# On macOS, `builtins.currentSystem` (`*-darwin`) can never equal
# the node system (`*-linux`), so we can always provide a helpful error message:
>&2 echo "Error, node system not set. See here how to fix this:"
>&2 echo "https://github.com/fort-nix/nix-bitcoin/blob/master/docs/install.md#optional-specify-the-system-of-your-node"
return 1
fi
};
pidClosure() {
echo "$1"