[Nix-dev] Installing Nix from an existing Linux installation

Sean E. Russell nix at ser1.net
Sat Apr 14 16:10:49 CEST 2007


Howdy, howdy...

I recently installed Nix on a second partition and wrote up a step-by-step 
howto (attached), which I thought might be useful to some people if somebody 
wants to stick it in the Nix pages somewhere -- after doing a sanity check on 
it, of course.  Some steps I'm not sure about the correctness of (EG, steps 
5 and 12).

I have a number of questions about Nix that I'd like to ask as well.

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?

2) What's the recommended way for users to build their own kernels?

3) What is the Nix equivalent to Gentoo's /etc/modules.autoload.d?

4) Why does Nix use /dev/sd* for ATA harddrives?  This is troublesome.

5) How does one inform Nix about the existence of other operating systems, so 
that it doesn't make itself the only thing that can be booted?

Thanks, in advance.

-- 
### SER   
### Deutsch|Esperanto|Francaise|Linux|XML|Java|Ruby|Aikido|Iaido
### http://www.ser1.net  jabber.com:ser  ICQ:83578737 
### GPG: http://www.ser1.net/Security/ser_public.gpg
-------------- next part --------------
Note that NixOS uses /dev/sd* devices for everything, including ATA devices, whereas most other distributions use /dev/hd*.  This requires care when installing from an existing OS -- you can NOT simply replace sd with hd in your fstab and grub configs.

Be careful if Nix is successful in runnig Grub, as it won't respect your existing Linux installation.

1. Mount the ISO
  mkdir nixos
  mount -o loop -t iso9660 nixos-i686-linux.iso nixos
2. Mount the partition you want to install nixos on
  mount /dev/hda5 nixos/mnt
3. Mount required meta-directories
  mount -o bind /dev nixos/dev
  mount -o bind /proc nixos/proc
  mount -o sys /dev nixos/sys
  mount -t ramfs ramfs nixos/etc
  mount -t ramfs ramfs nixos/var
  mount -t ramfs ramfs nixos/nix/var
  mount -t ramfs ramfs nixos/root
4. Link /etc
  cd nixos/etc
  ln -s ../nix/store/k3ad2pb6nhvsim34bv5hafhl4yiwmvf7-etc/etc/* .
  cd ../..
5. Copy required /etc files
  cp /etc/fstab /etc/resolv.conf /etc/mtab nixos/etc/
6. Edit /etc/fstab
7. Chroot
  chroot nixos /nix/store/ylmnj7n98vz3lrpr2qp8nq8jw29sbcgs-bash-3.2/bin/bash
  export HOME=/root
  source /etc/profile
8. Setup
  mkdir -p /etc/nixos/nixos
  tar -xjf nixos.tar.bz2 -C etc/nixos/nixos 
  tar -xjf nixpkgs.tar.bz2 -C /etc/nixos/nixos --strip-components 1
  cp etc/nixos/nixos/configuration/examples/basic.nix etc/nixos/configuration.nix
9. Edit said configuration.nix
10. Run nixos-install
11. chroot to the installed directory and change the root password.  You have to make sure all of the mount bindings are also mounted in the new chroot.
12. Manually merge one (or more) of the grub kernel definitions from nixos/boot/grub/menu.lst into your own grub config and re-run grub from your main Linux install.


More information about the nix-dev mailing list