Skip to content

protocol: update JSON output with structured Signature type#15009

Merged
Ericson2314 merged 1 commit into
NixOS:masterfrom
amaanq:signature-type
Mar 3, 2026
Merged

protocol: update JSON output with structured Signature type#15009
Ericson2314 merged 1 commit into
NixOS:masterfrom
amaanq:signature-type

Conversation

@amaanq
Copy link
Copy Markdown
Member

@amaanq amaanq commented Jan 16, 2026

Motivation

Previously, signatures were raw strings (in the format of keyName:base64sig) in JSON outputs. A proper Signature type in the JSON can improve this output by mimicking the inner Signature type used in the codebase.

Context

The JSON output uses a structured {keyName, sig} objects for Realisation and PathInfo V3. Additionally, V1 & V2 keeps the string format for backwards compatibility, and parsing accepts both formats.

The new JSON schemas introduced in this PR are signature-v1.yaml for the Signature type itself and store-object-info-v3.yaml for PathInfo with structured signatures.


Add 👍 to pull requests you find important.

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

@github-actions github-actions Bot added documentation new-cli Relating to the "nix" command store Issues and pull requests concerning the Nix store labels Jan 16, 2026
Comment thread doc/manual/rl-next/structured-signatures.md Outdated
Comment thread doc/manual/source/protocols/json/schema/build-trace-entry-v2.yaml Outdated
Comment thread doc/manual/source/protocols/json/schema/signature-v2.yaml
Comment thread doc/manual/source/protocols/json/schema/store-object-info-v3.yaml
Comment thread src/libutil/include/nix/util/signature/local-keys.hh Outdated
Comment thread src/libutil/signature/local-keys.cc Outdated
Comment thread src/libutil/include/nix/util/signature/local-keys.hh
@amaanq amaanq force-pushed the signature-type branch 2 times, most recently from 1b3da8c to c6c44e9 Compare January 16, 2026 20:14
Comment thread doc/manual/source/protocols/json/schema/signature-v2.yaml Outdated
Comment thread doc/manual/source/protocols/json/schema/store-object-info-v3.yaml
Comment thread doc/manual/rl-next/structured-signatures.md Outdated
Comment thread src/libutil/signature/local-keys.cc Outdated
@Ericson2314

This comment was marked as resolved.

@Ericson2314

This comment was marked as resolved.

Comment thread src/libstore-tests/data/common-protocol/realisation-with-deps.bin
Comment thread src/libstore-tests/data/realisation/with-signature.json
Comment thread src/libstore-tests/data/serve-protocol/realisation-with-deps.bin
Comment thread src/libstore-tests/data/path-info/json-2/json-3 Outdated
Comment thread src/libstore/realisation.cc Outdated
@amaanq amaanq force-pushed the signature-type branch 3 times, most recently from 097c8b3 to 3d71485 Compare January 22, 2026 20:03
Comment thread src/libstore-tests/realisation.cc
Comment thread src/libstore-tests/realisation.cc
Comment thread doc/manual/rl-next/structured-signatures.md Outdated
@github-actions github-actions Bot added the with-tests Issues related to testing. PRs with tests have some priority label Jan 22, 2026
@Ericson2314 Ericson2314 changed the title protocol: introduce structured Signature type protocol: update JSON output with structured Signature type Jan 22, 2026
Comment thread tests/functional/ca/signatures.sh Outdated

source common.sh

requireDaemonNewerThan "2.34pre20260122"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the daemon format just uses the latest JSON for which is bad, but I don't think it is worth fixing because we have some more serious Realisation/Build Trace JSON format changes right around the corner, after which there will be a harder compat break for this unstable feature, and I also took that opportunity to make it stop using JSON so we won't have this versioning issue again.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to delete this now!

Comment on lines +181 to +184
j = {
{"keyName", s.keyName},
{"sig", base64::encode(std::as_bytes(std::span<const char>{s.sig}))},
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what this gets us in terms of immediate benefits? The signature itself is still a binary blob that's supposed to be ed25519.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. It is used in nix path-info, but that is already versioned
  2. It is used in realisations, but those are going to be subject to breaking changes anyways. We have back compat in the reading direction (just not writing direction) too.

Comment on lines +26 to +33
keyName:
type: string
title: Key Name
description: The name of the key used to produce this signature
sig:
type: string
title: Signature Data
description: The raw signature bytes, Base64-encoded
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add algorithm field? Something that is ed25519 currently?

CC @mschwaig @edef1c

@amaanq amaanq force-pushed the signature-type branch 2 times, most recently from 5640ebf to ac6060f Compare March 2, 2026 22:40
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  - Version 1: Original format
  - Version 2:
    - Remove `dependentRealisations`
 - Version 3:
    - Use `drvPath` not `drvHash` to refer to derivation in a more conventional way.
    - Separate into `key` and `value`
    - Use 2nd version of signatures format (objects, not strings)

We should have this in the version history, and this should be named to `v3 accordingly.

@amaanq amaanq force-pushed the signature-type branch 3 times, most recently from d5e7d61 to 75b6a24 Compare March 3, 2026 00:50
This commit updates the JSON output with a Signature type containing
keyName and sig fields. JSON parsing accepts both formats for backwards
compatibility.

Co-authored-by: John Ericson <John.Ericson@Obsidian.Systems>
Copy link
Copy Markdown
Member

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The concern with this was that we were churning the formats, but now that we are changing realisations in a breaking way anyways (drv hash -> drv path) there is essentially no marginal cost of doing this

@Ericson2314 Ericson2314 enabled auto-merge March 3, 2026 01:33
@Ericson2314 Ericson2314 added this pull request to the merge queue Mar 3, 2026
Merged via the queue into NixOS:master with commit 05855f5 Mar 3, 2026
15 checks passed
@amaanq amaanq deleted the signature-type branch March 25, 2026 05:13
brittonr pushed a commit to brittonr/nix that referenced this pull request Apr 1, 2026
protocol: update JSON output with structured `Signature` type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation new-cli Relating to the "nix" command store Issues and pull requests concerning the Nix store with-tests Issues related to testing. PRs with tests have some priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants