{ lib, modulesPath, pkgs, ... }: { imports = [ ./sd-image.nix ]; # Some packages (ahci fail... this bypasses that) https://discourse.nixos.org/t/does-pkgs-linuxpackages-rpi3-build-all-required-kernel-modules/42509 nixpkgs.overlays = [ (final: super: { makeModulesClosure = x: super.makeModulesClosure (x // { allowMissing = true; }); }) ]; nixpkgs.hostPlatform = "aarch64-linux"; # ! Need a trusted user for deploy-rs. nix.settings.trusted-users = ["@wheel"]; system.stateVersion = "24.11"; zramSwap = { enable = true; algorithm = "zstd"; }; sdImage = { # bzip2 compression takes loads of time with emulation, skip it. Enable this if you're low on space. compressImage = false; imageName = "zero2.img"; extraFirmwareConfig = { # Give up VRAM for more Free System Memory # - Disable camera which automatically reserves 128MB VRAM start_x = 0; # - Reduce allocation of VRAM to 16MB minimum for non-rotated (32MB for rotated) gpu_mem = 16; # Configure display to 800x600 so it fits on most screens # * See: https://elinux.org/RPi_Configuration hdmi_group = 2; hdmi_mode = 8; }; }; hardware = { enableRedistributableFirmware = lib.mkForce false; firmware = [pkgs.raspberrypiWirelessFirmware]; # Keep this to make sure wifi works i2c.enable = true; deviceTree.filter = "bcm2837-rpi-zero*.dtb"; deviceTree.overlays = [ { name = "enable-i2c"; dtsText = '' /dts-v1/; /plugin/; / { compatible = "brcm,bcm2837"; fragment@0 { target = <&i2c1>; __overlay__ { status = "okay"; }; }; }; ''; } ]; }; boot = { kernelPackages = pkgs.linuxPackages_rpi02w; initrd.availableKernelModules = ["xhci_pci" "usbhid" "usb_storage"]; loader = { grub.enable = false; generic-extlinux-compatible.enable = true; }; # Avoids warning: mdadm: Neither MAILADDR nor PROGRAM has been set. This will cause the `mdmon` service to crash. # See: https://github.com/NixOS/nixpkgs/issues/254807 swraid.enable = lib.mkForce false; }; networking = { interfaces."wlan0".useDHCP = true; wireless = { enable = true; interfaces = ["wlan0"]; # ! Change the following to connect to your own network networks = { "" = { psk = ""; }; }; }; }; # Enable OpenSSH out of the box. services.sshd.enable = true; # NTP time sync. services.timesyncd.enable = true; # ! Change the following configuration users.users.bob = { isNormalUser = true; home = "/home/bob"; description = "Bob"; extraGroups = ["wheel" "networkmanager"]; # ! Be sure to put your own public key here openssh.authorizedKeys.keys = ["a public key"]; }; security.sudo = { enable = true; wheelNeedsPassword = false; }; # ! Be sure to change the autologinUser. services.getty.autologinUser = "bob"; }