at 18.09-beta 29 lines 977 B view raw
1{ stdenv }: 2# helper functions for packaging programs with plugin systems 3{ 4 5 /* Takes a list of expected plugin names 6 * and compares it to the found plugins given in the file, 7 * one plugin per line. 8 * If the lists differ, the build fails with a nice message. 9 * 10 * This is helpful to ensure maintainers dont miss 11 * the addition or removal of a plugin. 12 */ 13 diffPlugins = expectedPlugins: foundPluginsFilePath: '' 14 # sort both lists first 15 plugins_expected=$(mktemp) 16 (${stdenv.lib.concatMapStrings (s: "echo \"${s}\";") expectedPlugins}) \ 17 | sort -u > "$plugins_expected" 18 plugins_found=$(mktemp) 19 sort -u "${foundPluginsFilePath}" > "$plugins_found" 20 21 if ! mismatches="$(diff -y "$plugins_expected" "$plugins_found")"; then 22 echo "The the list of expected plugins (left side) doesn't match" \ 23 "the list of plugins we found (right side):" >&2 24 echo "$mismatches" >&2 25 exit 1 26 fi 27 ''; 28 29}