NixOS/nixpkgs — pull request #3143 by lethalman (2014-06-30 12:43:35+00:00)
Title: Allow booting nixos from a subdirectory of the root device

Assuming we are installing nixos under /nixos, we mount --rbind /nixos /mnt and do the usual installation.
Then in the configuration.nix:

```
boot.loader.grub.doInstall = false;

fileSystems."/mnt/root" =
{ device = "/dev/foo";
fsType = "bar";
neededForBoot = true;
};

fileSystems."/" =
{ device = "/mnt/root/nixos";
fsType = "none";
options = "bind";
};
```

Finally add a menu entry to the existing grub loader of your device with something like: `configfile (hd0,...)/nixos/boot/grub/grub.cfg`.

This PR must not be merged, I need some help on what's the best practice for factorizing bootFileSystems and closestMountPoint which are used in both grub.nix and stage-1.nix.
They are used to automatically detect the correct order of the mounts and to detect the subdirectory of the nixos installation to be used in the grub configuration. This was a choice from a discussion with @edolstra on irc.