Skip to content

libutil: add Signature struct for typed signatures#15029

Merged
edolstra merged 1 commit intoNixOS:masterfrom
amaanq:signature-type-core
Jan 21, 2026
Merged

libutil: add Signature struct for typed signatures#15029
edolstra merged 1 commit intoNixOS:masterfrom
amaanq:signature-type-core

Conversation

@amaanq
Copy link
Member

@amaanq amaanq commented Jan 20, 2026

Motivation

Currently, signatures are represented as raw strings in the format keyName:base64sig. This requires parsing at every use site and makes the code less type-safe. This PR introduces a Signature struct that encapsulates this representation.

Context

This PR introduces a Signature struct and uses it throughout the codebase. The struct has two string fields, a keyName and a sig field. The sig field contains the raw decoded bytes. All places where signatures were used as strings have been updated to use Signature now - for example, sets of signatures were StringSet before, but are now std::set<Signature>. The JSON output is untouched in this PR; we use to_string() when writing to/reading from JSON.

#15009 builds on top of this by actually changing the JSON output to use a more structured type. This PR is the preliminary scaffolding for that.


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@amaanq amaanq requested a review from edolstra as a code owner January 20, 2026 19:06
@amaanq amaanq force-pushed the signature-type-core branch from dad1595 to 216e2e5 Compare January 20, 2026 19:19
@amaanq amaanq requested a review from Ericson2314 as a code owner January 20, 2026 19:19
@github-actions github-actions bot added new-cli Relating to the "nix" command store Issues and pull requests concerning the Nix store labels Jan 20, 2026
@amaanq amaanq force-pushed the signature-type-core branch 2 times, most recently from 627ecbf to b6384ad Compare January 20, 2026 19:35
@amaanq amaanq force-pushed the signature-type-core branch from b6384ad to 5829623 Compare January 20, 2026 21:05
@amaanq amaanq force-pushed the signature-type-core branch 3 times, most recently from d0a8284 to 80ab69d Compare January 21, 2026 16:00
@Ericson2314

This comment was marked as resolved.

@amaanq amaanq force-pushed the signature-type-core branch from 80ab69d to ae17622 Compare January 21, 2026 16:43
Introduce a new `Signature` struct that represents a cryptographic
signature
along with the key name that produced it. This provides:

- Structured representation instead of colon-separated strings
- Type-safe parsing with `Signature::parse()`
- Serialization with `to_string()`
- JSON serialization/deserialization
- Batch parsing with `parseMany<Container>()`
- Batch serialization with `toStrings()`

This is scaffolding for future changes that will use this type
throughout the codebase.
@amaanq amaanq force-pushed the signature-type-core branch from ae17622 to 12ef043 Compare January 21, 2026 16:51
@edolstra edolstra added this pull request to the merge queue Jan 21, 2026
Merged via the queue into NixOS:master with commit 44dce7a Jan 21, 2026
14 checks passed
@amaanq amaanq deleted the signature-type-core branch January 22, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-cli Relating to the "nix" command store Issues and pull requests concerning the Nix store

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants