SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. { pkgs ? import <nixpkgs> {} }: with pkgs;
  2. let linuxPackages = callPackage /etc/nixos/thirtythree/kernel.nix {}; in
  3. rec {
  4.   linux = linuxPackages.kernel;
  5.   initrd = (makeInitrd {
  6.     contents = [
  7.       { object = init; symlink = "/sbin/init"; }
  8.       { object = init; symlink = "/init"; }
  9.       { object = "${modulesClosure}/lib"; symlink = "/lib"; }
  10.     ];
  11.   }).overrideAttrs (o: {
  12.     makeUInitrd = false;
  13.   });
  14.   modulesClosure = makeModulesClosure {
  15.     kernel = aggregateModules [ linuxPackages.kernel linuxPackages.zfs linuxPackages.spl ];
  16.     rootModules = ["zfs"];
  17.     firmware = [];
  18.   };
  19.   init = writeScript "init" ''
  20.     #!${busybox}/bin/ash -x
  21.     ${busybox}/bin/mknod /dev/console c 5 1
  22.     ${busybox}/bin/mknod /dev/null c 1 3
  23.     ${busybox}/bin/mknod /dev/ttyFIQ0 c 254 0
  24.     echo "Hello, world!"
  25.     echo "Hello, console!" > /dev/console
  26.     echo "Hello, tty!" > /dev/ttyFIQ0
  27.     export PATH=${busybox}/bin:${pkgs.zfs}/bin
  28.     mkdir -p /proc
  29.     mount -t proc proc /proc
  30.     mkdir -p /sys
  31.     mount -t sysfs sys /sys
  32.     mkdir -p /etc
  33.     echo $'\x99\x33\x99\x33' > /etc/hostid
  34.  
  35.     modprobe zfs
  36.     (
  37.     cd /sys
  38.     for dev in devices/virtual/misc/zfs block/* ; do
  39.       ( . $dev/uevent
  40.       type=c
  41.       [[ $dev = *block* ]] && type=b
  42.       mknod /dev/$DEVNAME $type $MAJOR $MINOR
  43.       ) &
  44.     done
  45.     wait
  46.     )
  47.     mkdir -p /mnt
  48.     zpool import -N thirtythree
  49.     mount.zfs -o zfsutil thirtythree/nixos/root /mnt
  50.     mount.zfs -o zfsutil thirtythree/nixos/nix /mnt/nix
  51.     exec ash
  52.   '';
  53.   nspawn = writeScript "nspawn" ''
  54.     #!${stdenv.shell}
  55.     exec unshare -m ${nspawnReal} "$@"
  56.   '';
  57.   nspawnReal = writeScript "nspawn-real" ''
  58.     #!${stdenv.shell}
  59.     mount -t tmpfs tmpfs /tmp
  60.     cd /tmp
  61.     gzip -d < ${initrd}/initrd | cpio -i
  62.     exec chroot . /sbin/init
  63.   '';
  64.   kexec = writeScript "kexec" ''
  65.     #!${stdenv.shell}
  66.     set -ex
  67.     kexec -l ${linux}/Image --initrd ${initrd}/initrd --append "console=ttyFIQ0 panic=10 loglevel=4" --dtb ${linux}/dtbs/rockchip/rk3399-nanopi4-rev01.dtb
  68.     sleep 5
  69.     echo ---------------------------------------- > /dev/console
  70.     systemctl kexec
  71.   '';
  72.   # storagemedia=sd rw root=PARTUUID=614e0000-0000 rootfstype=ext4 rootwait root=/dev/mmcblk0p1 rw rootfstype=ext4
  73.   # earlycon=uart8250,mmio32,0xff1a0000 swiotlb=1
  74.   # uboot_logo=0x02000000@0xf5c00000 loader.timestamp=2019-03-16_17:26:35 SecureBootCheckOk=0
  75. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top