From ba2dc2e941fe3170ccd85d319982d48d78081177 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 24 Nov 2026 01:04:04 +0000 Subject: populate lib: name the source whose type can't be determined, and why --- pkgs/populate/lib/types/populate.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkgs/populate/lib/types/populate.nix b/pkgs/populate/lib/types/populate.nix index eeb4a84..e5de33f 100644 --- a/pkgs/populate/lib/types/populate.nix +++ b/pkgs/populate/lib/types/populate.nix @@ -1,14 +1,18 @@ { lib }: rec { - source = lib.types.submodule ({ config, ... }: { + source = lib.types.submodule ({ config, name, ... }: { options = { type = let known-types = lib.attrNames source-types; type-candidates = lib.filter (k: config.${k} != null) known-types; in lib.mkOption { - default = if lib.length type-candidates == 1 - then lib.head type-candidates - else throw "cannot determine type"; + default = + if lib.length type-candidates == 1 then + lib.head type-candidates + else if type-candidates != [] then + throw "populate: source ${name} has more than one type: ${lib.concatStringsSep ", " type-candidates}" + else + throw "populate: source ${name} has no type; set one of ${lib.concatStringsSep ", " known-types}"; type = lib.types.enum known-types; }; derivation = lib.mkOption { -- cgit v1.3.1