diff options
| author | tv <tv@krebsco.de> | 2026-11-24 01:04:04 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-24 01:04:04 +0000 |
| commit | ba2dc2e941fe3170ccd85d319982d48d78081177 (patch) | |
| tree | d20adab8c07ec92993c2d3ac2f67fbcc276c8b41 /pkgs/populate | |
| parent | ba05ed325bef0cdf8eaad8e0593260cb58cd9a8b (diff) | |
populate lib: name the source whose type can't be determined, and why
Diffstat (limited to 'pkgs/populate')
| -rw-r--r-- | pkgs/populate/lib/types/populate.nix | 12 |
1 files 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 { |
