lol

Merge pull request #98214 from turion/dev_test_all_agda_packages

Fix #98209. Test all agda packages

authored by

Manuel Bärenz and committed by
GitHub
7a135abf b270a937

+77 -2
+63 -1
doc/languages-frameworks/agda.section.md
··· 158 158 159 159 By default, Agda sources are files ending on `.agda`, or literate Agda files ending on `.lagda`, `.lagda.tex`, `.lagda.org`, `.lagda.md`, `.lagda.rst`. The list of recognised Agda source extensions can be extended by setting the `extraExtensions` config variable. 160 160 161 - ## Adding Agda packages to Nixpkgs {#adding-agda-packages-to-nixpkgs} 161 + ## Maintaining the Agda package set on Nixpkgs {#maintaining-the-agda-package-set-on-nixpkgs} 162 + 163 + We are aiming at providing all common Agda libraries as packages on `nixpkgs`, 164 + and keeping them up to date. 165 + Contributions and maintenance help is always appreciated, 166 + but the maintenance effort is typically low since the Agda ecosystem is quite small. 167 + 168 + The `nixpkgs` Agda package set tries to take up a role similar to that of [Stackage](https://www.stackage.org/) in the Haskell world. 169 + It is a curated set of libraries that: 170 + 171 + 1. Always work together. 172 + 2. Are as up-to-date as possible. 173 + 174 + While the Haskell ecosystem is huge, and Stackage is highly automatised, 175 + the Agda package set is small and can (still) be maintained by hand. 176 + 177 + ### Adding Agda packages to Nixpkgs {#adding-agda-packages-to-nixpkgs} 162 178 163 179 To add an Agda package to `nixpkgs`, the derivation should be written to `pkgs/development/libraries/agda/${library-name}/` and an entry should be added to `pkgs/top-level/agda-packages.nix`. Here it is called in a scope with access to all other Agda libraries, so the top line of the `default.nix` can look like: 164 180 ··· 192 208 This library has a file called `.agda-lib`, and so we give an empty string to `libraryFile` as nothing precedes `.agda-lib` in the filename. This file contains `name: IAL-1.3`, and so we let `libraryName = "IAL-1.3"`. This library does not use an `Everything.agda` file and instead has a Makefile, so there is no need to set `everythingFile` and we set a custom `buildPhase`. 193 209 194 210 When writing an Agda package it is essential to make sure that no `.agda-lib` file gets added to the store as a single file (for example by using `writeText`). This causes Agda to think that the nix store is a Agda library and it will attempt to write to it whenever it typechecks something. See [https://github.com/agda/agda/issues/4613](https://github.com/agda/agda/issues/4613). 211 + 212 + In the pull request adding this library, 213 + you can test whether it builds correctly by writing in a comment: 214 + 215 + ``` 216 + @ofborg build agdaPackages.iowa-stdlib 217 + ``` 218 + 219 + ### Maintaining Agda packages 220 + 221 + As mentioned before, the aim is to have a compatible, and up-to-date package set. 222 + These two conditions sometimes exclude each other: 223 + For example, if we update `agdaPackages.standard-library` because there was an upstream release, 224 + this will typically break many reverse dependencies, 225 + i.e. downstream Agda libraries that depend on the standard library. 226 + In `nixpkgs` we are typically among the first to notice this, 227 + since we have build tests in place to check this. 228 + 229 + In a pull request updating e.g. the standard library, you should write the following comment: 230 + 231 + ``` 232 + @ofborg build agdaPackages.standard-library.passthru.tests 233 + ``` 234 + 235 + This will build all reverse dependencies of the standard library, 236 + for example `agdaPackages.agda-categories`, or `agdaPackages.generic`. 237 + 238 + In some cases it is useful to build _all_ Agda packages. 239 + This can be done with the following Github comment: 240 + 241 + ``` 242 + @ofborg build agda.passthru.tests.allPackages 243 + ``` 244 + 245 + Sometimes, the builds of the reverse dependencies fail because they have not yet been updated and released. 246 + You should drop the maintainers a quick issue notifying them of the breakage, 247 + citing the build error (which you can get from the ofborg logs). 248 + If you are motivated, you might even send a pull request that fixes it. 249 + Usually, the maintainers will answer within a week or two with a new release. 250 + Bumping the version of that reverse dependency should be a further commit on your PR. 251 + 252 + In the rare case that a new release is not to be expected within an acceptable time, 253 + simply mark the broken package as broken by setting `meta.broken = true;`. 254 + This will exclude it from the build test. 255 + It can be added later when it is fixed, 256 + and does not hinder the advancement of the whole package set in the meantime.
+5
pkgs/build-support/agda/default.nix
··· 79 79 find -not \( -path ${everythingFile} -or -path ${lib.interfaceFile everythingFile} \) -and \( ${concatMapStringsSep " -or " (p: "-name '*.${p}'") (extensions ++ extraExtensions)} \) -exec cp -p --parents -t "$out" {} + 80 80 runHook postInstall 81 81 ''; 82 + 82 83 meta = if meta.broken or false then meta // { hydraPlatforms = lib.platforms.none; } else meta; 84 + 85 + # Retrieve all packages from the finished package set that have the current package as a dependency and build them 86 + passthru.tests = with builtins; 87 + lib.filterAttrs (name: pkg: self.lib.isUnbrokenAgdaPackage pkg && elem pname (map (pkg: pkg.pname) pkg.buildInputs)) self; 83 88 }; 84 89 in 85 90 {
+5
pkgs/build-support/agda/lib.nix
··· 7 7 * interfaceFile "src/Everything.lagda.tex" == "src/Everything.agdai" 8 8 */ 9 9 interfaceFile = agdaFile: lib.head (builtins.match ''(.*\.)l?agda(\.(md|org|rst|tex))?'' agdaFile) + "agdai"; 10 + 11 + /* Takes an arbitrary derivation and says whether it is an agda library package 12 + * that is not marked as broken. 13 + */ 14 + isUnbrokenAgdaPackage = pkg: pkg.isAgdaDerivation or false && !pkg.meta.broken; 10 15 }
+4 -1
pkgs/top-level/agda-packages.nix
··· 13 13 14 14 lib = lib.extend (final: prev: import ../build-support/agda/lib.nix { lib = prev; }); 15 15 16 - agda = withPackages [] // { inherit withPackages; }; 16 + agda = withPackages [] // { 17 + inherit withPackages; 18 + passthru.tests.allPackages = withPackages (lib.filter (pkg: self.lib.isUnbrokenAgdaPackage pkg) (lib.attrValues self)); 19 + }; 17 20 18 21 standard-library = callPackage ../development/libraries/agda/standard-library { 19 22 inherit (pkgs.haskellPackages) ghcWithPackages;