[Nix-dev] Re-submission of questions
Eelco Dolstra
eelco at cs.uu.nl
Wed Apr 25 23:21:15 CEST 2007
Hi,
Sean Russell wrote:
> 1) What's the SOP for adding user-defined Nix expressions? What I mean
> is, is there a recommended place to store these things, and how should
> users contribute expressions to the project?
People who hack on Nixpkgs just have a checkout of the Nixpkgs tree
(https://svn.cs.uu.nl:12443/repos/trace/nixpkgs/trunk/). There is some (not
quite up to date) policy on where to put the Nix expression for a specific package:
https://svn.cs.uu.nl:12443/repos/trace/nixpkgs/trunk/maintainers/docs/classification.txt
Section 5.1 of the Nix manual describes what's necessary to add a package (write
a Nix expression, maybe a builder, and add a call in
pkgs/top-level/all-packages.nix). Then commit (if you have commit access -
we're pretty liberal with handing out commit access) or send a patch to the
mailing list or me. Once it's committed our build farm automatically produces a
new Nixpkgs release.
> 2) What's the recommended way for users to build their own kernels? Is
> there any procedure, or is it simply finding the kernel, running make
> menu and then modifying the grub config?
The purely functional way would be to change the kernel config passed to the Nix
expression that builds the kernel (and there should be an option for that in the
configuration file but there isn't yet).
The kernel configuration is specified in
nixpkgs/pkgs/os-specific/linux/kernel/linux-2.6.20.nix:
config =
if userModeLinux then ./config-2.6.20-uml else
if stdenv.system == "i686-linux" then ./config-2.6.20-i686-smp else
if stdenv.system == "x86_64-linux" then ./config-2.6.20-x86_64-smp else
abort "No kernel configuration for your platform!";
So you can create your own config file and change that to
config =
...
if stdenv.system == "i686-linux" then ./my-config else
...
It's also worth noting that the function linux-2.6.20.nix accepts a "patches"
arguments, which should evaluate to a list of patches to be applied to the
kernel. In all-packages.nix we apply a few patches:
kernel_2_6_20 = import ../os-specific/linux/kernel/linux-2.6.20.nix {
inherit fetchurl stdenv perl mktemp module_init_tools;
kernelPatches = [
{ name = "skas-2.6.20-v9-pre9";
patch = fetchurl {
url =
http://www.user-mode-linux.org/~blaisorblade/patches/skas3-2.6/skas-2.6.20-v9-pre9/skas-2.6.20-v9-pre9.patch.bz2;
md5 = "02e619e5b3aaf0f9768f03ac42753e74";
};
extraConfig =
"CONFIG_PROC_MM=y\n" +
"# CONFIG_PROC_MM_DUMPABLE is not set\n";
}
etc.
It's kind of nice that this way you can never forget to apply the patches you
need when you build a new kernel, it's done automatically. (Of course, the
patches may no longer apply cleanly to the new kernel, but at least then you get
an error.)
> 3) What is the Nix equivalent to Gentoo's /etc/modules.autoload.d? IE,
> where does one specify modules that should be auto-loaded?
If auto-loading simply means loading them at boot time, then there are two
configuration options: boot.initrd.extraKernelModules specifies a list of
modules to be loaded in the initial ramdisk (so these should be the modules
necessary for mounting the root device), and boot.kernelModules are the modules
loaded afterwards. Example:
{
boot = {
grubDevice = "/dev/sda";
initrd = {
extraKernelModules = ["3w_xxxx"]; # sda = a 3Ware RAID disk
};
extraKernelModules = ["kvm-intel"];
};
...
}
Note that all the dependencies of modules in boot.initrd.extraKernelModules are
automatically added to the initrd as well. So if you have "ide-disk" in there,
then "ide-core" is also added.
--
Eelco Dolstra | http://www.cs.uu.nl/~eelco
More information about the nix-dev
mailing list