From c3428419e05c8e3ef2b722b82b2f7065a6d46441 Mon Sep 17 00:00:00 2001 From: Ingo Blechschmidt Date: Tue, 5 Apr 2022 16:52:09 +0200 Subject: [PATCH] nixos/switch-to-configuration: Provider better error message in cross-compiling situations --- .../system/activation/switch-to-configuration.pl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nixos/modules/system/activation/switch-to-configuration.pl b/nixos/modules/system/activation/switch-to-configuration.pl index 9e5b760434a0..3f0d976e70b8 100755 --- a/nixos/modules/system/activation/switch-to-configuration.pl +++ b/nixos/modules/system/activation/switch-to-configuration.pl @@ -1,5 +1,17 @@ #! @perl@/bin/perl +# Issue #166838 uncovered a situation in which a configuration not suitable +# for the target architecture caused a cryptic error message instead of +# a clean failure. Due to this mismatch, the perl interpreter in the shebang +# line wasn't able to be executed, causing this script to be misinterpreted +# as a shell script. +# +# Let's detect this situation to give a more meaningful error +# message. The following two lines are carefully written to be both valid Perl +# and Bash. +printf "Perl script erroneously interpreted as shell script,\ndoes target platform match nixpkgs.crossSystem platform?\n" && exit 1 + if 0; + use strict; use warnings; use Config::IniFiles;