Sketch at Varlink interface for #8602 - #13768
Conversation
e7f2322 to
ec76643
Compare
a11549d to
922b322
Compare
|
If non-fixed-output derivations can use dynamic derivations to create fixed-output derivations then that can be used to send data to the internet: e.g. derivation A that should be fully sandboxed could create fixed-output derivation B with a curl command sending information to a remote server. |
|
Isn't that an existing issue with recursive-nix? |
|
Yes, I had just noticed the issue now though |
|
We could prohibit that. |
f026d02 to
40f4931
Compare
6594ccb to
45c541e
Compare
| # The added files may only reference the runtime closures of the calling derivation's | ||
| # inputs or file system objects that have already been created via the Varlink interface. | ||
| # | ||
| # The file descriptor may be a regular fd referencing a file or a dirfd. |
There was a problem hiding this comment.
This is wrong, the file descriptor is a *socket( over which a NAR and (later) also arbitrary many file descriptors for individual files are sent.
f35b599 to
a76ae11
Compare
NixOS/nix#15793 lets builds with the builder-rpc-v0 system feature talk to the daemon over the worker protocol's restricted allowlist plus a new SubmitOutput op, which removes the need for the recursive-nix subprocess dance. SubmitOutput enforces outputPathName(callingDrv.name, \"out\") on the submitted path, so the final drv is re-uploaded under that canonical name and submitted — its bytes come from Tools.uploaded_drvs (populated at upload time) because under builder-rpc-v0 the .drv only exists in the daemon's store, never in the inner sandbox FS. NixOS/nix#12727 tracks accepting SingleDerivedPath::Built so the rename trick can go away. mkMesonPackage moves to a raw derivation — stdenv's _assignFirst dies when submit-output mode skips \$out/\$outputs — so NIX_CFLAGS_COMPILE suffixed by stdenv.cc.suffixSalt and PKG_CONFIG_PATH are populated by hand from nativeBuildInputs in place of cc-wrapper's setup hooks. Parallel to Path A (NixOS/nix#13768); both stay until upstream picks one.
NixOS/nix#15793 lets builds with the builder-rpc-v0 system feature talk to the daemon over the worker protocol's restricted allowlist plus a new SubmitOutput op, which removes the need for the recursive-nix subprocess dance. SubmitOutput enforces outputPathName(callingDrv.name, \"out\") on the submitted path, so the final drv is re-uploaded under that canonical name and submitted — its bytes come from Tools.uploaded_drvs (populated at upload time) because under builder-rpc-v0 the .drv only exists in the daemon's store, never in the inner sandbox FS. NixOS/nix#12727 tracks accepting SingleDerivedPath::Built so the rename trick can go away. mkMesonPackage moves to a raw derivation — stdenv's _assignFirst dies when submit-output mode skips \$out/\$outputs — so NIX_CFLAGS_COMPILE suffixed by stdenv.cc.suffixSalt and PKG_CONFIG_PATH are populated by hand from nativeBuildInputs in place of cc-wrapper's setup hooks. Parallel to Path A (NixOS/nix#13768); both stay until upstream picks one.
NixOS/nix#15793 lets builds with the builder-rpc-v0 system feature talk to the daemon over the worker protocol's restricted allowlist plus a new SubmitOutput op, which removes the need for the recursive-nix subprocess dance. SubmitOutput enforces outputPathName(callingDrv.name, \"out\") on the submitted path, so the final drv is re-uploaded under that canonical name and submitted — its bytes come from Tools.uploaded_drvs (populated at upload time) because under builder-rpc-v0 the .drv only exists in the daemon's store, never in the inner sandbox FS. NixOS/nix#12727 tracks accepting SingleDerivedPath::Built so the rename trick can go away. mkMesonPackage moves to a raw derivation — stdenv's _assignFirst dies when submit-output mode skips \$out/\$outputs — so NIX_CFLAGS_COMPILE suffixed by stdenv.cc.suffixSalt and PKG_CONFIG_PATH are populated by hand from nativeBuildInputs in place of cc-wrapper's setup hooks. Parallel to Path A (NixOS/nix#13768); both stay until upstream picks one.
NixOS/nix#15793 lets builds with the builder-rpc-v0 system feature talk to the daemon over the worker protocol's restricted allowlist plus a new SubmitOutput op, which removes the need for the recursive-nix subprocess dance. SubmitOutput enforces outputPathName(callingDrv.name, \"out\") on the submitted path, so the final drv is re-uploaded under that canonical name and submitted — its bytes come from Tools.uploaded_drvs (populated at upload time) because under builder-rpc-v0 the .drv only exists in the daemon's store, never in the inner sandbox FS. NixOS/nix#12727 tracks accepting SingleDerivedPath::Built so the rename trick can go away. mkMesonPackage moves to a raw derivation — stdenv's _assignFirst dies when submit-output mode skips \$out/\$outputs — so NIX_CFLAGS_COMPILE suffixed by stdenv.cc.suffixSalt and PKG_CONFIG_PATH are populated by hand from nativeBuildInputs in place of cc-wrapper's setup hooks. Parallel to Path A (NixOS/nix#13768); both stay until upstream picks one.
NixOS/nix#15793 lets builds with the builder-rpc-v0 system feature talk to the daemon over the worker protocol's restricted allowlist plus a new SubmitOutput op, which removes the need for the recursive-nix subprocess dance. SubmitOutput enforces outputPathName(callingDrv.name, \"out\") on the submitted path, so the final drv is re-uploaded under that canonical name and submitted — its bytes come from Tools.uploaded_drvs (populated at upload time) because under builder-rpc-v0 the .drv only exists in the daemon's store, never in the inner sandbox FS. NixOS/nix#12727 tracks accepting SingleDerivedPath::Built so the rename trick can go away. mkMesonPackage moves to a raw derivation — stdenv's _assignFirst dies when submit-output mode skips \$out/\$outputs — so NIX_CFLAGS_COMPILE suffixed by stdenv.cc.suffixSalt and PKG_CONFIG_PATH are populated by hand from nativeBuildInputs in place of cc-wrapper's setup hooks. Parallel to Path A (NixOS/nix#13768); both stay until upstream picks one.
NixOS/nix#15793 lets builds with the builder-rpc-v0 system feature talk to the daemon over the worker protocol's restricted allowlist plus a new SubmitOutput op, which removes the need for the recursive-nix subprocess dance. SubmitOutput enforces outputPathName(callingDrv.name, \"out\") on the submitted path, so the final drv is re-uploaded under that canonical name and submitted — its bytes come from Tools.uploaded_drvs (populated at upload time) because under builder-rpc-v0 the .drv only exists in the daemon's store, never in the inner sandbox FS. NixOS/nix#12727 tracks accepting SingleDerivedPath::Built so the rename trick can go away. mkMesonPackage moves to a raw derivation — stdenv's _assignFirst dies when submit-output mode skips \$out/\$outputs — so NIX_CFLAGS_COMPILE suffixed by stdenv.cc.suffixSalt and PKG_CONFIG_PATH are populated by hand from nativeBuildInputs in place of cc-wrapper's setup hooks. Parallel to Path A (NixOS/nix#13768); both stay until upstream picks one.
NixOS/nix#15793 lets builds with the builder-rpc-v0 system feature talk to the daemon over the worker protocol's restricted allowlist plus a new SubmitOutput op, which removes the need for the recursive-nix subprocess dance. SubmitOutput enforces outputPathName(callingDrv.name, \"out\") on the submitted path, so the final drv is re-uploaded under that canonical name and submitted — its bytes come from Tools.uploaded_drvs (populated at upload time) because under builder-rpc-v0 the .drv only exists in the daemon's store, never in the inner sandbox FS. NixOS/nix#12727 tracks accepting SingleDerivedPath::Built so the rename trick can go away. mkMesonPackage moves to a raw derivation — stdenv's _assignFirst dies when submit-output mode skips \$out/\$outputs — so NIX_CFLAGS_COMPILE suffixed by stdenv.cc.suffixSalt and PKG_CONFIG_PATH are populated by hand from nativeBuildInputs in place of cc-wrapper's setup hooks. Parallel to Path A (NixOS/nix#13768); both stay until upstream picks one.
NixOS/nix#15793 lets builds with the builder-rpc-v0 system feature talk to the daemon over the worker protocol's restricted allowlist plus a new SubmitOutput op, which removes the need for the recursive-nix subprocess dance. SubmitOutput enforces outputPathName(callingDrv.name, \"out\") on the submitted path, so the final drv is re-uploaded under that canonical name and submitted — its bytes come from Tools.uploaded_drvs (populated at upload time) because under builder-rpc-v0 the .drv only exists in the daemon's store, never in the inner sandbox FS. NixOS/nix#12727 tracks accepting SingleDerivedPath::Built so the rename trick can go away. mkMesonPackage moves to a raw derivation — stdenv's _assignFirst dies when submit-output mode skips \$out/\$outputs — so NIX_CFLAGS_COMPILE suffixed by stdenv.cc.suffixSalt and PKG_CONFIG_PATH are populated by hand from nativeBuildInputs in place of cc-wrapper's setup hooks. Parallel to Path A (NixOS/nix#13768); both stay until upstream picks one.
NixOS/nix#15793 lets builds with the builder-rpc-v0 system feature talk to the daemon over the worker protocol's restricted allowlist plus a new SubmitOutput op, which removes the need for the recursive-nix subprocess dance. SubmitOutput enforces outputPathName(callingDrv.name, \"out\") on the submitted path, so the final drv is re-uploaded under that canonical name and submitted — its bytes come from Tools.uploaded_drvs (populated at upload time) because under builder-rpc-v0 the .drv only exists in the daemon's store, never in the inner sandbox FS. NixOS/nix#12727 tracks accepting SingleDerivedPath::Built so the rename trick can go away. mkMesonPackage moves to a raw derivation — stdenv's _assignFirst dies when submit-output mode skips \$out/\$outputs — so NIX_CFLAGS_COMPILE suffixed by stdenv.cc.suffixSalt and PKG_CONFIG_PATH are populated by hand from nativeBuildInputs in place of cc-wrapper's setup hooks. Parallel to Path A (NixOS/nix#13768); both stay until upstream picks one.
NixOS/nix#15793 lets builds with the builder-rpc-v0 system feature talk to the daemon over the worker protocol's restricted allowlist plus a new SubmitOutput op, which removes the need for the recursive-nix subprocess dance. SubmitOutput enforces outputPathName(callingDrv.name, \"out\") on the submitted path, so the final drv is re-uploaded under that canonical name and submitted — its bytes come from Tools.uploaded_drvs (populated at upload time) because under builder-rpc-v0 the .drv only exists in the daemon's store, never in the inner sandbox FS. NixOS/nix#12727 tracks accepting SingleDerivedPath::Built so the rename trick can go away. mkMesonPackage moves to a raw derivation — stdenv's _assignFirst dies when submit-output mode skips \$out/\$outputs — so NIX_CFLAGS_COMPILE suffixed by stdenv.cc.suffixSalt and PKG_CONFIG_PATH are populated by hand from nativeBuildInputs in place of cc-wrapper's setup hooks. Parallel to Path A (NixOS/nix#13768); both stay until upstream picks one.
NixOS/nix#15793 lets builds with the builder-rpc-v0 system feature talk to the daemon over the worker protocol's restricted allowlist plus a new SubmitOutput op, which removes the need for the recursive-nix subprocess dance. SubmitOutput enforces outputPathName(callingDrv.name, \"out\") on the submitted path, so the final drv is re-uploaded under that canonical name and submitted — its bytes come from Tools.uploaded_drvs (populated at upload time) because under builder-rpc-v0 the .drv only exists in the daemon's store, never in the inner sandbox FS. NixOS/nix#12727 tracks accepting SingleDerivedPath::Built so the rename trick can go away. mkMesonPackage moves to a raw derivation — stdenv's _assignFirst dies when submit-output mode skips \$out/\$outputs — so NIX_CFLAGS_COMPILE suffixed by stdenv.cc.suffixSalt and PKG_CONFIG_PATH are populated by hand from nativeBuildInputs in place of cc-wrapper's setup hooks. Parallel to Path A (NixOS/nix#13768); both stay until upstream picks one.
NixOS/nix#15793 lets builds with the builder-rpc-v0 system feature talk to the daemon over the worker protocol's restricted allowlist plus a new SubmitOutput op, which removes the need for the recursive-nix subprocess dance. SubmitOutput enforces outputPathName(callingDrv.name, \"out\") on the submitted path, so the final drv is re-uploaded under that canonical name and submitted — its bytes come from Tools.uploaded_drvs (populated at upload time) because under builder-rpc-v0 the .drv only exists in the daemon's store, never in the inner sandbox FS. NixOS/nix#12727 tracks accepting SingleDerivedPath::Built so the rename trick can go away. mkMesonPackage moves to a raw derivation — stdenv's _assignFirst dies when submit-output mode skips \$out/\$outputs — so NIX_CFLAGS_COMPILE suffixed by stdenv.cc.suffixSalt and PKG_CONFIG_PATH are populated by hand from nativeBuildInputs in place of cc-wrapper's setup hooks. Parallel to Path A (NixOS/nix#13768); both stay until upstream picks one.
NixOS/nix#15793 lets builds with the builder-rpc-v0 system feature talk to the daemon over the worker protocol's restricted allowlist plus a new SubmitOutput op, which removes the need for the recursive-nix subprocess dance. NixOS/nix#12727 tracks accepting SingleDerivedPath::Built so the rename trick can go away. mkMesonPackage moves to a raw derivation — stdenv's _assignFirst dies when submit-output mode skips \$out/\$outputs — so NIX_CFLAGS_COMPILE suffixed by stdenv.cc.suffixSalt and PKG_CONFIG_PATH are populated by hand from nativeBuildInputs in place of cc-wrapper's setup hooks. Parallel to Path A (NixOS/nix#13768); both stay until upstream picks one. Co-Authored-By: Artemis Tosini <artemis.tosini@obsidian.systems>
NixOS/nix#15793 lets builds with the builder-rpc-v0 system feature talk to the daemon over the worker protocol's restricted allowlist plus a new SubmitOutput op, which removes the need for the recursive-nix subprocess dance. NixOS/nix#12727 tracks accepting SingleDerivedPath::Built so the rename trick can go away. mkMesonPackage moves to a raw derivation — stdenv's _assignFirst dies when submit-output mode skips \$out/\$outputs — so NIX_CFLAGS_COMPILE suffixed by stdenv.cc.suffixSalt and PKG_CONFIG_PATH are populated by hand from nativeBuildInputs in place of cc-wrapper's setup hooks. Parallel to Path A (NixOS/nix#13768); both stay until upstream picks one. Co-Authored-By: Artemis Tosini <artemis.tosini@obsidian.systems>
NixOS/nix#15793 lets builds with the builder-rpc-v0 system feature talk to the daemon over the worker protocol's restricted allowlist plus a new SubmitOutput op, which removes the need for the recursive-nix subprocess dance. NixOS/nix#12727 tracks accepting SingleDerivedPath::Built so the rename trick can go away. mkMesonPackage moves to a raw derivation — stdenv's _assignFirst dies when submit-output mode skips \$out/\$outputs — so NIX_CFLAGS_COMPILE suffixed by stdenv.cc.suffixSalt and PKG_CONFIG_PATH are populated by hand from nativeBuildInputs in place of cc-wrapper's setup hooks. Parallel to Path A (NixOS/nix#13768); both stay until upstream picks one. Co-Authored-By: Artemis Tosini <artemis.tosini@obsidian.systems>
…outputs. Although the tests use libnix-store, the protocol is simple enough that it can be implemented by others relatively easily. Co-Authored-By: John Ericson <John.Ericson@Obsidian.Systems> Co-Authored-By: Artemis Tosini <artemis.tosini@obsidian.systems>
NixOS/nix#15793 lets builds with the builder-rpc-v0 system feature talk to the daemon over the worker protocol's restricted allowlist plus a new SubmitOutput op, which removes the need for the recursive-nix subprocess dance. NixOS/nix#12727 tracks accepting SingleDerivedPath::Built so the rename trick can go away. mkMesonPackage moves to a raw derivation — stdenv's _assignFirst dies when submit-output mode skips \$out/\$outputs — so NIX_CFLAGS_COMPILE suffixed by stdenv.cc.suffixSalt and PKG_CONFIG_PATH are populated by hand from nativeBuildInputs in place of cc-wrapper's setup hooks. Parallel to Path A (NixOS/nix#13768); both stay until upstream picks one. - Move uploaded_drvs into BuilderRpcClient - Move rpc_client out of Tools They are different things, and are needed in different places - Remove most instances of shelling out to nix Co-Authored-By: Artemis Tosini <artemis.tosini@obsidian.systems>
NixOS/nix#15793 lets builds with the builder-rpc-v0 system feature talk to the daemon over the worker protocol's restricted allowlist plus a new SubmitOutput op, which removes the need for the recursive-nix subprocess dance. NixOS/nix#12727 tracks accepting SingleDerivedPath::Built so the rename trick can go away. mkMesonPackage moves to a raw derivation — stdenv's _assignFirst dies when submit-output mode skips \$out/\$outputs — so NIX_CFLAGS_COMPILE suffixed by stdenv.cc.suffixSalt and PKG_CONFIG_PATH are populated by hand from nativeBuildInputs in place of cc-wrapper's setup hooks. Parallel to Path A (NixOS/nix#13768); both stay until upstream picks one. - Move uploaded_drvs into BuilderRpcClient - Move rpc_client out of Tools They are different things, and are needed in different places - Remove all instances of shelling out to nix, daemon protocol handles everything now. Co-Authored-By: Artemis Tosini <artemis.tosini@obsidian.systems> Co-Authored-By: John Ericson <john.ericson@obsidian.systems>
NixOS/nix#15793 lets builds with the builder-rpc-v0 system feature talk to the daemon over the worker protocol's restricted allowlist plus a new SubmitOutput op, which removes the need for the recursive-nix subprocess dance. NixOS/nix#12727 tracks accepting SingleDerivedPath::Built so the rename trick can go away. mkMesonPackage moves to a raw derivation — stdenv's _assignFirst dies when submit-output mode skips \$out/\$outputs — so NIX_CFLAGS_COMPILE suffixed by stdenv.cc.suffixSalt and PKG_CONFIG_PATH are populated by hand from nativeBuildInputs in place of cc-wrapper's setup hooks. Parallel to Path A (NixOS/nix#13768); both stay until upstream picks one. - Move uploaded_drvs into BuilderRpcClient - Move rpc_client out of Tools They are different things, and are needed in different places - Remove all instances of shelling out to nix, daemon protocol handles everything now. - Add a test to make sure adding executable files to the store works Co-Authored-By: Artemis Tosini <artemis.tosini@obsidian.systems> Co-Authored-By: John Ericson <john.ericson@obsidian.systems>
NixOS/nix#15793 lets builds with the builder-rpc-v0 system feature talk to the daemon over the worker protocol's restricted allowlist plus a new SubmitOutput op, which removes the need for the recursive-nix subprocess dance. NixOS/nix#12727 tracks accepting SingleDerivedPath::Built so the rename trick can go away. mkMesonPackage moves to a raw derivation — stdenv's _assignFirst dies when submit-output mode skips \$out/\$outputs — so NIX_CFLAGS_COMPILE suffixed by stdenv.cc.suffixSalt and PKG_CONFIG_PATH are populated by hand from nativeBuildInputs in place of cc-wrapper's setup hooks. Parallel to Path A (NixOS/nix#13768); both stay until upstream picks one. - Move uploaded_drvs into BuilderRpcClient - Move rpc_client out of Tools They are different things, and are needed in different places - Remove all instances of shelling out to nix, daemon protocol handles everything now. - Add a test to make sure adding executable files to the store works Co-Authored-By: Artemis Tosini <artemis.tosini@obsidian.systems> Co-Authored-By: John Ericson <john.ericson@obsidian.systems>
|
I think this draft is the right place to define a dedicated builder-facing API. I would prefer not to stabilize the Nix daemon worker protocol as a derivation-facing ABI. #15793 has now merged The three operations in this PR look like the right capability boundary:
I would change how One possible API is:
This does not introduce another RPC or binary framing format. Control messages remain Varlink, and the only post-upgrade payload is one existing NAR stream. JSON-RPC 2.0 would not solve this part: its base specification defines neither stream framing nor binary transfer, whereas Varlink already provides an IDL, typed errors, introspection, and the upgrade mechanism. The same interface can be transported over:
Varlink permits any connection-oriented transport, but it does not currently define a standard Windows named-pipe address or guarantee that bindings implement one. We would therefore need a named-pipe transport implementation and address convention, without changing the Varlink call/reply semantics. For concurrent calls, the Windows listener needs multiple pipe instances or overlapped I/O. It should use Independently of transport, the service should remain per-build and capability-limited:
There is also an unresolved security rule: reference restrictions alone do not prevent a generated derivation from acquiring capabilities its parent lacked, for example by generating a fixed-output derivation that receives network access. Before stabilization, Would maintainers be open to revising this draft along those lines, using #15810 for the bootstrap-friendly client/shim story, and keeping the daemon-protocol implementation confined to experimental |
|
Thanks @domenkozar, that is very much along the line of what I was thinking for next steps, and I am glad to hear that you are interested in this feature and figuring out its details. Some things I would like to add are:
@xokdvium and I were interested in the |
|
Derivations with network access generated by cargo-dyndrv sound convenient, but I don't think they're needed in the majority of cases. e.g. before a program can generate dynamic derivations for Rust crates, it needs the full dependency tree crate manifests. By far the easiest way to accomplish this is |
|
I just noticed that JSON derivations are less flexible than ATerm, since ATerm derivations are capable of representing bytes that are not valid Unicode, but JSON is not (the specification describes it as a sequence of Unicode codepoints, not a sequence of bytes. It can then be encoded in any Unicode encoding, though Nix always uses UTF-8 iirc.) e.g. try: drv="$(nix eval --raw --expr $(echo -ne '(builtins.derivation { name = "a"; system = "x86_64-linux"; builder = "/bin/sh"; args = [ "-c" "echo -n \xfe > $out" ]; }).drvPath'))"
# succeeds
cat $drv
# succeeds
xxd $(nix build --print-out-paths $drv^out)
# fails
nix derivation show $drvThis would not be an issue with e.g. CBOR, which has native support for binary strings. |
Thanks @artemist To me that sounds like Varlink has hit a blocker, we should also strive for maximum performance. I'll start on CBOR representation of Derivation and then look into using CDDL |
|
Playing with #16429 I'm thinking we need separate protocol for generating derivations and content. |
Motivation
Just a draft PR. Really, just putting this up for ease of liking for conversation at this moment.
#8602
Context
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.