evanjs

initramfs_structured_config

Feb 6th, 2020
45
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. { pkgs, config, lib, ... }:
  2. let
  3. initrd-tools = pkgs.buildEnv {
  4. name = "initrd-tools";
  5. paths = [ pkgs.busybox ];
  6. };
  7. initrd = pkgs.makeInitrd {
  8. contents = [
  9. {
  10. object = "${initrd-tools}/bin";
  11. symlink = "/bin";
  12. }
  13. {
  14. object = script;
  15. symlink = "/init";
  16. }
  17. ];
  18. };
  19. linuxPackages_4_4 = pkgs.linuxPackages_4_4.extend (lib.const (ksuper: {
  20. kernel = ksuper.kernel.override {
  21. configfile = ./kernel.config;
  22. structuredExtraConfig = with import (pkgs.path + "/lib/kernel.nix") {
  23. inherit lib;
  24. inherit (ksuper) version;
  25. }; {
  26. CONFIG_INITRAMFS_SOURCE = "${initrd}/initrd";
  27. };
  28. };
  29. }));
  30. script = pkgs.writeTextFile {
  31. name = "init";
  32. text = ''
  33. #!${pkgs.busybox}/bin/ash
  34. export PATH=/bin
  35. mknod /dev/kmsg c 1 11
  36. exec > /dev/kmsg 2>&1
  37. mount -t proc proc proc
  38. mount -t sysfs sys sys
  39. mount -t devtmpfs dev dev
  40. mount -t debugfs debugfs /sys/kernel/debug
  41. exec > /dev/ttyAMA0 2>&1 < /dev/ttyAMA0
  42. /bin/sh > /dev/ttyAMA0 < /dev/ttyAMA0
  43. echo sh failed
  44. '';
  45. executable = true;
  46. };
  47. in linuxPackages_4_4
RAW Paste Data