NixOS on ARM/Raspberry Pi 4: Difference between revisions

imported>Waschtl
removed general, non nixOS specific, Raspberry Pi Information
imported>N0nameuser
fix information about minimal rpi4 config,
Line 37: Line 37:
First follow the [[NixOS_on_ARM#Installation|generic installation steps]] to get the installer image and install using the [[NixOS_on_ARM#NixOS_installation_.26_configuration|installation and configuration steps]].
First follow the [[NixOS_on_ARM#Installation|generic installation steps]] to get the installer image and install using the [[NixOS_on_ARM#NixOS_installation_.26_configuration|installation and configuration steps]].


The Raspberry Pi 4B works with the [https://hydra.nixos.org/job/nixos/trunk-combined/nixos.sd_image.aarch64-linux generic SD image].
The Raspberry Pi 4B works with the [https://hydra.nixos.org/job/nixos/trunk-combined/nixos.sd_image.aarch64-linux generic SD image].


Sample instructions for [https://nix.dev/tutorials/installing-nixos-on-a-raspberry-pi installing NixOS on a Raspberry Pi] are available at nix.dev.
Sample instructions for [https://nix.dev/tutorials/installing-nixos-on-a-raspberry-pi installing NixOS on a Raspberry Pi] are available at nix.dev.
Line 45: Line 45:
=== Configuration ===
=== Configuration ===


{{outdated|These instructions were written when the generic image did not work. Using the vendor kernel may be desirable under some conditions<sup>[which?]</sup>}}
Using <code>nixos-generate-config</code> will generate the required minimal configuration.


Using <code>nixos-generate-config</code> will not generate the required minimal configuration.
For better GPU Support and some deviceTree quirks add the nixos-hardware channel:
 
<code>nix-channel --add https://github.com/NixOS/nixos-hardware/archive/master.tar.gz nixos-hardware</code>
For better GPU Support, remember to add the nixos-hardware channel:
<code>nixos-hardware https://github.com/NixOS/nixos-hardware/archive/master.tar.gz</code>


{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{ config, pkgs, lib, ... }:
{ config, pkgs, lib, ... }:
{
{
# This configuration worked on 09-03-2021 nixos-unstable @ commit 102eb68ceec
   imports =
# The image used https://hydra.nixos.org/build/134720986
     [
 
      <nixos-hardware/raspberry-pi/4>
   boot = {
      ./hardware-configuration.nix
     kernelPackages = pkgs.linuxPackages_rpi4;
    tmpOnTmpfs = true;
    initrd.availableKernelModules = [ "usbhid" "usb_storage" ];
    # ttyAMA0 is the serial console broken out to the GPIO
    kernelParams = [
        "8250.nr_uarts=1"
        "console=ttyAMA0,115200"
        "console=tty1"
        # A lot GUI programs need this, nearly all wayland applications
        "cma=128M"
     ];
     ];
   };
   hardware = {
 
     raspberry-pi."4".apply-overlays-dtmerge.enable = true;
  boot.loader.raspberryPi = {
     deviceTree = {
     enable = true;
    version = 4;
  };
  boot.loader.grub.enable = false;
 
  # Required for the Wireless firmware
  hardware.enableRedistributableFirmware = true;
 
  networking = {
    hostName = "nixos-raspi-4"; # Define your hostname.
     networkmanager = {
       enable = true;
       enable = true;
      filter = "*rpi-4-*.dtb";
     };
     };
   };
   };
 
   console.enable = false;
   nix = {
  environment.systemPackages = with pkgs; [
    autoOptimiseStore = true;
     libraspberrypi
    gc = {
     raspberrypi-eeprom
      automatic = true;
   ];
      dates = "weekly";
   system.stateVersion = "23.11";
      options = "--delete-older-than 30d";
     };
    # Free up to 1GiB whenever there is less than 100MiB left.
     extraOptions = ''
      min-free = ${toString (100 * 1024 * 1024)}
      max-free = ${toString (1024 * 1024 * 1024)}
    '';
   };
   system.stateVersion = "20.09";
}
}
</nowiki>}}
</nowiki>}}