Loading lib/licenses.nix +6 −0 Original line number Diff line number Diff line Loading @@ -618,6 +618,12 @@ in mkLicense lset) ({ fullName = "Licence Art Libre 1.3"; }; lens = { fullName = "Lens Terms of Service Agreement"; url = "https://k8slens.dev/licenses/tos"; free = false; }; lgpl2Only = { spdxId = "LGPL-2.0-only"; fullName = "GNU Library General Public License v2 only"; Loading lib/options.nix +14 −7 Original line number Diff line number Diff line Loading @@ -155,6 +155,8 @@ rec { # Name for the package, shown in option description name: { # Whether the package can be null, for example to disable installing a package altogether. nullable ? false, # The attribute path where the default package is located (may be omitted) default ? name, # A string or an attribute path to use as an example (may be omitted) Loading @@ -164,19 +166,24 @@ rec { }: let name' = if isList name then last name else name; in mkOption ({ type = with lib.types; (if nullable then nullOr else lib.id) package; description = "The ${name'} package to use." + (if extraDescription == "" then "" else " ") + extraDescription; } // (if default != null then let default' = if isList default then default else [ default ]; defaultPath = concatStringsSep "." default'; defaultValue = attrByPath default' (throw "${defaultPath} cannot be found in pkgs") pkgs; in mkOption { in { default = defaultValue; defaultText = literalExpression ("pkgs." + defaultPath); type = lib.types.package; description = "The ${name'} package to use." + (if extraDescription == "" then "" else " ") + extraDescription; ${if default != null then "default" else null} = defaultValue; ${if example != null then "example" else null} = literalExpression } else if nullable then { default = null; } else { }) // lib.optionalAttrs (example != null) { example = literalExpression (if isList example then "pkgs." + concatStringsSep "." example else example); }; }); /* Like mkPackageOption, but emit an mdDoc description instead of DocBook. */ mkPackageOptionMD = pkgs: name: extra: Loading lib/tests/modules.sh +5 −0 Original line number Diff line number Diff line Loading @@ -182,6 +182,11 @@ checkConfigOutput '^true$' config.enableAlias ./alias-with-priority.nix checkConfigOutput '^false$' config.enable ./alias-with-priority-can-override.nix checkConfigOutput '^false$' config.enableAlias ./alias-with-priority-can-override.nix # Check mkPackageOption checkConfigOutput '^"hello"$' config.package.pname ./declare-mkPackageOption.nix checkConfigError 'The option .undefinedPackage. is used but not defined' config.undefinedPackage ./declare-mkPackageOption.nix checkConfigOutput '^null$' config.nullablePackage ./declare-mkPackageOption.nix # submoduleWith ## specialArgs should work Loading lib/tests/modules/declare-mkPackageOption.nix 0 → 100644 +19 −0 Original line number Diff line number Diff line { lib, ... }: let pkgs.hello = { type = "derivation"; pname = "hello"; }; in { options = { package = lib.mkPackageOption pkgs "hello" { }; undefinedPackage = lib.mkPackageOption pkgs "hello" { default = null; }; nullablePackage = lib.mkPackageOption pkgs "hello" { nullable = true; default = null; }; }; } maintainers/maintainer-list.nix +12 −0 Original line number Diff line number Diff line Loading @@ -1951,6 +1951,12 @@ githubId = 75972; name = "Ben Booth"; }; benwis = { name = "Ben Wishovich"; email = "ben@benw.is"; github = "benwis"; githubId = 6953353; }; berberman = { email = "berberman@yandex.com"; matrix = "@berberman:mozilla.org"; Loading Loading @@ -2676,6 +2682,12 @@ } ]; }; Ch1keen = { email = "gihoong7@gmail.com"; github = "Ch1keen"; githubId = 40013212; name = "Han Jeongjun"; }; chaduffy = { email = "charles@dyfis.net"; github = "charles-dyfis-net"; Loading Loading
lib/licenses.nix +6 −0 Original line number Diff line number Diff line Loading @@ -618,6 +618,12 @@ in mkLicense lset) ({ fullName = "Licence Art Libre 1.3"; }; lens = { fullName = "Lens Terms of Service Agreement"; url = "https://k8slens.dev/licenses/tos"; free = false; }; lgpl2Only = { spdxId = "LGPL-2.0-only"; fullName = "GNU Library General Public License v2 only"; Loading
lib/options.nix +14 −7 Original line number Diff line number Diff line Loading @@ -155,6 +155,8 @@ rec { # Name for the package, shown in option description name: { # Whether the package can be null, for example to disable installing a package altogether. nullable ? false, # The attribute path where the default package is located (may be omitted) default ? name, # A string or an attribute path to use as an example (may be omitted) Loading @@ -164,19 +166,24 @@ rec { }: let name' = if isList name then last name else name; in mkOption ({ type = with lib.types; (if nullable then nullOr else lib.id) package; description = "The ${name'} package to use." + (if extraDescription == "" then "" else " ") + extraDescription; } // (if default != null then let default' = if isList default then default else [ default ]; defaultPath = concatStringsSep "." default'; defaultValue = attrByPath default' (throw "${defaultPath} cannot be found in pkgs") pkgs; in mkOption { in { default = defaultValue; defaultText = literalExpression ("pkgs." + defaultPath); type = lib.types.package; description = "The ${name'} package to use." + (if extraDescription == "" then "" else " ") + extraDescription; ${if default != null then "default" else null} = defaultValue; ${if example != null then "example" else null} = literalExpression } else if nullable then { default = null; } else { }) // lib.optionalAttrs (example != null) { example = literalExpression (if isList example then "pkgs." + concatStringsSep "." example else example); }; }); /* Like mkPackageOption, but emit an mdDoc description instead of DocBook. */ mkPackageOptionMD = pkgs: name: extra: Loading
lib/tests/modules.sh +5 −0 Original line number Diff line number Diff line Loading @@ -182,6 +182,11 @@ checkConfigOutput '^true$' config.enableAlias ./alias-with-priority.nix checkConfigOutput '^false$' config.enable ./alias-with-priority-can-override.nix checkConfigOutput '^false$' config.enableAlias ./alias-with-priority-can-override.nix # Check mkPackageOption checkConfigOutput '^"hello"$' config.package.pname ./declare-mkPackageOption.nix checkConfigError 'The option .undefinedPackage. is used but not defined' config.undefinedPackage ./declare-mkPackageOption.nix checkConfigOutput '^null$' config.nullablePackage ./declare-mkPackageOption.nix # submoduleWith ## specialArgs should work Loading
lib/tests/modules/declare-mkPackageOption.nix 0 → 100644 +19 −0 Original line number Diff line number Diff line { lib, ... }: let pkgs.hello = { type = "derivation"; pname = "hello"; }; in { options = { package = lib.mkPackageOption pkgs "hello" { }; undefinedPackage = lib.mkPackageOption pkgs "hello" { default = null; }; nullablePackage = lib.mkPackageOption pkgs "hello" { nullable = true; default = null; }; }; }
maintainers/maintainer-list.nix +12 −0 Original line number Diff line number Diff line Loading @@ -1951,6 +1951,12 @@ githubId = 75972; name = "Ben Booth"; }; benwis = { name = "Ben Wishovich"; email = "ben@benw.is"; github = "benwis"; githubId = 6953353; }; berberman = { email = "berberman@yandex.com"; matrix = "@berberman:mozilla.org"; Loading Loading @@ -2676,6 +2682,12 @@ } ]; }; Ch1keen = { email = "gihoong7@gmail.com"; github = "Ch1keen"; githubId = 40013212; name = "Han Jeongjun"; }; chaduffy = { email = "charles@dyfis.net"; github = "charles-dyfis-net"; Loading