Skip to content

Only define commit-lock-file-summary when the commit-msg input is explicitly defined (non-empty) #210

@MattSturgeon

Description

@MattSturgeon

It is possible to configure commit-lock-file-summary via a flake's nixConfig or via global nix config (e.g. specified in the install-nix action).

However, if --commit-lock-file-summary (or more precisely, --option commit-lockfile-summary) is supplied at the CLI, the configured value will be overridden by the value supplied at the CLI.

Instead, I'd propose removing the commit-msg input's default, and then only doing .concat(lockfileSummaryFlags) when commitMessage is truthy (non-empty). Alternatively, lockfileSummaryFlags could itself be an empty string when commitMessage is.

The default value specified in the input is usually1 identical to the default used by nix, so relying on nix's default when the input isn't defined seems like a reasonable behaviour.

The input:

commit-msg:
description: "The message provided with the commit"
required: false
default: "flake.lock: Update"

The lockfileSummaryFlags definition:

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

The concat:

.concat(lockfileSummaryFlags);

Footnotes

  1. for top-level flake.lock files it is identical. For nested flake.lock files nix will default the commit summary to something like path/to/flake.lock: Update relative to the root of the flake's source repo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions