First pass at armv7l images

This commit is contained in:
Craige McWhirter 2020-06-26 08:51:29 +10:00
parent 1005bad669
commit 50c59caae1
Signed by: sercanto
GPG key ID: 7DBA9F5689EFB6AA
4 changed files with 168 additions and 0 deletions

34
clusters/pi2B_rack.nix Normal file
View file

@ -0,0 +1,34 @@
# NixOps configuration for the Raspberry Pi 2B Rack
{
imports =
[
<nixpkgs/nixos/modules/installer/scan/not-detected.nix>
../hardware/raspberry_pi_2_model_B.nix
../roles/host_common.nix
../roles/pi_common.nix
../roles/server_common.nix
];
# Ensure the right package architecture is used
nixpkgs.localSystem = {
system = "armv7l-linux";
config = "armv7l-unknown-linux-gnu";
allowUnfree = true;
};
networking.wireless.enable = false; # Toggles wireless support via wpa_supplicant.
documentation = {
nixos.enable = false; # Save some space by disabling the manual
};
users.users.root = {
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDtjE0YstRzlh+Zhlj03th9DYOkMqJ5xHUcderBq151K craige@mcwhirter.io"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFq6/C6ZSM8nS091fqw/om9LRszHDmS82ZTL7+GaSBnz craige@paidh-tri"
];
};
}

View file

@ -0,0 +1,75 @@
# Configuration common to all Raspberry Pi 3 Model B devices
{ config, pkgs, lib, ... }:
{
boot = {
initrd = {
availableKernelModules = [
"bcm2835_dma" # Allows early (earlier) mode setting
"i2c_bcm2835" # Allows early (earlier) mode setting
"usbhid"
"usb_storage"
"vc4" # Allows early (earlier) mode setting
];
};
kernelPackages = pkgs.linuxPackages_latest; # For a Raspberry Pi 2 or 3)
kernelParams = [
"console=ttyS0,115200n8" # Enable the serial console
"console=ttyAMA0,115200n8"
"console=tty0"
];
loader = {
generic-extlinux-compatible = {
enable = true; # Enables the generation of /boot/extlinux/extlinux.conf
};
grub = {
enable = false; # NixOS wants to enable GRUB by default.
};
raspberryPi = {
enable = true;
version = 3;
firmwareConfig = ''
hdmi_force_hotplug=1 # Enable headless booting
'';
};
};
};
# File systems configuration for using the installer's partition layout
fileSystems = {
"/" = {
device = "/dev/disk/by-label/NIXOS_SD";
fsType = "ext4";
};
"/boot/firmware" = {
device = "/dev/disk/by-label/FIRMWARE";
fsType = "vfat";
# Alternatively, this could be removed from the configuration.
# The filesystem is not needed at runtime, it could be treated
# as an opaque blob instead of a discrete FAT32 filesystem.
options = [ "nofail" "noauto" ];
};
"/var" = {
device = "/dev/disk/by-label/var";
fsType = "ext4";
};
};
# !!! Adding a swap file is optional, but strongly recommended!
swapDevices = [ { device = "/swapfile"; size = 1024; } ];
hardware = {
enableRedistributableFirmware = true; # Enable support for Pi firmware blobs
};
networking = {
enableB43Firmware = false; # If true, enable Pi wireless firmware
};
environment.systemPackages = with pkgs; [
raspberrypi-tools # Userland tools for the Raspberry Pi board
];
}

View file

@ -0,0 +1,19 @@
# SD image for paidh-aon
#
# To build this image, run:
#
# nix-build '<nixpkgs/nixos>' -A config.system.build.sdImage -I \
# nixos-config=./images/sd-image_paidh-aon.nix
#
# An example of how to write the image to SD card:
#
# bzcat ./result/sd-image/nixos-sd-image-20.03.1577.74a80c5a9ab-aarch64-linux.img.bz2 | sudo dd of=/dev/sdb
{ ... }: {
imports = [
./sd-image_paidh-armv7.nix
../hosts/paidh-aon.nix
];
}

View file

@ -0,0 +1,40 @@
# Base image for building SD images for my Pi 2's
#
# To build, use:
# imports = [ ./sd-image_paidh-armv7.nix ]
{ config, lib, pkgs, ... }:
let
extlinux-conf-builder =
import <nixpkgs/nixos/modules/system/boot/loader/generic-extlinux-compatible/extlinux-conf-builder.nix> {
pkgs = pkgs.buildPackages;
};
in
{
imports = [
<nixpkgs/nixos/modules/profiles/base.nix>
<nixpkgs/nixos/modules/installer/cd-dvd/sd-image-armv7l-multiplatform.nix>
];
boot.consoleLogLevel = lib.mkDefault 7;
sdImage = {
populateFirmwareCommands = let
configTxt = pkgs.writeText "config.txt" ''
# Prevent the firmware from smashing the framebuffer setup done by the mainline kernel
# when attempting to show low-voltage or overtemperature warnings.
avoid_warnings=1
'';
in ''
(cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/firmware/)
cp ${pkgs.ubootRaspberryPi2}/u-boot.bin firmware/u-boot-rpi2.bin
cp ${configTxt} firmware/config.txt
'';
populateRootCommands = ''
mkdir -p ./files/boot
${extlinux-conf-builder} -t 3 -c ${config.system.build.toplevel} -d ./files/boot
'';
};
}