Thousands of Lambdas

LambdaNix

I have a POC of running Nix in AWS Lambda: GitHub - tomberek/lambdanix
It involves several hacks and patching/hacking of libraries, but it has basic minimal function. Given all the inputs for a simple derivation, it can then go build it.

Biggest hurdles

  1. lack of root/chroot: libfakechroot.so
  2. lack of pseudoterminal in Lambda environment, Nix really wants to have one, LD_PRELOAD’ed past this with some custom horrible code.
  3. No access to /nix/store : use nixrewrite (GitHub - timjrd/nixrewrite: Prototype implementation of Nix store path rewriting)
  4. Nix kills builds too fast (or something…, perhaps Builder is sometimes unexpectedly killed · Issue #2176 · NixOS/nix · GitHub). Patch it!
  5. Custom go runtime, runs a shell script, which runs nix-store. Expected input is a JSON string base64-encoding of a NAR.

Why? (oh dear god! why?!)

As others have pointed out, dedicated servers are far more economical for continuous use. But sporadic use may benefit from a Lambda approach. And just to see what hurdles I ran into. Tested several techniques, learned a lot about LD_PRELOAD. Dug into Nix internals. Potential to use Lambdas to process simply defined workflows for jobs in the vein of funflow, fractalide, etc.

8 Likes