Skip to content

Commit b0e5dcc

Browse files
committed
First draft at a varlink protocol for inside derivations
1 parent 3b03872 commit b0e5dcc

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# For the derivation builder insider to communicate with Nix
2+
interface org.nix.derivation-builder
3+
4+
type DerivationOutput (
5+
# Note, not needed for floating content-addressing derivations.
6+
path: ?string,
7+
method: ?string,
8+
hashAlgo: ?string,
9+
hash: ?string
10+
)
11+
12+
type Derivation (
13+
name: string,
14+
outputs: [string]DerivationOutput,
15+
# TODO, combine both types in to just "sources"
16+
inputSrcs: []string,
17+
# Approximate typing
18+
inputDrvs: [string]object,
19+
system: string,
20+
builder: string,
21+
args: []string,
22+
env: [string]string,
23+
# Intentionally freeform, as the point of this is being extensible.
24+
# Implementations should reject what they don't understand.
25+
options: ?[string]object
26+
)
27+
28+
# Add a file to the store.
29+
#
30+
# Parameters:
31+
# - name: file name
32+
# - method: content addressing method ("sha256", etc.)
33+
# - fd: file descriptor number to read from
34+
#
35+
# Returns:
36+
# - path: resulting store path
37+
#
38+
# The references should be scanned based on the starting possible
39+
# reference set of all derivation inputs, and all previously-added store
40+
# objects. (Ever sucessfull add, this possible reference set grows one
41+
# bigger.)
42+
#
43+
# This also requires a file descriptor to be sent which refers to the
44+
# actual data to be added. I am not sure if it is possible to write this
45+
# in the IDL since it is an extension (in systemd's usage of Varlink),
46+
# and not Varlink proper. (Opened
47+
# https://github.com/systemd/systemd/issues/38595 for this question.)
48+
method AddToStore(
49+
name: string,
50+
method: string,
51+
#descriptor: int
52+
) -> (path: string)
53+
54+
# Add a derivation to the store.
55+
# Parameters:
56+
# - derivation: derivation in JSON format
57+
# Returns:
58+
# - path: store path of the derivation (in format)
59+
method AddDerivation(derivation: Derivation) -> (path: string)
60+
61+
# Submit an output, associating an output with a store object.
62+
#
63+
# Parameters:
64+
# - name: name of the output
65+
# - path: path of the store object (must already exist in store)
66+
#
67+
# The idea is derivations should add and submit their outputs one at a
68+
# time. This allows a few things:
69+
#
70+
# 1. Interesting pipeling. If something downstream just needs e.g. a
71+
# "dev" or "headers" output, it need not block on waiting for the other
72+
# outputs of the upstream derivation.
73+
#
74+
# 2. Content addressing doesn't require Nix-side rewriting. Instead, it
75+
# is the responsibilty of the builder to add outputs in reference order,
76+
# and arrange for the store paths that resulted from earlier adds being
77+
# used in later adds. This takes would be a very hard problem to solver
78+
# in "build system space", and punts it back to userspace, where
79+
# arbitrary strategies can be employed.
80+
method SubmitOutput(name: string, path: string) -> ()

0 commit comments

Comments
 (0)