Skip to content

Commit

Permalink
check-meta: add allowUnfreeLicensePredicate to accept specific unfree…
Browse files Browse the repository at this point in the history
… licenses
  • Loading branch information
Pandapip1 committed Jan 3, 2025
1 parent b31a926 commit e7e6966
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pkgs/stdenv/generic/check-meta.nix
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,30 @@ let
# }
allowUnfreePredicate = config.allowUnfreePredicate or (x: false);

# Allow granular checks to allow only some unfree licenses
# Example:
# { ... }:
# {
# allowUnfree = false;
# allowUnfreeLicensePredicate = (license: licenses.faircode or false);
# }
allowUnfreeLicensePredicate = config.allowUnfreeLicensePredicate or (x: false);

# Check whether unfree packages are allowed and if not, whether the
# package has an unfree license and is not explicitly allowed by the
# `allowUnfreePredicate` function.
hasDeniedUnfreeLicense = attrs:
hasUnfreeLicense attrs &&
!allowUnfree &&
!allowUnfreePredicate attrs;
!allowUnfreePredicate attrs
&& (
if isAttrs attrs.meta.license then
!allowUnfreeLicensePredicate attrs.meta.license
else if isString attrs.meta.license then
!allowUnfreeLicensePredicate { free = false; shortName = attrs.meta.license; }
else
any (license: !allowUnfreeLicensePredicate license) attrs.meta.license
);

allowInsecureDefaultPredicate = x: builtins.elem (getNameWithVersion x) (config.permittedInsecurePackages or []);
allowInsecurePredicate = x: (config.allowInsecurePredicate or allowInsecureDefaultPredicate) x;
Expand Down

0 comments on commit e7e6966

Please sign in to comment.