Dynamic Derivations + Dynamic build graphs: next steps

After the long-history (see below) of Dynamic Derivations we are at a point where there are many groups exploring the feature and I am proposing a working group to:

  • share the experiences of the implementors
  • refine the user experience based on usage of the various PoCs
  • determine infrastructure needs
  • deduplicate work
  • raise awareness
  • build momentum for adoption
  • … anything else relevant

I believe this feature has the potential to be a game-changer. Faster rebuilds, easier development, reduced pressure on CI systems, cacheable and alternative forms of instantiation, less need for “lang2nix”, close the gap with Bazel, and fine-grained incremental builds. Along with the existing work on better schedulers, RBE-style remote builders, bytecode evaluation, parallel eval, memory optimizations (thanks @xokdvium !), and so much more - this is an exciting time for Nix and I can see DynDrvs as a way to fix some of the outstanding UX issues Nix has in day-to-day usage. There is even work to make IFD more performant, there is lots of design space to explore here. This should be a part of what Nix has to offer the world. @Ericson2314 has devoted years to this, and it deserves the payoff of becoming a mature feature.

This is a call to action. Let’s consider collaboration and a semimonthly meeting to at least say hello + consider next steps: Dynamic Derivations Working Group - Crab Fit

History

Dynamic Derivations have been in-progress for a long time. This has much of the history that I can put together. Let me know if this can be more complete. (and if anyone can help move/migrate into the wiki?)

42 Likes

Existing! Is the invitation only for people who’ve done some related work, or are people interested in learning more about it (and potentially use it) are also invited?

3 Likes

It’s open to a variety of participants. For a while it took specialized expertise to meaningfully contribute, but now that has changed. We need end-users, documenters, testers, tutorial authors, library authors, developers, integrators, and so forth.

So yes. Anything helps.

1 Like

Calling all aarch64-darwin users: help reproduce a Potential Upstream Nix Dynamic Derivations Issue

Hi everyone,

@tomberek and I have been debugging an issue with Sandstone and nixgg on macOS (aarch64-darwin) using a master branch Nix build with the following features enabled:

  • builder-rpc-v0
  • ca-derivations
  • dynamic-derivations

We’re trying to determine whether this is reproducible on more than one Darwin machine, and we’d really appreciate your help if you’re running a Darwin system.

What we’re seeing

When building the Sandstone example derivation, we hit this error:

building '/nix/store/8mdr07snb49axrfkhx88gn771ks69czw-sandstone-dyn-drvs-on-example.drv'...
sandstone-dyn-drvs-on-example> + echo /nix/store/wy51zbjg46lhxlivfqszl1jvmjdkvvac-coreutils-9.5/bin
sandstone-dyn-drvs-on-example> /nix/store/wy51zbjg46lhxlivfqszl1jvmjdkvvac-coreutils-9.5/bin
sandstone-dyn-drvs-on-example> + /nix/store/6hw535bcfaxkncfz6y575nlwg2jcfyv9-ghc-9.6.6/bin/ghc -o /nix/store/ciqp18j8bsg5xhc5a8rfv3q0vgbxkv5i-sandstone-dyn-drvs-on-example /nix/store/y3qjknhz2c45sxs4yms8ngj8784r1007-compile-A-object/A.o /nix/store/70r2jcb3rbk79n57bxkz3858aa1yz9kb-compile-B-object/B.o /nix/store/7cz43zchdmn0fva9g1mnavsy9ykxswp3-compile-C-object/C.o /nix/store/ak0rd83cmji6fxpwb84n7n28g3k68lw6-compile-D-object/D.o /nix/store/shsvkxbkjp4yyzjiqgaj0024pdfw2x9z-compile-Main-object/Main.o /nix/store/g0gm8xbjnkzl42fl83nyfl0dj8zixrzf-compile-Nested.E-object/Nested/E.o /nix/store/5x9fixvbjk4l00v5nzy1b0mnd7qwfwmy-compile-X-object/X.o
error: cannot operate on output 'out' of the unbuilt derivation '/nix/store/j4v89slzf43jm6fdcghqby7gg8lmw0f1-sandstone-dyn-drvs-on-example.drv.drv'

Setup notes

  • For Sandstone, you’ll need to temporarily comment out the recursive-nix required feature and In WriteDerivation.hs, change x86_64-linux to aarch64-darwin (until @Ericson2314 pushes a fix later).

How you can help

If you have an aarch64-darwin machine and can test this setup, please let us know if you get the same output we are seeing.

This will help us narrow down whether this is a Nix issue.

Thanks! Hope we can fix this issue before 2.36 gets released!

1 Like

In my aarch64-darwin VM, I’m only able to reproduce your error by using a Nix client older than version 2.35. That is, with Nix daemon version 2.35.0 or master commit 85f1926, and Nix client version 2.34.8:

building '/nix/store/8mdr07snb49axrfkhx88gn771ks69czw-sandstone-dyn-drvs-on-example.drv'...
sandstone-dyn-drvs-on-example> + echo /nix/store/wy51zbjg46lhxlivfqszl1jvmjdkvvac-coreutils-9.5/bin
sandstone-dyn-drvs-on-example> /nix/store/wy51zbjg46lhxlivfqszl1jvmjdkvvac-coreutils-9.5/bin
sandstone-dyn-drvs-on-example> + /nix/store/6hw535bcfaxkncfz6y575nlwg2jcfyv9-ghc-9.6.6/bin/ghc -o /nix/store/ciqp18j8bsg5xhc5a8rfv3q0vgbxkv5i-sandstone-dyn-drvs-on-example /nix/store/y3qjknhz2c45sxs4yms8ngj8784r1007-compile-A-object/A.o /nix/store/70r2jcb3rbk79n57bxkz3858aa1yz9kb-compile-B-object/B.o /nix/store/7cz43zchdmn0fva9g1mnavsy9ykxswp3-compile-C-object/C.o /nix/store/ak0rd83cmji6fxpwb84n7n28g3k68lw6-compile-D-object/D.o /nix/store/shsvkxbkjp4yyzjiqgaj0024pdfw2x9z-compile-Main-object/Main.o /nix/store/g0gm8xbjnkzl42fl83nyfl0dj8zixrzf-compile-Nested.E-object/Nested/E.o /nix/store/5x9fixvbjk4l00v5nzy1b0mnd7qwfwmy-compile-X-object/X.o
error: cannot operate on output 'out' of the unbuilt derivation '/nix/store/j4v89slzf43jm6fdcghqby7gg8lmw0f1-sandstone-dyn-drvs-on-example.drv.drv'

If it’s flipped (daemon version 2.34.8, and client version 2.35.0 or master commit 85f1926), I get a different error:

building '/nix/store/8mdr07snb49axrfkhx88gn771ks69czw-sandstone-dyn-drvs-on-example.drv'...
sandstone-dyn-drvs-on-example> + echo /nix/store/wy51zbjg46lhxlivfqszl1jvmjdkvvac-coreutils-9.5/bin
sandstone-dyn-drvs-on-example> /nix/store/wy51zbjg46lhxlivfqszl1jvmjdkvvac-coreutils-9.5/bin
sandstone-dyn-drvs-on-example> + /nix/store/6hw535bcfaxkncfz6y575nlwg2jcfyv9-ghc-9.6.6/bin/ghc -o /nix/store/ciqp18j8bsg5xhc5a8rfv3q0vgbxkv5i-sandstone-dyn-drvs-on-example /nix/store/y3qjknhz2c45sxs4yms8ngj8784r1007-compile-A-object/A.o /nix/store/70r2jcb3rbk79n57bxkz3858aa1yz9kb-compile-B-object/B.o /nix/store/7cz43zchdmn0fva9g1mnavsy9ykxswp3-compile-C-object/C.o /nix/store/ak0rd83cmji6fxpwb84n7n28g3k68lw6-compile-D-object/D.o /nix/store/shsvkxbkjp4yyzjiqgaj0024pdfw2x9z-compile-Main-object/Main.o /nix/store/g0gm8xbjnkzl42fl83nyfl0dj8zixrzf-compile-Nested.E-object/Nested/E.o /nix/store/5x9fixvbjk4l00v5nzy1b0mnd7qwfwmy-compile-X-object/X.o
warning: the daemon is missing the 'realisation-with-path-not-hash' protocol feature, needed to support content-addressing derivations
error:
       … looking up realisation for derivation '/nix/store/j4v89slzf43jm6fdcghqby7gg8lmw0f1-sandstone-dyn-drvs-on-example.drv.drv'

       error: cannot operate on output 'out' of the unbuilt derivation '/nix/store/j4v89slzf43jm6fdcghqby7gg8lmw0f1-sandstone-dyn-drvs-on-example.drv.drv'

With both the daemon and the client at either version 2.35.0 or master commit 85f1926, I get no error:

building '/nix/store/8mdr07snb49axrfkhx88gn771ks69czw-sandstone-dyn-drvs-on-example.drv'...
sandstone-dyn-drvs-on-example> + echo /nix/store/wy51zbjg46lhxlivfqszl1jvmjdkvvac-coreutils-9.5/bin
sandstone-dyn-drvs-on-example> /nix/store/wy51zbjg46lhxlivfqszl1jvmjdkvvac-coreutils-9.5/bin
sandstone-dyn-drvs-on-example> + /nix/store/6hw535bcfaxkncfz6y575nlwg2jcfyv9-ghc-9.6.6/bin/ghc -o /nix/store/ciqp18j8bsg5xhc5a8rfv3q0vgbxkv5i-sandstone-dyn-drvs-on-example /nix/store/y3qjknhz2c45sxs4yms8ngj8784r1007-compile-A-object/A.o /nix/store/70r2jcb3rbk79n57bxkz3858aa1yz9kb-compile-B-object/B.o /nix/store/7cz43zchdmn0fva9g1mnavsy9ykxswp3-compile-C-object/C.o /nix/store/ak0rd83cmji6fxpwb84n7n28g3k68lw6-compile-D-object/D.o /nix/store/shsvkxbkjp4yyzjiqgaj0024pdfw2x9z-compile-Main-object/Main.o /nix/store/g0gm8xbjnkzl42fl83nyfl0dj8zixrzf-compile-Nested.E-object/Nested/E.o /nix/store/5x9fixvbjk4l00v5nzy1b0mnd7qwfwmy-compile-X-object/X.o
/nix/store/b8n9rxn28m7l2cvvrl20himz1xfvsami-sandstone-dyn-drvs-on-example

And if both the daemon and the client are version 2.34.8, I get no error and a different path:

building '/nix/store/8mdr07snb49axrfkhx88gn771ks69czw-sandstone-dyn-drvs-on-example.drv'...
sandstone-dyn-drvs-on-example> + echo /nix/store/wy51zbjg46lhxlivfqszl1jvmjdkvvac-coreutils-9.5/bin
sandstone-dyn-drvs-on-example> /nix/store/wy51zbjg46lhxlivfqszl1jvmjdkvvac-coreutils-9.5/bin
sandstone-dyn-drvs-on-example> + /nix/store/6hw535bcfaxkncfz6y575nlwg2jcfyv9-ghc-9.6.6/bin/ghc -o /nix/store/ciqp18j8bsg5xhc5a8rfv3q0vgbxkv5i-sandstone-dyn-drvs-on-example /nix/store/y3qjknhz2c45sxs4yms8ngj8784r1007-compile-A-object/A.o /nix/store/70r2jcb3rbk79n57bxkz3858aa1yz9kb-compile-B-object/B.o /nix/store/7cz43zchdmn0fva9g1mnavsy9ykxswp3-compile-C-object/C.o /nix/store/ak0rd83cmji6fxpwb84n7n28g3k68lw6-compile-D-object/D.o /nix/store/shsvkxbkjp4yyzjiqgaj0024pdfw2x9z-compile-Main-object/Main.o /nix/store/g0gm8xbjnkzl42fl83nyfl0dj8zixrzf-compile-Nested.E-object/Nested/E.o /nix/store/5x9fixvbjk4l00v5nzy1b0mnd7qwfwmy-compile-X-object/X.o
/nix/store/bfg8z4lsi08mbs6wm6a02yj368d6vvrr-sandstone-dyn-drvs-on-example
4 Likes

One more small contribution: dynamic-derivation-based builds for Go: GitHub - dnr/dgd: Dynamic Go Derivations — fine-grained Go builds for Nix · GitHub

It’s a drop-in replacement for buildGoModule, but missing a bunch of features, and I would only call it alpha quality.

3 Likes

RE: title, how about “Dynamic Build Graphs” or simply “Dynamism” instead of referencing the specific implementation approach :upside_down_face:

  1. “Dynamic Derivations”
  2. Look inside
  3. recursive-nix
2 Likes

Idea inspired by this, make can also output a build graph and because kbuild ( kernel’s build system ) has a makefile per directly, it may allow very fine grained kernel builds, aka per possibly per config option.

2 Likes

Looking at the Crab fit availability, looks most can make:

PST / PDT (Pacific Time): 10:00 AM Thursdays

EST / EDT (Eastern Time): 1:00 PM Thursdays

GMT / UTC (Greenwich Mean Time): 6:00 PM Thursdays (if there is timezone confusion, then this time is the one-true time)

CET (Central European Time): 7:00 PM Thursdays

Video link: Jitsi Meet

6 Likes

Ah gawddamit, I kept forgetting to fill this ~~"

EDIT: thanks for the clarification re: meeting time. I’ll try to make at least part of it, if it’s 1800 GMT then.

I’m focusing mostly on Ninja-based stuff first (so ultimately AOSP, probably with stops at LLVM and Chromium for faster iteration on scale problems), but it’s one of things I wanted to try next after it and I’m trying to write the code so it can be extended with non-Ninja build graph edges without turning everything upside down. So if nobody else beats me to this, then it’s going to happen at some point anyway.

3 Likes

I’ve sent out an invite to those for whom I have emails. If I’ve missed you, please ping me with an email.

1 Like

Currently I am trying to either parse the .cmd files the kernel leaves ( which themselves are evaluated gcc commands ) after a compile or look at how something like kninja does it.