-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
pkgs/top-level/config.nix: nixfmt, declare options #330753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
philiptaron
merged 11 commits into
NixOS:master
from
eclairevoyant:nixpkgs-declare-options
Aug 5, 2024
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f24c3a7
pkgs/top-level/config.nix: nixfmt-rfc-style
eclairevoyant 1899a02
pkgs/top-level/config.nix: add options.allowNonSource
eclairevoyant 598f225
pkgs/top-level/config.nix: add options.allowUnfreePredicate
eclairevoyant 333370d
pkgs/top-level/config.nix: add options.allowNonSourcePredicate
eclairevoyant 0e7bb49
pkgs/top-level/config.nix: add options.packageOverrides
eclairevoyant 139f904
pkgs/top-level/config.nix: add options.{permittedInsecurePackages,all…
eclairevoyant 36c0423
pkgs/top-level/config.nix: add options.checkMetaRecursively
eclairevoyant d442a38
pkgs/top-level/config.nix: add options.handleEvalIssue
eclairevoyant 1d47396
pkgs/top-level/config.nix: add options.inHydra
eclairevoyant 87e58be
pkgs/top-level/config.nix: add options.{allow,block}listedLicenses
eclairevoyant d65c92e
pkgs/top-level/config.nix: pass nixf-tidy
eclairevoyant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,51 +12,55 @@ let | |
| inherit (lib) | ||
| literalExpression | ||
| mapAttrsToList | ||
| mkEnableOption | ||
| mkOption | ||
| optionals | ||
| types | ||
| ; | ||
|
|
||
| mkMassRebuild = args: mkOption (builtins.removeAttrs args [ "feature" ] // { | ||
| type = args.type or (types.uniq types.bool); | ||
| default = args.default or false; | ||
| description = ((args.description or '' | ||
| Whether to ${args.feature} while building nixpkgs packages. | ||
| '') + '' | ||
| Changing the default may cause a mass rebuild. | ||
| ''); | ||
| }); | ||
| mkMassRebuild = | ||
| args: | ||
| mkOption ( | ||
| builtins.removeAttrs args [ "feature" ] | ||
| // { | ||
| type = args.type or (types.uniq types.bool); | ||
| default = args.default or false; | ||
| description = ( | ||
| (args.description or '' | ||
| Whether to ${args.feature} while building nixpkgs packages. | ||
| '' | ||
| ) | ||
| + '' | ||
| Changing the default may cause a mass rebuild. | ||
| '' | ||
| ); | ||
| } | ||
| ); | ||
|
|
||
| options = { | ||
|
|
||
| /* Internal stuff */ | ||
| # Internal stuff | ||
|
|
||
| # Hide built-in module system options from docs. | ||
| _module.args = mkOption { | ||
| internal = true; | ||
| }; | ||
| _module.args = mkOption { internal = true; }; | ||
|
|
||
| warnings = mkOption { | ||
| type = types.listOf types.str; | ||
| default = []; | ||
| default = [ ]; | ||
| internal = true; | ||
| }; | ||
|
|
||
| /* Config options */ | ||
| # Config options | ||
|
|
||
| warnUndeclaredOptions = mkOption { | ||
| description = "Whether to warn when `config` contains an unrecognized attribute."; | ||
| type = types.bool; | ||
| default = false; | ||
| }; | ||
|
|
||
| doCheckByDefault = mkMassRebuild { | ||
| feature = "run `checkPhase` by default"; | ||
| }; | ||
| doCheckByDefault = mkMassRebuild { feature = "run `checkPhase` by default"; }; | ||
|
|
||
| strictDepsByDefault = mkMassRebuild { | ||
| feature = "set `strictDeps` to true by default"; | ||
| }; | ||
| strictDepsByDefault = mkMassRebuild { feature = "set `strictDeps` to true by default"; }; | ||
|
|
||
| structuredAttrsByDefault = mkMassRebuild { | ||
| feature = "set `__structuredAttrs` to true by default"; | ||
|
|
@@ -104,6 +108,80 @@ let | |
| ''; | ||
| }; | ||
|
|
||
| allowUnfreePredicate = mkOption { | ||
| type = types.functionTo types.bool; | ||
| default = _: false; | ||
| defaultText = literalExpression ''pkg: false''; | ||
| example = literalExpression ''pkg: lib.hasPrefix "vscode" pkg.name''; | ||
| description = '' | ||
| A function that specifies whether a given unfree package may be permitted. | ||
| Only takes effect if [`config.allowUnfree`](#opt-allowUnfree) is set to false. | ||
|
|
||
| See [Installing unfree packages](https://nixos.org/manual/nixpkgs/stable/#sec-allow-unfree) in the NixOS manual. | ||
| ''; | ||
| }; | ||
|
|
||
| allowlistedLicenses = mkOption { | ||
| type = types.listOf (types.lazyAttrsOf types.raw); # list of license attrsets | ||
| default = [ ]; | ||
| example = literalExpression '' | ||
| [ | ||
| lib.licenses.cc-by-nc-sa-20 | ||
| ({ | ||
| spdxId = "Abstyles"; | ||
| fullName = "Abstyles License"; | ||
| }) | ||
| ] | ||
| ''; | ||
| description = '' | ||
| Permits evaluation of a package, if the package: | ||
| * only has free licenses or licenses in this allowlist, and | ||
| * does not fail evaluation for some other reason. | ||
| ''; | ||
| }; | ||
|
|
||
| blocklistedLicenses = mkOption { | ||
| type = types.listOf (types.lazyAttrsOf types.raw); # list of license attrsets | ||
| default = [ ]; | ||
| example = literalExpression '' | ||
| [ | ||
| lib.licenses.cc-by-nc-sa-20 | ||
| ({ | ||
| spdxId = "Abstyles"; | ||
| fullName = "Abstyles License"; | ||
| }) | ||
| ] | ||
| ''; | ||
| description = '' | ||
| Disallows evaluation of a package, if the package has a license in this blocklist. | ||
| ''; | ||
| }; | ||
|
|
||
| allowNonSource = mkEnableOption "" // { | ||
philiptaron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| default = true; | ||
| defaultText = literalExpression ''true && builtins.getEnv "NIXPKGS_ALLOW_NONSOURCE" != "0"''; | ||
philiptaron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| description = '' | ||
| Whether to allow non-source packages. | ||
| Can be combined with `config.allowNonSourcePredicate`. | ||
| ''; | ||
| }; | ||
|
|
||
| allowNonSourcePredicate = mkOption { | ||
| type = types.functionTo types.bool; | ||
| default = _: false; | ||
| defaultText = literalExpression ''pkg: false''; | ||
| example = literalExpression '' | ||
| pkg: | ||
| (lib.all ( | ||
| prov: prov.isSource || prov == lib.sourceTypes.binaryFirmware | ||
| ) pkg.meta.sourceProvenance); | ||
| ''; | ||
| description = '' | ||
| A function that specifies whether a given non-source package may be permitted. | ||
| Only takes effect if [`config.allowNonSource`](#opt-allowNonSource) is set to false. | ||
| ''; | ||
| }; | ||
|
|
||
| allowBroken = mkOption { | ||
| type = types.bool; | ||
| default = false; | ||
|
|
@@ -128,6 +206,33 @@ let | |
| ''; | ||
| }; | ||
|
|
||
| permittedInsecurePackages = mkOption { | ||
| type = types.listOf types.str; | ||
| default = [ ]; | ||
| description = '' | ||
| List of insecure package names that are permitted. | ||
| Only takes effect if [`config.allowInsecurePredicate`](#opt-allowInsecurePredicate) is left as default | ||
| or is written to use the values in this option. | ||
|
|
||
| See [Installing insecure packages](#sec-allow-insecure). | ||
| ''; | ||
| }; | ||
|
|
||
| allowInsecurePredicate = mkOption { | ||
| type = types.functionTo types.bool; | ||
| defaultText = literalExpression '' | ||
| pkg: | ||
| builtins.elem (pkg.name | ||
| or "''${pkg.pname or "«name-missing»"}-''${pkg.version or "«version-missing»"}" | ||
| ) config.permittedInsecurePackages | ||
| ''; | ||
| description = '' | ||
| A function that specifies whether a given insecure package may be permitted. | ||
|
|
||
| See [Installing insecure packages](#sec-allow-insecure). | ||
| ''; | ||
| }; | ||
|
|
||
| cudaSupport = mkMassRebuild { | ||
| type = types.bool; | ||
| default = false; | ||
|
|
@@ -140,9 +245,26 @@ let | |
| feature = "build packages with ROCm support by default"; | ||
| }; | ||
|
|
||
| packageOverrides = mkOption { | ||
|
||
| type = types.functionTo types.raw; | ||
|
||
| default = lib.id; | ||
eclairevoyant marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| defaultText = literalExpression ''lib.id''; | ||
| example = literalExpression '' | ||
| pkgs: rec { | ||
| foo = pkgs.foo.override { /* ... */ }; | ||
| }; | ||
| ''; | ||
| description = '' | ||
| A function that takes the current nixpkgs instance (`pkgs`) as an argument | ||
| and returns a modified set of packages. | ||
|
|
||
| See [Modify packages via `packageOverrides`](#sec-modify-via-packageOverrides). | ||
| ''; | ||
| }; | ||
|
|
||
| showDerivationWarnings = mkOption { | ||
| type = types.listOf (types.enum [ "maintainerless" ]); | ||
| default = []; | ||
| default = [ ]; | ||
| description = '' | ||
| Which warnings to display for potentially dangerous | ||
| or deprecated values passed into `stdenv.mkDerivation`. | ||
|
|
@@ -162,23 +284,48 @@ let | |
| Whether to check that the `meta` attribute of derivations are correct during evaluation time. | ||
| ''; | ||
| }; | ||
|
|
||
| checkMetaRecursively = mkEnableOption "checking that the `meta` attribute of derivations and their references are correct during evalution"; | ||
|
|
||
| handleEvalIssue = mkOption { | ||
| type = types.functionTo (types.functionTo types.bool); | ||
| internal = true; | ||
| description = '' | ||
| Function to handle evaluation errors and possibly output a more informative message. | ||
| ''; | ||
| }; | ||
|
|
||
| inHydra = mkEnableOption "" // { | ||
| internal = true; | ||
| description = '' | ||
| Whether the current nixpkgs instance is being evauluated by Hydra. | ||
| If set to true, evaluation checks will produce less verbose error messages. | ||
| ''; | ||
| }; | ||
| }; | ||
|
|
||
| in { | ||
| in | ||
| { | ||
|
|
||
| freeformType = | ||
| let t = types.lazyAttrsOf types.raw; | ||
| in t // { | ||
| merge = loc: defs: | ||
| let r = t.merge loc defs; | ||
| in r // { _undeclared = r; }; | ||
| let | ||
| t = types.lazyAttrsOf types.raw; | ||
| in | ||
| t | ||
| // { | ||
| merge = | ||
| loc: defs: | ||
| let | ||
| r = t.merge loc defs; | ||
| in | ||
| r // { _undeclared = r; }; | ||
| }; | ||
|
|
||
| inherit options; | ||
|
|
||
| config = { | ||
| warnings = optionals config.warnUndeclaredOptions ( | ||
| mapAttrsToList (k: v: "undeclared Nixpkgs option set: config.${k}") config._undeclared or {} | ||
| mapAttrsToList (k: v: "undeclared Nixpkgs option set: config.${k}") config._undeclared or { } | ||
| ); | ||
| }; | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.