NixOS on ARM/Raspberry Pi 4: Difference between revisions

imported>Nebucatnetzer
Add a proper example for updating the firmware.
imported>Fuu0
m removed unrelated config, updated infos based on a long debugging session...
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 should work with either the [https://hydra.nixos.org/job/nixos/trunk-combined/nixos.sd_image.aarch64-linux generic SD image] or [https://hydra.nixos.org/job/nixos/trunk-combined/nixos.sd_image_new_kernel.aarch64-linux the new kernel variant], starting with 21.05 (or unstable). As long as a kernel 5.10 or newer is in use.
The Raspberry Pi 4B works with the [https://hydra.nixos.org/job/nixos/trunk-combined/nixos.sd_image.aarch64-linux generic SD image].
 
Please note: to uncompress the .zstd, one may use the <code>unzstd</code> command (equivalent to <code>zstd -d</code>) on supported machines. The zstd commands can be accessed from the <code>zstd</code> package.


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 49: Line 47:
Using <code>nixos-generate-config</code> will not generate the required minimal configuration.
Using <code>nixos-generate-config</code> will not generate the required minimal configuration.


Remember to add the nixos-unstable channel.
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>
Line 67: Line 66:
         "console=ttyAMA0,115200"
         "console=ttyAMA0,115200"
         "console=tty1"
         "console=tty1"
         # Some gui programs need this
         # A lot GUI programs need this, nearly all wayland applications
         "cma=128M"
         "cma=128M"
     ];
     ];
Line 86: Line 85:
       enable = true;
       enable = true;
     };
     };
  };
  environment.systemPackages = with pkgs; [
    neovim
  ];
  users = {
    defaultUserShell = pkgs.zsh;
    mutableUsers = false;
    users.root = {
      password = "apassword";
    };
    users.anormaluser = {
      isNormalUser = true;
      password = "apassword";
      extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
    };
  };
  environment.variables = {
    EDITOR = "nvim";
  };
  programs.zsh = {
    enable = true;
    syntaxHighlighting.enable = true;
    interactiveShellInit = ''
      source ${pkgs.grml-zsh-config}/etc/zsh/zshrc
    '';
    promptInit = ""; # otherwise it'll override the grml prompt
   };
   };


Line 131: Line 100:
     '';
     '';
   };
   };
  # Assuming this is installed on top of the disk image.
  fileSystems = {
    "/" = {
      device = "/dev/disk/by-label/NIXOS_SD";
      fsType = "ext4";
      options = [ "noatime" ];
    };
  };
  nixpkgs.config = {
    allowUnfree = true;
  };
  powerManagement.cpuFreqGovernor = "ondemand";
   system.stateVersion = "20.09";
   system.stateVersion = "20.09";
  #swapDevices = [ { device = "/swapfile"; size = 3072; } ];
}
}
</nowiki>}}
</nowiki>}}