[Nix-dev] Using Nix to build embedded linux firmware

Michael Raskin 7c6f434c at mail.ru
Mon May 21 10:48:25 CEST 2012


>Cross Compilation
>	There seems to be some work in the nixpkgs tree that deals with
>	cross builds (pkgs/top-level/release-cross.nix). It would be interesing
>	to hear from the people who are behind this. Are cross
>	builds alive and supported?

It works, it is used, it may require some fixing for your specific 
target.

>Nix's binary size and runtime requirements:
>	Our usual size limit for images is 8MB compressed. With an image
>	that small, we need to be really picky about what goes in
>	and what doesn't. Quick measurement shows that Nix + libraries
>	take ~10MB on disk. AFAIK, Nix also requires the C++ STL.
>
>	The size is only a problem for small devices which
>	have a very limited amount of flash memory available.
>	Those devices might also not be able to execute
>	Nix expressions because their CPU power and main memory is
>	limited. It seems Nix wasn't really designed to
>	run in resource-constrained environments.
>
>	Has anybody run into similar issues before?

Cross-builds could alleviate this problem. It is quite easy to prepare
an archive with everything needed by a cross-built expression. 

You may need to patch stdenv, though, as you could need a smaller libc
and busybox instead of glibc and coreutils. There is some support for
that, but you'll likely need to tune it for your use case.

Another question is updating.. Nix model may mean that you will have to
do more writes (whether with deploying cross-builds or not).

>Remote installation of packages:
>	As a follow-up thought to the last one, would it be possible
>	to update an installation remotely, with only a very limited set of
>	tools being present? I've looked at Disnix, and the README says
>	that all target hosts need to have Nix (and Nixpkgs) installed,
>	which is unfortunate but understandable given its intended
>	use case (server/cluster deployment).
>
>	The Nix store file structure seems simple
>	enough to allow remote management. Is this correct?

Technically, it would be possible to have a mirror nix store on a normal
computer and sync device with it (as path contents should not change, 
you need only to copy new paths and delete obsolete ones, not change 
anything).

>Configuration changes:
>	System configuration (networking, services...) is not part of Nixpkgs
>	but is kept in the NixOS tree. This is good, because we have very
>	specific needs in terms of network configuration and implement
>	it ourselves anyway.
>
>	How does Nix handle pre/post upgrade scripts? As far as I understand,
>	the Nixpkgs tree only contains build instructions, any output is created
>	at compile time.

Nix doesn't support this. You would probably have to generate them and
then create a minimal tool to run these scripts on configuration 
changes. In a sense, NixOS is an example of such a tool. Note that it 
gets no support from Nix per se for configuration activation.





More information about the nix-dev mailing list