[Nix-dev] Trying to build L4Linux kernel on NixOS: how to cross-compile?

Mateusz Czaplinski czapkofan at gmail.com
Fri Apr 7 01:44:24 CEST 2017


Ok, I believe I have gotten through this. First of all, I unfortunately
erroneously quoted my original code in the previous message: the last line
I had before was `kernel.crossDrv`, not `kernel`. And actually changing it
to `kernel`, per
https://github.com/NixOS/nixpkgs/issues/24388#issuecomment-289613711, seems
to have gotten me further. What I have now is roughly (hope no errors this
time):

with import <nixpkgs> {
  crossSystem = {
    [...]
    platform = {
      kernelArch = "l4";
      [...]
    };
  };
}
let
  nixpkgs = path;
  l4re = stdenv.mkDerivation { [...] };
  kernel = { [...] };
in
  kernel;

and it appears I've started getting errors complaining about missing fields
in crossSystem (e.g. kernelMajor, etc.), which I believe I can now try
squashing one by one.

Best Regards,
/Mateusz.

On Mon, Apr 3, 2017 at 9:13 PM, Mateusz Czaplinski <czapkofan at gmail.com>
wrote:

> I'm testing my luck trying to get L4Linux kernel running on NixOS. I tried
> to get the L4Linux kernel to build (it uses the regular kernel
> infrastructure) with an expression like below (full contents at:
> https://github.com/akavel/l4.nix/blob/9fb900a88619eb4830710e531cd3f0
> 76d74b584d/l4linux.nix):
>
> [...]
>   kernel =
>     pkgs.callPackage "${nixpkgs}/pkgs/os-specific/linux/kernel/generic.nix"
> (rec {
>       version = "4.7.0-l4-2016082114";  # TODO(akavel): ok or not?
>       modDirVersion = "4.7.0-l4";  # see: nixpkgs issue #17801 and
> linux-mptcp.nix
>       src = l4re;
>       kernelPatches = [];
>     });
> in
>   kernel
>
> But then I found out [1], that this actually builds a *vanilla* (non-L4)
> kernel, because of nonempty argument ARCH passed to make by
> <nixpkgs>/.../kernel/generic.nix. To fix this, I believe I need to use
> the cross-compilation infrastructure of Nix, so that generic.nix would see
> stdenv.cross.platform.kernelArch == "l4", and thus pass it as ARCH="l4"
> to make. Now, based on some rudimentary info in The Nixpkgs  Manual +
> linked wiki, I tried changing the final line to read "kernel.crossDrv",
> then putting various variants of:
>
>   crossSystem = { platform = { kernelArch = "l4"; }; };
>
> in various places (including the {} just after `import <nixpkgs>`, or the
> {} just after pkgs.callPackage), also supplemented with more fields stolen
> from <nixpkgs>/.../platforms.nix's pcBase or from some random snippets
> found on The Internets. But whatever I tried to do, nix-build always seemed
> to reject my courting with a blunt:
>
>   error: attribute `crossDrv' missing, at <path>/l4linux.nix:<line>:<
> column>
>
> What should I do to make it happy?
>
> Also, as a somewhat related question: what exactly triggers appearance of
> a .crossDrv attribute in a derivation? (Is there some place in nixpkgs
> where I can find the code for that?)
>
> Thanks & Best Regards,
> /Mateusz.
>
>   [1]: http://os.inf.tu-dresden.de/pipermail/l4-hackers/2017/007995.html
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20170407/8a022f1d/attachment.html>


More information about the nix-dev mailing list