# nix build .#nixosConfigurations.rpi3.config.system.build.sdImage { description = "Minimal NixOS Raspberry Pi 3B Flake"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; }; outputs = { self, nixpkgs, ... }@inputs: { nixosConfigurations.rpi3 = nixpkgs.lib.nixosSystem { system = "aarch64-linux"; modules = [ # Include the official SD card image builder module "${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix" ({ lib, pkgs, ... }: { # System basic configuration system.stateVersion = "24.11"; networking.hostName = "nixos-pi3"; # Enable necessary hardware firmware hardware.enableRedistributableFirmware = true; # Create a default user so you can log in users.users.root.initialHashedPassword = ""; # Or set a password/SSH key users.users.nixos = { isNormalUser = true; extraGroups = [ "wheel" ]; # Enable ‘sudo’ initialPassword = "changeme"; }; # Enable SSH for remote access on first boot services.openssh = { enable = true; settings.PermitRootLogin = "yes"; # Change or use keys for security }; # Expand root partition automatically on first boot # services.growpart.enable = true; }) ]; }; }; }