2024-04-26 14:19:53 -03:00
|
|
|
// Build the Nix args out of inputs from the Actions environment
|
|
|
|
export function makeNixCommandArgs(
|
|
|
|
nixOptions: string[],
|
|
|
|
flakeInputs: string[],
|
|
|
|
commitMessage: string,
|
|
|
|
): string[] {
|
|
|
|
const flakeInputFlags = flakeInputs.flatMap((input) => [
|
|
|
|
"--update-input",
|
|
|
|
input,
|
|
|
|
]);
|
|
|
|
|
2024-06-28 13:37:59 -07:00
|
|
|
// NOTE(cole-h): In Nix versions 2.23.0 and later, `commit-lockfile-summary` became an alias to
|
|
|
|
// the setting `commit-lock-file-summary` (https://github.com/NixOS/nix/pull/10691), and Nix does
|
|
|
|
// not treat aliases the same as their "real" setting by requiring setting aliases to be
|
|
|
|
// configured via `--option <alias name> <option value>`
|
|
|
|
// (https://github.com/NixOS/nix/issues/10989).
|
|
|
|
// So, we go the long way so that we can support versions both before and after Nix 2.23.0.
|
|
|
|
const lockfileSummaryFlags = [
|
|
|
|
"--option",
|
|
|
|
"commit-lockfile-summary",
|
|
|
|
commitMessage,
|
|
|
|
];
|
|
|
|
|
2024-05-09 14:15:38 -04:00
|
|
|
const updateLockMechanism = flakeInputFlags.length === 0 ? "update" : "lock";
|
|
|
|
|
2024-04-26 14:19:53 -03:00
|
|
|
return nixOptions
|
2024-05-09 14:15:38 -04:00
|
|
|
.concat(["flake", updateLockMechanism])
|
2024-04-26 14:19:53 -03:00
|
|
|
.concat(flakeInputFlags)
|
2024-06-28 13:37:59 -07:00
|
|
|
.concat(["--commit-lock-file"])
|
|
|
|
.concat(lockfileSummaryFlags);
|
2024-04-26 14:19:53 -03:00
|
|
|
}
|