[Nix-dev] Has someone a working setup for Kernel development with NixOS?
Matthias Beyer
mail at beyermatthias.de
Fri Jul 15 20:00:51 CEST 2016
Hi,
so here is what I've got so far... maybe my approach is nonsense, but
I don't know that (yet... feel free to point me to a better one).
It doesn't work, though, as I get:
error: value is a function while a set was expected
and I don't know why.
Here is my custom-kernel.nix. The imports are simply things which
should be in a normal configuration.nix.
Maybe someone of you has a good idea how to get this working.
-------------8<-------------
{ config, pkgs, ... }:
let
configDir = /home/m/config/nixos;
nixpkgsClone = /home/m/dev/contrib/nixpkgs;
kernelSrc = "../linux/";
kernelVersion = "4.7-custom";
customKernelFn =
{ stdenv, fetchurl, perl, buildLinux, ... } @ args:
import "${nixpkgsClone}/pkgs/os-specific/linux/kernel/generic.nix" (args // {
version = kernelVersion;
extraMeta.branch = "master";
src = kernelSrc;
kernelPatches = pkgs.kernelPatches;
features.iwlwifi = true;
features.efiBootStub = true;
features.needsCifsUtils = true;
features.canDisableNetfilterConntrackHelpers = true;
features.netfilterRPFilter = true;
})
;
customKernel = customKernelFn {
stdenv = pkgs.stdenv;
fetchurl = pkgs.fetchurl;
perl = pkgs.perl;
buildLinux = pkgs.buildLinux;
kernelPatches = with pkgs.kernelPatches;
[ kernelPatches.bridge_stp_helper
kernelPatches.qat_common_Makefile
kernelPatches.hiddev_CVE_2016_5829
]
++ lib.optionals ((platform.kernelArch or null) == "mips")
[ kernelPatches.mips_fpureg_emu
kernelPatches.mips_fpu_sigill
kernelPatches.mips_ext3_n32
];
};
customKernelPackages = pkgs.recurseIntoAttrs
(pkgs.linuxPackagesFor customKernel pkgs.linuxPackages_custom);
in
{
imports = [
# Base configuration
"${configDir}/base-configuration.nix"
# Program configuration
"${configDir}/programs/default.nix"
# Filesystem additions
"${configDir}/fs/yuu.nix"
# Users
"${configDir}/users/m.nix"
# Services
"${configDir}/services/sshServer.nix"
"${configDir}/services/x.nix"
];
boot.kernelPackages = customKernelPackages;
# Define on which hard drive you want to install Grub.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.initrd.availableKernelModules = [ "ehci_pci" "ahci" "usb_storage" ];
boot.initrd.kernelModules = [ "fbcon" "kvm-intel" ];
boot.initrd.luks.cryptoModules = [ "aes" "sha256" "sha1" "cbc" ];
networking = {
hostName = "yuu-kernelvm";
nameservers = [ "8.8.8.8" "8.8.4.4" ];
wireless.enable = false;
useDHCP = false;
};
nixpkgs.config.allowUnfree = false;
environment.variables = {
CONFIG_DIR = "~/config";
EDITOR = "nvim";
};
environment.systemPackages = let
basePkgs = import "${configDir}/pkgs/basePackages.nix" pkgs;
analyzePkgs = import "${configDir}/pkgs/analyzePackages.nix" pkgs;
devPkgs = import "${configDir}/pkgs/devPackages.nix" pkgs;
docPkgs = import "${configDir}/pkgs/docPackages.nix" pkgs;
networkingPkgs = import "${configDir}/pkgs/networkingPackages.nix" pkgs;
nvimPkgs = import "${configDir}/pkgs/neovim.nix" pkgs;
in
basePkgs ++
analyzePkgs ++
devPkgs ++
docPkgs ++
networkingPkgs ++
nvimPkgs;
}
------------->8-------------
On 27-06-2016 21:50:38, Layus wrote:
> 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
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
--
Mit freundlichen Grüßen,
Kind regards,
Matthias Beyer
Proudly sent with mutt.
Happily signed with gnupg.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160715/2af043c4/attachment.sig>
More information about the nix-dev
mailing list