evaluateProperty
lib.licenses.evaluateProperty
Docs pulled from | This Revision | 31 minutes ago
Nixpkgs manual
Evaluate a license expression for a given predicate.
Example
evaluateProperty (x: x.free) true (with lib.licenses; AND [ ncsa (WITH asl20 llvm-exception) ])
Type
evaluateProperty :: Function -> Bool -> AttrSet -> Bool
Arguments
- [predicate] checks for each license included in the license expression
- [permissive] whether to apply checks permissive or reciprocal
- [license] license expression to check
Noogle detected
Implementation
The following is the current implementation of this function.
evaluateProperty =
predicate: permissive: license:
let
OR = if permissive then lib.any else lib.all;
AND = if permissive then lib.all else lib.any;
in
if license.licenseType == "simple" then
predicate license
else if license.licenseType == "compound" then
if license.operator == "OR" then
OR (x: evaluateProperty predicate permissive x) license.licenses
else if license.operator == "AND" then
AND (x: evaluateProperty predicate permissive x) license.licenses
else
throw "Unknown license operator"
else if license.licenseType == "exception" then
AND (x: evaluateProperty predicate permissive x) [
license.license
license.exception
]
else if license.licenseType == "plus" then
evaluateProperty predicate permissive license.license
else
throw "Unknown license type or legacy license";