Refactor common unionfs-fuse initrd prep into a separate module

wip/yesman
Shea Levy 12 years ago
parent 3eb0faf317
commit e34024d998
  1. 17
      modules/installer/cd-dvd/iso-image.nix
  2. 1
      modules/module-list.nix
  3. 19
      modules/tasks/filesystems/unionfs-fuse.nix
  4. 11
      modules/virtualisation/qemu-vm.nix

@ -194,25 +194,14 @@ in
boot.initrd.availableKernelModules = [ "squashfs" "iso9660" ];
boot.initrd.kernelModules = [ "loop" "fuse" ];
boot.initrd.kernelModules = [ "loop" ];
boot.kernelModules = pkgs.stdenv.lib.optional config.isoImage.makeEfiBootable "efivars";
# Need unionfs-fuse
boot.initrd.extraUtilsCommands = ''
cp -v ${pkgs.fuse}/lib/libfuse* $out/lib
cp -v ${pkgs.unionfs-fuse}/bin/unionfs $out/bin
'';
# In stage 1, mount a tmpfs on top of / (the ISO image) and
# /nix/store (the squashfs image) to make this a live CD.
boot.initrd.postMountCommands =
''
# Hacky!!! fuse hard-codes the path to mount
mkdir -p /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${pkgs.utillinux.name}/bin
ln -s $(which mount) /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${pkgs.utillinux.name}/bin
ln -s $(which umount) /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${pkgs.utillinux.name}/bin
mkdir -p /unionfs-chroot$targetRoot
mount --rbind $targetRoot /unionfs-chroot$targetRoot
@ -318,7 +307,7 @@ in
'';
# Add vfat support to the initrd to enable people to copy the
# contents of the CD to a bootable USB stick.
boot.initrd.supportedFilesystems = [ "vfat" ];
# contents of the CD to a bootable USB stick. Need unionfs-fuse for union mounts
boot.initrd.supportedFilesystems = [ "vfat" "unionfs-fuse" ];
}

@ -214,6 +214,7 @@
./tasks/filesystems/ext.nix
./tasks/filesystems/nfs.nix
./tasks/filesystems/reiserfs.nix
./tasks/filesystems/unionfs-fuse.nix
./tasks/filesystems/vfat.nix
./tasks/filesystems/xfs.nix
./tasks/kbd.nix

@ -0,0 +1,19 @@
{ config, pkgs, ... }:
{
config = pkgs.lib.mkIf (pkgs.lib.any (fs: fs == "unionfs-fuse") config.boot.initrd.supportedFilesystems) {
boot.initrd.kernelModules = [ "fuse" ];
boot.initrd.extraUtilsCommands = ''
cp -v ${pkgs.fuse}/lib/libfuse* $out/lib
cp -v ${pkgs.unionfs-fuse}/bin/unionfs $out/bin
'';
boot.initrd.postDeviceCommands = ''
# Hacky!!! fuse hard-codes the path to mount
mkdir -p /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${pkgs.utillinux.name}/bin
ln -s $(which mount) /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${pkgs.utillinux.name}/bin
ln -s $(which umount) /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${pkgs.utillinux.name}/bin
'';
};
}

@ -252,16 +252,12 @@ in
boot.initrd.availableKernelModules =
[ "cifs" "nls_utf8" "hmac" "md4" "ecb" "des_generic" ];
# unionfs-fuse expects fuse to be loaded
boot.initrd.kernelModules = optional cfg.writableStore [ "fuse" ];
boot.initrd.supportedFilesystems = optional cfg.writableStore "unionfs-fuse";
boot.initrd.extraUtilsCommands =
''
# We need mke2fs in the initrd.
cp ${pkgs.e2fsprogs}/sbin/mke2fs $out/bin
'' + optionalString cfg.writableStore ''
cp -v ${pkgs.fuse}/lib/libfuse* $out/lib
cp -v ${pkgs.unionfs-fuse}/bin/unionfs $out/bin
'';
boot.initrd.postDeviceCommands =
@ -290,11 +286,6 @@ in
mkdir -p $targetRoot/boot
mount -o remount,ro $targetRoot/nix/store
${optionalString cfg.writableStore ''
# Hacky!!! fuse hard-codes the path to mount
mkdir -p /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${pkgs.utillinux.name}/bin
ln -s $(which mount) /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${pkgs.utillinux.name}/bin
ln -s $(which umount) /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${pkgs.utillinux.name}/bin
mkdir -p /unionfs-chroot$targetRoot
mount --rbind $targetRoot /unionfs-chroot$targetRoot

Loading…
Cancel
Save