|
| 1 | +# Updating Dependencies |
| 2 | + |
| 3 | +This document explains how to update various dependencies used in the nix configuration. |
| 4 | + |
| 5 | +## Updating Packer |
| 6 | + |
| 7 | +Packer is used for creating machine images and is defined in `nix/packages/packer.nix`. |
| 8 | + |
| 9 | +### Steps to update Packer version: |
| 10 | + |
| 11 | +1. Create a branch off of `develop` |
| 12 | +2. Navigate to `nix/packages/packer.nix` |
| 13 | +3. Update the version field: |
| 14 | + ```nix |
| 15 | + version = "1.15.0"; # Update to desired version |
| 16 | + ``` |
| 17 | +4. Update the git revision to match the new version: |
| 18 | + ```nix |
| 19 | + rev = "v${version}"; |
| 20 | + ``` |
| 21 | +5. Temporarily clear the hash to get the new SHA256: |
| 22 | + ```nix |
| 23 | + hash = ""; # Clear this temporarily |
| 24 | + ``` |
| 25 | +6. Save the file and run: |
| 26 | + ```bash |
| 27 | + nix build .#packer |
| 28 | + ``` |
| 29 | +7. Nix will fail and output the correct SHA256 hash. Copy this hash and update the file: |
| 30 | + ```nix |
| 31 | + hash = "sha256-NEWHASHHEREFROMBUILDOUTPUT"; |
| 32 | + ``` |
| 33 | +8. Update the vendorHash if needed. If the build fails due to vendor hash mismatch, temporarily set: |
| 34 | + ```nix |
| 35 | + vendorHash = ""; # Clear this temporarily |
| 36 | + ``` |
| 37 | +9. Run `nix build .#packer` again to get the correct vendorHash, then update: |
| 38 | + ```nix |
| 39 | + vendorHash = "sha256-NEWVENDORHASHHEREFROMBUILDOUTPUT"; |
| 40 | + ``` |
| 41 | +10. Verify the build works: |
| 42 | + ```bash |
| 43 | + nix build .#packer |
| 44 | + ``` |
| 45 | +11. Test the packer binary: |
| 46 | + ```bash |
| 47 | + ./result/bin/packer version |
| 48 | + ``` |
| 49 | +12. Run the full test suite to ensure nothing is broken: |
| 50 | + ```bash |
| 51 | + nix flake check -L |
| 52 | + ``` |
| 53 | +13. Commit your changes and create a PR for review |
| 54 | +14. Update any CI/CD workflows or documentation that reference the old Packer version |
| 55 | + |
| 56 | +### Notes: |
| 57 | +- Always check the [Packer changelog](https://github.com/hashicorp/packer/releases) for breaking changes |
| 58 | +- Packer uses Go, so ensure compatibility with the Go version specified in the flake inputs |
| 59 | +- The current Go version is specified in `flake.nix` under `nixpkgs-go124` input |
| 60 | +- If updating to a major version, test all packer templates (`.pkr.hcl` files) in the repository |
| 61 | + |
| 62 | +## Updating Other Dependencies |
| 63 | + |
| 64 | +Similar patterns can be followed for other dependencies defined in the nix packages. Always: |
| 65 | +1. Check for breaking changes in changelogs |
| 66 | +2. Update version numbers and hashes |
| 67 | +3. Run local tests |
| 68 | +4. Verify functionality before creating PR |
0 commit comments