From 9996cca17aeb63ed0d51d59d4572dced0b050aee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sun, 4 Dec 2022 21:39:25 +0100 Subject: install.sh: add ability to install non-native architecture The result is that it now requires to be run only on NixOS but that should be fine. --- common.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'common.sh') diff --git a/common.sh b/common.sh index 9b6f48c..d3ddbc3 100644 --- a/common.sh +++ b/common.sh @@ -80,6 +80,10 @@ device_system() { nix eval --raw ".#nixosConfigurations.$1.config.nixpkgs.system" } +build_system() { + nix eval --raw --impure --expr 'builtins.currentSystem' +} + # Validates if link is valid. build_validate() { local device="$1" @@ -93,12 +97,10 @@ build() { local device="$1" shift - local toplevel=".config.system.build.toplevel" - if [ "$(device_system "$device")" = "armv7l-linux" ]; then - toplevel=".config.system.build.cross.x86_64-linux${toplevel}" - fi - if [ "$(device_system "$device")" = "aarch64-linux" ]; then - toplevel=".config.system.build.cross.x86_64-linux${toplevel}" + local toplevel="config.system.build.toplevel" + local bsystem="$(build_system)" + if [ "$bsystem" != "$(device_system "$device")" ]; then + toplevel="config.system.build.cross.$bsystem.$toplevel" fi stage "Building system for device: $device" @@ -106,7 +108,7 @@ build() { -o "$(result "${device}")" \ --keep-going \ "$@" \ - "${0%/*}#nixosConfigurations.${device}${toplevel}" + "${0%/*}#nixosConfigurations.${device}.${toplevel}" } ## Copy NixOS system ########################################################### -- cgit v1.2.3