diff --git a/modules/common/default.nix b/modules/common/default.nix new file mode 100644 index 0000000..d0c90de --- /dev/null +++ b/modules/common/default.nix @@ -0,0 +1,31 @@ +# Modules that are common to various module systems +# Usually with very small differences, if any, between them. +{ lib, type ? null, ... }: +let + allowedTypes = [ + "nixos" + "home" + "darwin" + ]; + + allowedTypesString = lib.concatStringSep ", " (builtins.map lib.escapeNixString allowedTypes); +in +{ + config = { + assertions = [ + { + assertion = type != null; + message = '' + You must provide `type` as part of specialArgs to use the common modules. + It must be one of ${allowedTypesString}. + ''; + } + { + assertion = type != null -> builtins.elem type allowedTypes; + message = '' + `type` specialArgs must be one of ${allowedTypesString}. + ''; + } + ]; + }; +}