|
3 | 3 | callPackage, |
4 | 4 | fetchFromGitHub, |
5 | 5 | gitUpdater, |
| 6 | + gitMinimal, |
6 | 7 | lib, |
7 | 8 | writeText, |
8 | 9 | writeShellApplication, |
@@ -57,18 +58,37 @@ lib.recurseIntoAttrs ( |
57 | 58 | updateScript = _experimental-update-script-combinators.sequence [ |
58 | 59 | (gitUpdater { rev-prefix = "v"; }) |
59 | 60 | { |
60 | | - command = ( |
61 | | - writeShellApplication { |
62 | | - name = "bonfire-update-flavours"; |
63 | | - text = '' |
| 61 | + command = lib.getExe (writeShellApplication { |
| 62 | + name = "bonfire-update-flavours"; |
| 63 | + runtimeInputs = [ |
| 64 | + gitMinimal |
| 65 | + ]; |
| 66 | + text = lib.concatLines [ |
| 67 | + # Avoid a costly update if `gitUpdater` has not modified this file. |
| 68 | + '' |
| 69 | + if git diff --exit-code -- pkgs/by-name/bonfire/package.nix; then |
| 70 | + exit 0 |
| 71 | + fi |
| 72 | + '' |
| 73 | + # Clean everything to begin with to avoid leftovers. |
| 74 | + '' |
64 | 75 | rm -rf pkgs/by-name/bonfire/extensions/*/ |
65 | 76 | mkdir -p pkgs/by-name/bonfire/extensions/ |
66 | 77 | '' |
67 | | - + lib.concatMapStringsSep "\n" (flavour: '' |
68 | | - ${finalFlavours.${flavour}.passthru.update.script} |
69 | | - '') flavours; |
70 | | - } |
71 | | - ); |
| 78 | + # Updating all flavours using the same `src` set by `gitUpdater` |
| 79 | + # to avoid any flavour ending up using a `src` no longer matching |
| 80 | + # the files generated in pkgs/by-name/bonfire/extensions/${flavour}/, |
| 81 | + # which can happen when upstream releases a new version |
| 82 | + # during the update of a flavour, |
| 83 | + # which is likely since each flavour update takes roughly one hour. |
| 84 | + (lib.concatMapStringsSep "\n" ( |
| 85 | + flavour: |
| 86 | + lib.optionalString (!(finalFlavours.${flavour}.meta.broken or false)) '' |
| 87 | + ${lib.getExe finalFlavours.${flavour}.passthru.update.script} |
| 88 | + '' |
| 89 | + ) flavours) |
| 90 | + ]; |
| 91 | + }); |
72 | 92 | supportedFeatures = [ "silent" ]; |
73 | 93 | } |
74 | 94 | ]; |
|
0 commit comments