|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +source ./common.sh |
| 4 | + |
| 5 | +TODO_NixOS |
| 6 | + |
| 7 | +createFlake1 |
| 8 | + |
| 9 | +lockfileSummaryFlake=$TEST_ROOT/lockfileSummaryFlake |
| 10 | +createGitRepo "$lockfileSummaryFlake" "--initial-branch=main" |
| 11 | + |
| 12 | +# Test that the --commit-lock-file-summary flag and its alias work |
| 13 | +cat > "$lockfileSummaryFlake/flake.nix" <<EOF |
| 14 | +{ |
| 15 | + inputs = { |
| 16 | + flake1.url = "git+file://$flake1Dir"; |
| 17 | + }; |
| 18 | +
|
| 19 | + description = "lockfileSummaryFlake"; |
| 20 | +
|
| 21 | + outputs = inputs: rec { |
| 22 | + packages.$system.default = inputs.flake1.packages.$system.foo; |
| 23 | + }; |
| 24 | +} |
| 25 | +EOF |
| 26 | + |
| 27 | +git -C "$lockfileSummaryFlake" add flake.nix |
| 28 | +git -C "$lockfileSummaryFlake" commit -m 'Add lockfileSummaryFlake' |
| 29 | + |
| 30 | +testSummary="test summary 1" |
| 31 | +nix flake lock "$lockfileSummaryFlake" --commit-lock-file --commit-lock-file-summary "$testSummary" |
| 32 | +[[ -e "$lockfileSummaryFlake/flake.lock" ]] |
| 33 | +[[ -z $(git -C "$lockfileSummaryFlake" diff main || echo failed) ]] |
| 34 | +[[ "$(git -C "$lockfileSummaryFlake" log --format=%s -n 1)" = "$testSummary" ]] |
| 35 | + |
| 36 | +git -C "$lockfileSummaryFlake" rm :/:flake.lock |
| 37 | +git -C "$lockfileSummaryFlake" commit -m "remove flake.lock" |
| 38 | +testSummary="test summary 2" |
| 39 | +# NOTE(cole-h): We use `--option` here because Nix settings do not currently support flag-ifying the |
| 40 | +# alias of a setting: https://github.com/NixOS/nix/issues/10989 |
| 41 | +nix flake lock "$lockfileSummaryFlake" --commit-lock-file --option commit-lockfile-summary "$testSummary" |
| 42 | +[[ -e "$lockfileSummaryFlake/flake.lock" ]] |
| 43 | +[[ -z $(git -C "$lockfileSummaryFlake" diff main || echo failed) ]] |
| 44 | +[[ "$(git -C "$lockfileSummaryFlake" log --format=%s -n 1)" = "$testSummary" ]] |
0 commit comments