2 # helper functions for packaging programs with plugin systems
5 /* Takes a list of expected plugin names
6 * and compares it to the found plugins given in the file,
8 * If the lists differ, the build fails with a nice message.
10 * This is helpful to ensure maintainers don’t miss
11 * the addition or removal of a plugin.
13 diffPlugins = expectedPlugins: foundPluginsFilePath: ''
14 # sort both lists first
15 plugins_expected=$(mktemp)
16 (${lib.concatMapStrings (s: "echo \"${s}\";") expectedPlugins}) \
17 | sort -u > "$plugins_expected"
18 plugins_found=$(mktemp)
19 sort -u "${foundPluginsFilePath}" > "$plugins_found"
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