summary refs log tree commit diff
path: root/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix
diff options
context:
space:
mode:
authorTuomas Tynkkynen <tuomas@tuxera.com>2017-01-24 00:52:25 +0200
committerTuomas Tynkkynen <tuomas@tuxera.com>2017-01-25 02:14:47 +0200
commit0e4c1bfb43a4558fe9c2c420a907d40e757fa585 (patch)
tree8f3be723d2bc61a4ac9cc24aab9577f0cecdc34a /nixos/modules/installer/cd-dvd/sd-image-aarch64.nix
parentb29ee6c8ff11613c545dcd332f2f3ff37b00a068 (diff)
downloadnixpkgs-0e4c1bfb43a4558fe9c2c420a907d40e757fa585.tar
nixpkgs-0e4c1bfb43a4558fe9c2c420a907d40e757fa585.tar.gz
nixpkgs-0e4c1bfb43a4558fe9c2c420a907d40e757fa585.tar.bz2
nixpkgs-0e4c1bfb43a4558fe9c2c420a907d40e757fa585.tar.lz
nixpkgs-0e4c1bfb43a4558fe9c2c420a907d40e757fa585.tar.xz
nixpkgs-0e4c1bfb43a4558fe9c2c420a907d40e757fa585.tar.zst
nixpkgs-0e4c1bfb43a4558fe9c2c420a907d40e757fa585.zip
installer: Add SD image expression for Aarch64
This one works on the Raspberry Pi 3 so far.
Diffstat (limited to 'nixos/modules/installer/cd-dvd/sd-image-aarch64.nix')
-rw-r--r--nixos/modules/installer/cd-dvd/sd-image-aarch64.nix61
1 files changed, 61 insertions, 0 deletions
diff --git a/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix b/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix
new file mode 100644
index 00000000000..517ddc75c87
--- /dev/null
+++ b/nixos/modules/installer/cd-dvd/sd-image-aarch64.nix
@@ -0,0 +1,61 @@
+{ config, lib, pkgs, ... }:
+
+let
+  extlinux-conf-builder =
+    import ../../system/boot/loader/generic-extlinux-compatible/extlinux-conf-builder.nix {
+      inherit pkgs;
+    };
+in
+{
+  imports = [
+    ../../profiles/minimal.nix
+    ../../profiles/installation-device.nix
+    ./sd-image.nix
+  ];
+
+  assertions = lib.singleton {
+    assertion = pkgs.stdenv.system == "aarch64-linux";
+    message = "sd-image-aarch64.nix can be only built natively on Aarch64 / ARM64; " +
+      "it cannot be cross compiled";
+  };
+
+  # Needed by RPi firmware
+  nixpkgs.config.allowUnfree = true;
+
+  boot.loader.grub.enable = false;
+  boot.loader.generic-extlinux-compatible.enable = true;
+
+  boot.kernelPackages = pkgs.linuxPackages_latest;
+  boot.kernelParams = ["console=ttyS0,115200n8" "console=tty0"];
+  boot.consoleLogLevel = 7;
+
+  # FIXME: this probably should be in installation-device.nix
+  users.extraUsers.root.initialHashedPassword = "";
+
+  sdImage = {
+    populateBootCommands = let
+      # Contains a couple of fixes for booting a Linux kernel, will hopefully appear upstream soon.
+      patchedUboot = pkgs.ubootRaspberryPi3_64bit.overrideAttrs (oldAttrs: {
+        src = pkgs.fetchFromGitHub {
+          owner = "dezgeg";
+          repo = "u-boot";
+          rev = "baab53ec244fe44def01948a0f10e67342d401e6";
+          sha256 = "0r5j2pc42ws3w3im0a9c6bh01czz5kapqrqp0ik9ra823cw73lxr";
+        };
+      });
+
+      configTxt = pkgs.writeText "config.txt" ''
+        kernel=u-boot-rpi3.bin
+        arm_control=0x200
+        enable_uart=1
+      '';
+      in ''
+        for f in bootcode.bin fixup.dat start.elf; do
+          cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/$f boot/
+        done
+        cp ${patchedUboot}/u-boot.bin boot/u-boot-rpi3.bin
+        cp ${configTxt} boot/config.txt
+        ${extlinux-conf-builder} -t 3 -c ${config.system.build.toplevel} -d ./boot
+      '';
+  };
+}