diff options
| -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 { |
