[Nix-dev] Has someone a working setup for Kernel development with NixOS?

Layus layus.on at gmail.com
Mon Jun 27 21:50:38 CEST 2016


Hi,

Basically you need to build the vm attribute from 
<nixpkgs>/nixos/default.nix.

You can do this with
nix-build /path/to/nixpkgs/nixos -A vm
or even with
nixos-rebuild build-vm

You also need to specify an alternate nixos config, which you can do using

NIXOS_CONFIG=/path/to/custom/configuration.nix
or using nixos-config in nix-path (as below).

For your setup, the simplest way may be to

     NIXOS_CONFIG=/my/configuration.nix nixos-rebuild build-vm

Anyway, you will obtain a script to start the vm.

Now, bear in mind that the vm is started with QEMU & KVM, so you may 
need to tune the options if you want your developpment kernel to be 
fully used.
Read the produced script if you want more insight into qemu options.
If I remember well, in my setup the network stack of the guest was not 
used, the host kernel was used instead, even in the VM.
I am no expert, so I may be wrong. Just keep it in mind if you 
experience strange results.

You may also need to avoid full kernel compilation during dev iterations.
There may be hints at how to do that in [1].
Do not hesitate to share your final setup at the end :-).

-- Layus.

[1] http://lists.science.uu.nl/pipermail/nix-dev/2016-April/020336.html

On 27/06/16 21:10, joachifm at fastmail.fm wrote:
> On Mon, Jun 27, 2016, at 08:52 PM, Matthias Beyer wrote:
>> basically what I do with `nixos-rebuild build-vm` but from another
>> configuration.nix than my system-configuration.nix.
> You probably want something like
> ```
> $ nix-build -I nixpkgs=/my/nixpkgs -I nixos-config=/my/configuration.nix
> '<nixpkgs/nixos>' -A vm
> $ ./result/bin/run-nixos-vm
> ```
> or some variation thereof.
>
> HTH,
> Joachim
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev



More information about the nix-dev mailing list