You might have found that one already: https://github.com/nix-community/nix-environments/tree/master/envs/openwrt
This provides the environment for building openwrt. The first thing you would need to do is packaging their SDK, which is basically the build toolchain that includes all their compiler, linker and other build-tools. I see several options there in increasing order of difficulty
- Download & Patchelf their SDK (take a look at our android infrastructure: https://github.com/NixOS/nixpkgs/pull/50596)
- Use our pkgsCross to emulate their SDK with our build tools (don’t forgot that we use cc-wrappers, so use the unwrapped compilers).
- Try to build the SDK (I had problems with NixOS doing that, they had a few shebangs, but something forced me to use buildFHSUserEnv but I no longer remember the exact issues)
From their one could make use of their data structures to import their checksums into nix with by sourcing their checksums with make and to download them with fetchurl:
If you can extract the packages that a particular openwrt config tries to build then you could make sure to download all sources ahead of time and maybe split each package into its own derivation followed by a final image building step.
The openwrt buildsystem is stupid but quiet effective at hiding useful error message from the user, to debug it is useful to remove some
2>/dev/null redirections from their Makefiles or use something like
sysdig -c stderr. I am also on 35c3 and also abradar is. I am not so much interested in pulling that exact project of as this is quiet a lot of work I would rather like to put into improving our cross-compiling infrastructure, but I would be at the assembly, if you want to discuss some details.