Understanding of nix build

I am trying to understand Linux compilation using Nix. I am referring Github repo GitHub - nspin/nix-linux: Framework for configuring and building Linux and U-Boot using Nixpkgs when I am trying to build the given example “examples/rpi4”
using command “nix-build --dry-run” It gives following error:

error: Please be informed that this pseudo-package is not the only part of
       Nixpkgs that fails to evaluate. You should not evaluate entire Nixpkgs
       without some special measures to handle failing packages, like those taken
       by Hydra.

I am completely blank on this error. Can anybody guide me in cross compiling the Linux kernel?

1 Like

(just ignore me, I confused that repo with a different one and haven’t actually checked it’s contents before posting)

It seems like you are evaluating the complete nixpkgs package set, which throws this error because it’s almost never what you’d want to do and will most certainly fail.

Instead, you should select the right attribute (= package name), that you want to build out of all the packages defined in nixpkgs.

In the tutorial in the README they define their own kernel package, called kernel, you can put this nix code in a file default.nix and then build that with nix-build -A kernel.

For the rpi4 example, they define a kernel package called my-kernel and add it to the nixpkgs package set using an overlay, so in that directory you’d build the example kernel with nix-build -A my-kernel.

1 Like

Thanks a lot. In the overlay, he has an attribute:

kernel = my-kernel;

So I thought nix-build -A kernel should also work fine, but it doesn’t.

Ah but that’s not a top-level attribute, it’s an argument passed to the callPackage function which is used to evaluate the ./module.nix file.
The value of my-module is the result of calling the callPackage function with two arguments, the file path ./module.nix and the attribute set { kernel = my-kernel; }.

You could however just rename my-kernel to kernel directly in the attribute set that defines the overlay.