[Nix-dev] How to add file to initrd?

Tuomas Tynkkynen tuomas.tynkkynen at iki.fi
Fri Sep 11 20:03:43 CEST 2015


2015-09-11 15:05 GMT+03:00 Tomasz Czyż <tomasz.czyz at gmail.com>:
>

>
> Mhm, that's definitely not cool. I thought it will appear only inside initrd
> image :[

A copy of the initrd is always kept in /nix/store, but also the .drv file and
potentially any generated scripts (for building the initrd) might
contain the key.

> Do you think is there any other way to put this key in initrd?

GRUB supports loading multiple initrd images at once. For example,
on Arch Linux the generated grub.cfg contains this:

menuentry 'Arch Linux' --class arch --class gnu-linux /* etc. */ {
    # ...
    initrd /boot/intel-ucode.img /boot/initramfs-linux.img
}

So one approach would be to create a initrd with just the keyfile
(outside Nix), place it on the /boot partition, and then somehow
make the grub.cfg generator emit the proper initrd line(s).


More information about the nix-dev mailing list