2024-04-22 00:42:23 +02:00
|
|
|
import { ActionOptions, IdsToolbox, inputs } from "detsys-ts";
|
|
|
|
|
|
|
|
class UpdateFlakeLockAction {
|
|
|
|
idslib: IdsToolbox;
|
|
|
|
private nixOptions: string;
|
2024-04-22 00:50:32 +02:00
|
|
|
private targets: string[];
|
2024-04-22 00:42:23 +02:00
|
|
|
private commitMessage: string;
|
|
|
|
private pathToFlakeDir: string;
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
const options: ActionOptions = {
|
|
|
|
name: "update-flake-lock",
|
|
|
|
// We don't
|
|
|
|
fetchStyle: "universal",
|
|
|
|
requireNix: "fail",
|
|
|
|
};
|
|
|
|
|
|
|
|
this.idslib = new IdsToolbox(options);
|
|
|
|
|
|
|
|
this.nixOptions = inputs.getString("nix-options");
|
2024-04-22 00:50:32 +02:00
|
|
|
this.targets = inputs.getString("inputs").split(" ");
|
2024-04-22 00:42:23 +02:00
|
|
|
this.commitMessage = inputs.getString("commit-msg");
|
|
|
|
this.pathToFlakeDir = inputs.getString("path-to-flake-dir");
|
|
|
|
}
|
|
|
|
|
2024-04-22 00:50:32 +02:00
|
|
|
async update(): Promise<void> {
|
|
|
|
const inputFlags = this.targets
|
|
|
|
.map((input) => `--update-input ${input}`)
|
|
|
|
.join(" ");
|
|
|
|
const inputStr = this.targets.length > 1 ? `${inputFlags}` : undefined;
|
|
|
|
|
|
|
|
const nixCommand = `nix ${this.nixOptions} flake lock ${inputStr} --commit-lock-file --commit-lock-file-summary "${this.commitMessage}"`;
|
|
|
|
}
|
2024-04-22 00:42:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function main(): void {
|
|
|
|
const updateFlakeLock = new UpdateFlakeLockAction();
|
|
|
|
|
|
|
|
updateFlakeLock.idslib.onMain(async () => {
|
|
|
|
await updateFlakeLock.update();
|
|
|
|
});
|
|
|
|
|
|
|
|
updateFlakeLock.idslib.execute();
|
|
|
|
}
|
2024-04-22 00:17:03 +02:00
|
|
|
|
|
|
|
main();
|