Skip to content

Instantly share code, notes, and snippets.

@yorickvP
Last active September 21, 2019 14:44
Show Gist options
  • Save yorickvP/837cc52589b609803b0d28b3c3369e84 to your computer and use it in GitHub Desktop.
Save yorickvP/837cc52589b609803b0d28b3c3369e84 to your computer and use it in GitHub Desktop.
{ config, lib, pkgs, ... }:
let
rootfs = "/dev/disk/by-uuid/7165e542-0995-474c-a228-9592339e0604";
swapfs = "/dev/disk/by-uuid/baaf824a-bee0-4037-a237-3a69f1db7985";
in
{
# fs layout:
# before: /nixos/nix/* /boot/grub/menu.lst
# after: /nix/* /old-root/boot/grub/menu.lst
boot = {
kernelPackages = pkgs.linuxPackages_latest;
blacklistedKernelModules = ["coretemp"];
# use grub 1, don't install
loader.grub = {
version = 1;
enable = true;
storePath = "/nixos/nix/store";
extraPerEntryConfig = "root (hd0,0)"; # do we need this?
mirroredBoots = [{
path = "/old-root/boot";
devices = ["nodev"];
}];
splashImage = null;
};
initrd.availableKernelModules = [ "xen_blkfront" ];
kernelModules = [ ];
extraModulePackages = [ ];
kernelParams = ["root=${rootfs}" "boot.shell_on_fail"];
initrd = {
supportedFilesystems = [ "ext4" ];
postDeviceCommands = ''
mkdir -p /mnt-root/old-root ;
mount -t ext4 ${rootfs} /mnt-root/old-root ;
'';
};
};
fileSystems = {
"/" = {
device = "/old-root/nixos";
fsType = "none";
options = [ "bind" ];
};
"/old-root" = {
device = rootfs;
fsType = "ext4";
};
};
swapDevices = [ { device = swapfs; } ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment