lib/tests: add more tests for mkPackageOption
This commit is contained in:
@@ -227,8 +227,14 @@ checkConfigOutput '^false$' config.enableAlias ./alias-with-priority-can-overrid
|
|||||||
|
|
||||||
# Check mkPackageOption
|
# Check mkPackageOption
|
||||||
checkConfigOutput '^"hello"$' config.package.pname ./declare-mkPackageOption.nix
|
checkConfigOutput '^"hello"$' config.package.pname ./declare-mkPackageOption.nix
|
||||||
|
checkConfigOutput '^"hello"$' config.namedPackage.pname ./declare-mkPackageOption.nix
|
||||||
|
checkConfigOutput '^".*Hello.*"$' options.namedPackage.description ./declare-mkPackageOption.nix
|
||||||
|
checkConfigOutput '^"hello"$' config.pathPackage.pname ./declare-mkPackageOption.nix
|
||||||
|
checkConfigOutput '^"pkgs\.hello\.override \{ stdenv = pkgs\.clangStdenv; \}"$' options.packageWithExample.example.text ./declare-mkPackageOption.nix
|
||||||
|
checkConfigOutput '^".*Example extra description\..*"$' options.packageWithExtraDescription.description ./declare-mkPackageOption.nix
|
||||||
checkConfigError 'The option .undefinedPackage. is used but not defined' config.undefinedPackage ./declare-mkPackageOption.nix
|
checkConfigError 'The option .undefinedPackage. is used but not defined' config.undefinedPackage ./declare-mkPackageOption.nix
|
||||||
checkConfigOutput '^null$' config.nullablePackage ./declare-mkPackageOption.nix
|
checkConfigOutput '^null$' config.nullablePackage ./declare-mkPackageOption.nix
|
||||||
|
checkConfigOutput '^"null or package"$' options.nullablePackageWithDefault.type.description ./declare-mkPackageOption.nix
|
||||||
|
|
||||||
# submoduleWith
|
# submoduleWith
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,28 @@ in {
|
|||||||
options = {
|
options = {
|
||||||
package = lib.mkPackageOption pkgs "hello" { };
|
package = lib.mkPackageOption pkgs "hello" { };
|
||||||
|
|
||||||
|
namedPackage = lib.mkPackageOption pkgs "Hello" {
|
||||||
|
default = [ "hello" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
namedPackageSingletonDefault = lib.mkPackageOption pkgs "Hello" {
|
||||||
|
default = "hello";
|
||||||
|
};
|
||||||
|
|
||||||
|
pathPackage = lib.mkPackageOption pkgs [ "hello" ] { };
|
||||||
|
|
||||||
|
packageWithExample = lib.mkPackageOption pkgs "hello" {
|
||||||
|
example = "pkgs.hello.override { stdenv = pkgs.clangStdenv; }";
|
||||||
|
};
|
||||||
|
|
||||||
|
packageWithPathExample = lib.mkPackageOption pkgs "hello" {
|
||||||
|
example = [ "hello" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
packageWithExtraDescription = lib.mkPackageOption pkgs "hello" {
|
||||||
|
extraDescription = "Example extra description.";
|
||||||
|
};
|
||||||
|
|
||||||
undefinedPackage = lib.mkPackageOption pkgs "hello" {
|
undefinedPackage = lib.mkPackageOption pkgs "hello" {
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
@@ -15,5 +37,9 @@ in {
|
|||||||
nullable = true;
|
nullable = true;
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nullablePackageWithDefault = lib.mkPackageOption pkgs "hello" {
|
||||||
|
nullable = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user