raspberry pi configuration.nix code example
Example: raspberry pi configuration.nix
{ config, pkgs, lib, ... }:
{
boot = {
kernelPackages = pkgs.linuxPackages_rpi4;
tmpOnTmpfs = true;
initrd.availableKernelModules = [ "usbhid" "usb_storage" ];
kernelParams = [
"8250.nr_uarts=1"
"console=ttyAMA0,115200"
"console=tty1"
"cma=128M"
];
};
boot.loader.raspberryPi = {
enable = true;
version = 4;
};
boot.loader.grub.enable = false;
boot.loader.generic-extlinux-compatible.enable = true;
hardware.enableRedistributableFirmware = true;
networking = {
hostName = "nixos-raspi-4";
networkmanager = {
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" ];
};
};
environment.variables = {
EDITOR = "nvim";
};
programs.zsh = {
enable = true;
syntaxHighlighting.enable = true;
interactiveShellInit = ''
source ${pkgs.grml-zsh-config}/etc/zsh/zshrc
'';
promptInit = "";
};
nix = {
autoOptimiseStore = true;
gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 30d";
};
extraOptions = ''
min-free = ${toString (100 * 1024 * 1024)}
max-free = ${toString (1024 * 1024 * 1024)}
'';
};
fileSystems = {
"/" = {
device = "/dev/disk/by-label/NIXOS_SD";
fsType = "ext4";
options = [ "noatime" ];
};
};
nixpkgs.config = {
allowUnfree = true;
};
powerManagement.cpuFreqGovernor = "ondemand";
system.stateVersion = "20.09";
}