| 
									
										
										
										
											2025-04-01 20:10:43 +02:00
										 |  |  | { | 
					
						
							|  |  |  |   lib, | 
					
						
							|  |  |  |   stdenv, | 
					
						
							|  |  |  |   fetchurl, | 
					
						
							|  |  |  |   fetchzip, | 
					
						
							|  |  |  |   callPackage, | 
					
						
							|  |  |  |   newScope, | 
					
						
							|  |  |  |   recurseIntoAttrs, | 
					
						
							|  |  |  |   ocamlPackages_4_14, | 
					
						
							|  |  |  |   fetchpatch, | 
					
						
							|  |  |  |   makeWrapper, | 
					
						
							| 
									
										
										
										
											2024-12-23 15:36:52 +01:00
										 |  |  | }@args: | 
					
						
							|  |  |  | let | 
					
						
							| 
									
										
										
										
											2025-04-01 20:10:43 +02:00
										 |  |  |   lib = import ../build-support/rocq/extra-lib.nix { inherit (args) lib; }; | 
					
						
							|  |  |  | in | 
					
						
							|  |  |  | let | 
					
						
							|  |  |  |   mkRocqPackages' = | 
					
						
							|  |  |  |     self: rocq-core: | 
					
						
							|  |  |  |     let | 
					
						
							|  |  |  |       callPackage = self.callPackage; | 
					
						
							|  |  |  |     in | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2024-12-23 15:36:52 +01:00
										 |  |  |       inherit rocq-core lib; | 
					
						
							| 
									
										
										
										
											2025-04-01 20:10:43 +02:00
										 |  |  |       rocqPackages = self // { | 
					
						
							|  |  |  |         __attrsFailEvaluation = true; | 
					
						
							|  |  |  |         recurseForDerivations = false; | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2024-12-23 15:36:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-01 20:10:43 +02:00
										 |  |  |       metaFetch = import ../build-support/coq/meta-fetch/default.nix { | 
					
						
							|  |  |  |         inherit | 
					
						
							|  |  |  |           lib | 
					
						
							|  |  |  |           stdenv | 
					
						
							|  |  |  |           fetchzip | 
					
						
							|  |  |  |           fetchurl | 
					
						
							|  |  |  |           ; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |       mkRocqDerivation = lib.makeOverridable (callPackage ../build-support/rocq { }); | 
					
						
							| 
									
										
										
										
											2024-12-23 15:36:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-01 20:10:43 +02:00
										 |  |  |       bignums = callPackage ../development/rocq-modules/bignums { }; | 
					
						
							|  |  |  |       rocq-elpi = callPackage ../development/rocq-modules/rocq-elpi { }; | 
					
						
							|  |  |  |       stdlib = callPackage ../development/rocq-modules/stdlib { }; | 
					
						
							| 
									
										
										
										
											2024-12-23 15:36:52 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |       filterPackages = doesFilter: if doesFilter then filterRocqPackages self else self; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-01 20:10:43 +02:00
										 |  |  |   filterRocqPackages = | 
					
						
							|  |  |  |     set: | 
					
						
							| 
									
										
										
										
											2024-12-23 15:36:52 +01:00
										 |  |  |     lib.listToAttrs ( | 
					
						
							| 
									
										
										
										
											2025-04-01 20:10:43 +02:00
										 |  |  |       lib.concatMap ( | 
					
						
							|  |  |  |         name: | 
					
						
							|  |  |  |         let | 
					
						
							|  |  |  |           v = set.${name} or null; | 
					
						
							|  |  |  |         in | 
					
						
							|  |  |  |         lib.optional (!v.meta.rocqFilter or false) ( | 
					
						
							|  |  |  |           lib.nameValuePair name ( | 
					
						
							|  |  |  |             if lib.isAttrs v && v.recurseForDerivations or false then filterRocqPackages v else v | 
					
						
							|  |  |  |           ) | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2024-12-23 15:36:52 +01:00
										 |  |  |       ) (lib.attrNames set) | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2025-04-01 20:10:43 +02:00
										 |  |  |   mkRocq = | 
					
						
							|  |  |  |     version: | 
					
						
							|  |  |  |     callPackage ../applications/science/logic/rocq-core { | 
					
						
							|  |  |  |       inherit | 
					
						
							|  |  |  |         version | 
					
						
							|  |  |  |         ocamlPackages_4_14 | 
					
						
							|  |  |  |         ; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | in | 
					
						
							|  |  |  | rec { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /*
 | 
					
						
							|  |  |  |     The function `mkRocqPackages` takes as input a derivation for Rocq and produces | 
					
						
							|  |  |  |     a set of libraries built with that specific Rocq. More libraries are known to | 
					
						
							|  |  |  |     this function than what is compatible with that version of Rocq. Therefore, | 
					
						
							|  |  |  |     libraries that are not known to be compatible are removed (filtered out) from | 
					
						
							|  |  |  |     the resulting set. For meta-programming purposes (inspecting the derivations | 
					
						
							|  |  |  |     rather than building the libraries) this filtering can be disabled by setting | 
					
						
							|  |  |  |     a `dontFilter` attribute into the Rocq derivation. | 
					
						
							|  |  |  |   */ | 
					
						
							|  |  |  |   mkRocqPackages = | 
					
						
							|  |  |  |     rocq-core: | 
					
						
							|  |  |  |     let | 
					
						
							|  |  |  |       self = lib.makeScope newScope (lib.flip mkRocqPackages' rocq-core); | 
					
						
							|  |  |  |     in | 
					
						
							|  |  |  |     self.filterPackages (!rocq-core.dontFilter or false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   rocq-core_9_0 = mkRocq "9.0"; | 
					
						
							| 
									
										
										
										
											2024-12-23 15:36:52 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   rocqPackages_9_0 = mkRocqPackages rocq-core_9_0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   rocqPackages = recurseIntoAttrs rocqPackages_9_0; | 
					
						
							|  |  |  |   rocq-core = rocqPackages.rocq-core; | 
					
						
							|  |  |  | } |