From 9ccd1c7e23ffb88ced79c76460b0aabc693a2abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Fri, 10 Jan 2025 16:04:40 +0100 Subject: [PATCH] assert submodules are available to Nix derivation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should result in a human-readable error when `?submodules=1#` is not appended to the project URL as the README explains: ``` > nix build '.' error: Unable to build without submodules. Append '?submodules=1#' to the URL. > nix build '.?submodules=1#' ``` Signed-off-by: Jakub SokoĊ‚owski --- nix/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nix/default.nix b/nix/default.nix index 6e61e80c15..97d923987c 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -16,6 +16,10 @@ ], }: +# The 'or' is to handle src fallback to ../. which lack submodules attribue. +assert pkgs.lib.assertMsg ((src.submodules or true) == true) + "Unable to build without submodules. Append '?submodules=1#' to the URI."; + let inherit (pkgs) stdenv lib writeScriptBin callPackage;