Skip to content

Commit

Permalink
Fixup support for Nix 2.23.0 and later
Browse files Browse the repository at this point in the history
  • Loading branch information
cole-h committed Jun 28, 2024
1 parent b0723e0 commit db4ee38
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
7 changes: 6 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95086,8 +95086,13 @@ function makeNixCommandArgs(nixOptions, flakeInputs, commitMessage) {
"--update-input",
input
]);
const lockfileSummaryFlags = [
"--option",
"commit-lockfile-summary",
commitMessage
];
const updateLockMechanism = flakeInputFlags.length === 0 ? "update" : "lock";
return nixOptions.concat(["flake", updateLockMechanism]).concat(flakeInputFlags).concat(["--commit-lock-file", "--commit-lockfile-summary", commitMessage]);
return nixOptions.concat(["flake", updateLockMechanism]).concat(flakeInputFlags).concat(["--commit-lock-file"]).concat(lockfileSummaryFlags);
}

// src/index.ts
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions src/nix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ test("Nix command arguments", () => {
"flake",
"update",
"--commit-lock-file",
"--commit-lockfile-summary",
"--option",
"commit-lockfile-summary",
"just testing",
],
},
Expand All @@ -42,7 +43,8 @@ test("Nix command arguments", () => {
"--update-input",
"rust-overlay",
"--commit-lock-file",
"--commit-lockfile-summary",
"--option",
"commit-lockfile-summary",
"just testing",
],
},
Expand All @@ -57,7 +59,8 @@ test("Nix command arguments", () => {
"flake",
"update",
"--commit-lock-file",
"--commit-lockfile-summary",
"--option",
"commit-lockfile-summary",
"just testing",
],
},
Expand Down
15 changes: 14 additions & 1 deletion src/nix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,23 @@ export function makeNixCommandArgs(
input,
]);

// 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,
];

const updateLockMechanism = flakeInputFlags.length === 0 ? "update" : "lock";

return nixOptions
.concat(["flake", updateLockMechanism])
.concat(flakeInputFlags)
.concat(["--commit-lock-file", "--commit-lockfile-summary", commitMessage]);
.concat(["--commit-lock-file"])
.concat(lockfileSummaryFlags);
}

0 comments on commit db4ee38

Please sign in to comment.