core/lib/tests/modules/declare-mkPackageOption.nix

50 lines
1.3 KiB
Nix
Raw Normal View History

2024-06-30 08:16:52 +00:00
{ lib, ... }:
let
2024-05-01 22:14:04 +00:00
pkgs.hello = {
type = "derivation";
pname = "hello";
};
2024-06-30 08:16:52 +00:00
in
{
2024-05-01 22:14:04 +00:00
options = {
package = lib.mkPackageOption pkgs "hello" { };
2024-06-30 08:16:52 +00:00
namedPackage = lib.mkPackageOption pkgs "Hello" { default = [ "hello" ]; };
2024-05-01 22:14:04 +00:00
2024-06-30 08:16:52 +00:00
namedPackageSingletonDefault = lib.mkPackageOption pkgs "Hello" { default = "hello"; };
2024-05-01 22:14:04 +00:00
pathPackage = lib.mkPackageOption pkgs [ "hello" ] { };
packageWithExample = lib.mkPackageOption pkgs "hello" {
example = "pkgs.hello.override { stdenv = pkgs.clangStdenv; }";
};
2024-06-30 08:16:52 +00:00
packageWithPathExample = lib.mkPackageOption pkgs "hello" { example = [ "hello" ]; };
2024-05-01 22:14:04 +00:00
packageWithExtraDescription = lib.mkPackageOption pkgs "hello" {
extraDescription = "Example extra description.";
};
2024-06-30 08:16:52 +00:00
undefinedPackage = lib.mkPackageOption pkgs "hello" { default = null; };
2024-05-01 22:14:04 +00:00
nullablePackage = lib.mkPackageOption pkgs "hello" {
nullable = true;
default = null;
};
2024-06-30 08:16:52 +00:00
nullablePackageWithDefault = lib.mkPackageOption pkgs "hello" { nullable = true; };
2024-05-01 22:14:04 +00:00
2024-06-30 08:16:52 +00:00
packageWithPkgsText = lib.mkPackageOption pkgs "hello" { pkgsText = "myPkgs"; };
2024-05-01 22:14:04 +00:00
2024-06-30 08:16:52 +00:00
packageFromOtherSet =
let
myPkgs = {
hello = pkgs.hello // {
pname = "hello-other";
};
};
in
lib.mkPackageOption myPkgs "hello" { };
2024-05-01 22:14:04 +00:00
};
}