liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

default.nix (905B)


      1 {
      2   busybox,
      3   pkgsBuildBuild,
      4   runCommand,
      5   cpio,
      6   writeReferencesToFile,
      7   writeScript,
      8 }:
      9 let
     10   inherit (pkgsBuildBuild) gen_init_cpio;
     11   script = writeScript "init" ''
     12     #!/bin/sh
     13     exec >/dev/console
     14     echo Running in initramfs
     15     PATH=${busybox}/bin:$PATH
     16     export PATH
     17     mount -t proc none /proc
     18     mount -t sysfs none /sys
     19     ${busybox}/bin/sh
     20   '';
     21   refs = writeReferencesToFile busybox;
     22 in
     23 runCommand "initramfs.cpio" { } ''
     24   cat << SPECIALS | ${gen_init_cpio}/bin/gen_init_cpio /dev/stdin > out
     25   dir /proc 0755 0 0
     26   dir /sys 0755 0 0
     27   dir /dev 0755 0 0
     28   nod /dev/console 0600 0 0 c 5 1
     29   nod /dev/mtdblock0 0600 0 0 b 31 0
     30   dir /nix 0755 0 0
     31   dir /nix/store 0755 0 0
     32   dir /bin 0755 0 0
     33   file /bin/sh  ${busybox}/bin/sh 0755 0 0
     34   file /init ${script} 0755 0 0
     35   SPECIALS
     36   find $(cat ${refs}) | ${pkgsBuildBuild.cpio}/bin/cpio -H newc -o -A -v -O out
     37   cp out $out
     38 ''