-
-
Save ereslibre/594494ef4403b0e534726308f34f49a9 to your computer and use it in GitHub Desktop.
Raspberry Pi 4B nixos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ lib, pkgs, ... }: { | |
nixpkgs.overlays = [ | |
(final: super: { | |
makeModulesClosure = x: | |
super.makeModulesClosure (x // { allowMissing = true; }); | |
}) | |
]; | |
systemd.network.enable = true; | |
# Enable SSH with root login | |
services.openssh = { | |
enable = true; | |
permitRootLogin = "yes"; | |
}; | |
users.users.root.openssh.authorizedKeys.keys = [ | |
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAEAQDJz9rVLqUHt9ZFjep4RsN3B5xr9s6MtHSz4PbJHACj3bA3pP7UZwePzzDMofOZLhOIKzMJ+s9H0E28ruEN8xhAv9qPYN6DI15vvPoaMu4VbzyFOGAz4UXoMQpSkr3p9E8C3psJIMpgxOAGelp7PqODlCQS/6DVMqz3DqtkOJYPssAtivH1AfitA2NVPvI9bgswAhF0jArKJmnFPSy6DAc0G2q5DyVEZVfD943kOprd7GkVWdD9FpaHqjmLGd77RfHmmqrj9Tg5+ajYa+VrASJfTBkDJ/lZcFLH9DdfcUFcQzu2pzi/cX94e+FnTtog8TOGwCrWGDAZVPP5YEHmGU3QX0NQBl4vNprWe0oJaSjSzvIT2ZrixUhOWKTjW44To/+7UwIlCc4KWL/LJ+kbwWCpiOhhWqRs380cqUmuMRaq59uTIWCRImBTkqjTqBIxaj7060GV2ZWGzbYKhUsxPchx8KJVWyGxYoox+T/zQjF1KtwvnPVghIt4hiIifYCclxoeY1yAIU5T8LvZXaqBlSYPi715mJg7533IM6NhHMg09ANgkKt6fQmQUNtaYBpHfaIaKI68oSCJOFTiP3e1RYmKaz36GQPWqEBNKT5zaIYsSOMCyLhoecH6pF9Nqvust5iIpYgNSDlRh1qnOd1AUCimyJQiswsiEQTuCClbZHg152x33/6y8CZrpHRSzDh8cBApanvtQ5pmzD4IP9mZ3eGvWaSrVx6EtpYWkr4LSoPkh2dRWHdVu+a27TLVkl7V+2dE5WAIZzRsfpAfQB3JIVD5WmTVlbU1zgIIBSXr7SfGJo0bMQ59JptE9+ffoyGWk8fnbFww2re3QTphXau9Hy+88pUqvXkiYUxsSpHzXlpRAWbfR9wqCS3adKRaz+3vZYvJGP6d66ay9NRkTGeIKxEeYjdBSNues59UGsWiJVOaR9bxfvL5+F+WyIjv9a9yOJln9NXcADp32zUlAMY97+Kw0NRQeBnpX2fF6HjNLj+onlOt50EVNYGE3fS5CW8L9nSuIY4jAycQ8xF2GYG8lGgDfaCrGTVm0cFab6ytvLRFBaKFWqcIh2rYOgKV0p7qzoadQYH5hIH/V5LGt3yRgPdwqGHNd6662n5FKlio/omE1CUpAdedA1l+geMnaIdQpDG5ghjSb8jJnoUsPYVjTLQmg7g2HAnC2ofURbKAxEVfDDIuXmLp+plyb7DGGIhj6wprnoy7mDd/YJBzf9zmRjOz1mKhrgdbSHiDvfpbs0BW5HtodYHY7R6oEU8OtXYOR2bJfoqhspz5M/vmYBbzo5P7cbpBc5b6PW/xFnt2Sabuwrem0YTWh++eDmeDgSOK5F9k4NGQZriJYg5JqICqslht" | |
]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: | |
nix-build '<nixpkgs/nixos>' -A config.system.build.sdImage -I nixos-config=./rpi4-image.nix -I nixpkgs=~/path/to/nixpkgs-checked-out-at-pr-156005 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ config, lib, pkgs, ... }: { | |
nixpkgs.crossSystem.system = "aarch64-linux"; | |
imports = [ | |
# Sd image settings | |
<nixpkgs/nixos/modules/installer/sd-card/sd-image.nix> | |
# Your configuration | |
./configuration.nix | |
]; | |
boot = { | |
kernelPackages = pkgs.linuxPackages_rpi4; | |
loader.grub.enable = false; | |
loader.generic-extlinux-compatible.enable = true; | |
consoleLogLevel = lib.mkDefault 7; | |
# The serial ports listed here are: | |
# - ttyS0: for Tegra (Jetson TX1) | |
# - ttyAMA0: for QEMU's -machine virt | |
kernelParams = | |
[ "console=ttyS0,115200n8" "console=ttyAMA0,115200n8" "console=tty0" ]; | |
initrd.availableKernelModules = [ | |
"vc4" | |
"bcm2835_dma" | |
"i2c_bcm2835" | |
]; | |
}; | |
sdImage = { | |
populateFirmwareCommands = let | |
configTxt = pkgs.writeText "config.txt" '' | |
[pi3] | |
kernel=u-boot-rpi3.bin | |
[pi4] | |
kernel=u-boot-rpi4.bin | |
enable_gic=1 | |
armstub=armstub8-gic.bin | |
# Otherwise the resolution will be weird in most cases, compared to | |
# what the pi3 firmware does by default. | |
disable_overscan=1 | |
[all] | |
# Boot in 64-bit mode. | |
arm_64bit=1 | |
# U-Boot needs this to work, regardless of whether UART is actually used or not. | |
# Look in arch/arm/mach-bcm283x/Kconfig in the U-Boot tree to see if this is still | |
# a requirement in the future. | |
enable_uart=1 | |
# 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/) | |
# Add the config | |
cp ${configTxt} firmware/config.txt | |
# Add pi3 specific files | |
cp ${pkgs.ubootRaspberryPi3_64bit}/u-boot.bin firmware/u-boot-rpi3.bin | |
# Add pi4 specific files | |
cp ${pkgs.ubootRaspberryPi4_64bit}/u-boot.bin firmware/u-boot-rpi4.bin | |
cp ${pkgs.raspberrypi-armstubs}/armstub8-gic.bin firmware/armstub8-gic.bin | |
cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-4-b.dtb firmware/ | |
''; | |
populateRootCommands = '' | |
mkdir -p ./files/boot | |
${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot | |
''; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment