about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorJanne Heß <janne@hess.ooo>2021-12-05 18:54:36 +0100
committerJanne Heß <janne@hess.ooo>2021-12-05 18:54:36 +0100
commitb30d6193684bf810ece401085f3442523f368bde (patch)
treed2e0450b6188a358def3753176e6695963782f4f /nixos
parent6f1e0dc34f726dafade492a3db102467fe2032d4 (diff)
nixos/top-level: Check syntax of switch-to-configuration
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/system/activation/top-level.nix7
1 files changed, 7 insertions, 0 deletions
diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix
index b04577aeb83e4..8266622e78dfd 100644
--- a/nixos/modules/system/activation/top-level.nix
+++ b/nixos/modules/system/activation/top-level.nix
@@ -78,6 +78,13 @@ let
       export localeArchive="${config.i18n.glibcLocales}/lib/locale/locale-archive"
       substituteAll ${./switch-to-configuration.pl} $out/bin/switch-to-configuration
       chmod +x $out/bin/switch-to-configuration
+      ${optionalString (pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform) ''
+        if ! output=$($perl/bin/perl -c $out/bin/switch-to-configuration 2>&1); then
+          echo "switch-to-configuration syntax is not valid:"
+          echo "$output"
+          exit 1
+        fi
+      ''}
 
       echo -n "${toString config.system.extraDependencies}" > $out/extra-dependencies