197197
198198 pos_str = meta : meta . position or "«unknown-file»" ;
199199
200- remediation = {
201- unfree = remediate_allowlist "Unfree" ( remediate_predicate "allowUnfreePredicate" ) ;
202- non-source = remediate_allowlist "NonSource" ( remediate_predicate "allowNonSourcePredicate" ) ;
203- broken = remediate_allowlist "Broken" ( x : "" ) ;
204- unsupported = remediate_allowlist "UnsupportedSystem" ( x : "" ) ;
205- blocklisted = x : "" ;
206- insecure = remediate_insecure ;
207- broken-outputs = remediateOutputsToInstall ;
208- unknown-meta = x : "" ;
209- maintainerless = x : "" ;
210- } ;
211200 remediation_env_var =
212201 allow_attr :
213202 {
317306 {
318307 reason ,
319308 errormsg ? "" ,
309+ remediation ,
320310 } :
321311 let
322312 msg =
327317 Package ‘${ getNameWithVersion attrs } ’ in ${ pos_str meta } ${ errormsg } , refusing to evaluate.
328318
329319 ''
330- + ( builtins . getAttr reason remediation ) attrs ;
320+ + remediation ;
331321
332322 handler = if config ? handleEvalIssue then config . handleEvalIssue reason else throw ;
333323 in
@@ -338,15 +328,15 @@ let
338328 {
339329 reason ,
340330 errormsg ? "" ,
331+ remediation ,
341332 } :
342333 let
343- remediationMsg = ( builtins . getAttr reason remediation ) attrs ;
344334 msg =
345335 if inHydra then
346336 "Warning while evaluating ${ getNameWithVersion attrs } : «${ reason } »: ${ errormsg } "
347337 else
348338 "Package ${ getNameWithVersion attrs } in ${ pos_str meta } ${ errormsg } , continuing anyway."
349- + ( optionalString ( remediationMsg != "" ) "\n ${ remediationMsg } " ) ;
339+ + ( optionalString ( remediation != "" ) "\n ${ remediation } " ) ;
350340 isEnabled = findFirst ( x : x == reason ) null showWarnings ;
351341 in
352342 if isEnabled != null then builtins . trace msg true else true ;
484474 # e.g brokenness or license.
485475 #
486476 # Return { valid: "yes", "warn" or "no" } and additionally
487- # { reason: String; errormsg: String } if it is not valid, where
477+ # { reason: String; errormsg: String, remediation: String } if it is not valid, where
488478 # reason is one of "unfree", "blocklisted", "broken", "insecure", ...
489479 # !!! reason strings are hardcoded into OfBorg, make sure to keep them in sync
490480 # Along with a boolean flag for each reason
506496 valid = "no" ;
507497 reason = "unknown-meta" ;
508498 errormsg = "has an invalid meta attrset:${ concatMapStrings ( x : "\n - " + x ) res } \n " ;
499+ remediation = "" ;
509500 }
510501
511502 # --- Put checks that cannot be ignored here ---
514505 valid = "no" ;
515506 reason = "broken-outputs" ;
516507 errormsg = "has invalid meta.outputsToInstall" ;
508+ remediation = remediateOutputsToInstall attrs ;
517509 }
518510
519511 # --- Put checks that can be ignored here ---
@@ -522,24 +514,28 @@ let
522514 valid = "no" ;
523515 reason = "unfree" ;
524516 errormsg = "has an unfree license (‘${ showLicense attrs . meta . license } ’)" ;
517+ remediation = remediate_allowlist "Unfree" ( remediate_predicate "allowUnfreePredicate" ) attrs ;
525518 }
526519 else if hasBlocklistedLicense attrs then
527520 {
528521 valid = "no" ;
529522 reason = "blocklisted" ;
530523 errormsg = "has a blocklisted license (‘${ showLicense attrs . meta . license } ’)" ;
524+ remediation = "" ;
531525 }
532526 else if hasDeniedNonSourceProvenance attrs then
533527 {
534528 valid = "no" ;
535529 reason = "non-source" ;
536530 errormsg = "contains elements not built from source (‘${ showSourceType attrs . meta . sourceProvenance } ’)" ;
531+ remediation = remediate_allowlist "NonSource" ( remediate_predicate "allowNonSourcePredicate" ) attrs ;
537532 }
538533 else if hasDeniedBroken attrs then
539534 {
540535 valid = "no" ;
541536 reason = "broken" ;
542537 errormsg = "is marked as broken" ;
538+ remediation = remediate_allowlist "Broken" ( x : "" ) ;
543539 }
544540 else if ! allowUnsupportedSystem && hasUnsupportedPlatform attrs then
545541 let
@@ -557,12 +553,14 @@ let
557553 package.meta.platforms = ${ toPretty' ( attrs . meta . platforms or [ ] ) }
558554 package.meta.badPlatforms = ${ toPretty' ( attrs . meta . badPlatforms or [ ] ) }
559555 '' ;
556+ remediation = remediate_allowlist "UnsupportedSystem" ( x : "" ) attrs ;
560557 }
561558 else if ! ( hasAllowedInsecure attrs ) then
562559 {
563560 valid = "no" ;
564561 reason = "insecure" ;
565562 errormsg = "is marked as insecure" ;
563+ remediation = remediate_insecure attrs ;
566564 }
567565
568566 # --- warnings ---
572570 valid = "warn" ;
573571 reason = "maintainerless" ;
574572 errormsg = "has no maintainers or teams" ;
573+ remediation = "" ;
575574 }
576575 # -----
577576 else
752751 if valid == "yes" then
753752 true
754753 else if valid == "no" then
755- ( handleEvalIssue { inherit meta attrs ; } { inherit ( validity ) reason errormsg ; } )
754+ ( handleEvalIssue { inherit meta attrs ; } { inherit ( validity ) reason errormsg remediation ; } )
756755 else if valid == "warn" then
757- ( handleEvalWarning { inherit meta attrs ; } { inherit ( validity ) reason errormsg ; } )
756+ ( handleEvalWarning { inherit meta attrs ; } { inherit ( validity ) reason errormsg remediation ; } )
758757 else
759758 throw "Unknown validity: '${ valid } '"
760759 ) ;
0 commit comments