Headless Raspberry pi setup

What I meant by headless setup, is headless first-time setup,
without using any screen/keyboard. How would I set authorizedKeys in
the image directly? I mounted /dev/sda2 after writing the image to an
sd card but I see no configuration.nix so I don’t where I would do my
configuration.

That’s the setup I have, too :). I find a flake a bit like the following
works pretty well, and you can nix build yourself an ISO:

{
  inputs.nixpkgs = ...;

  outputs = { self, nixpkgs }: let
    pkgs = import nixpkgs {
      crossSystem.config = "aarch64-unknown-linux-gnu";
    };
  in {
    defaultPackage.<sys> = self.nixosConfigurautions.<name>.config.system.build.sdImage;

    nixosConfigurations.<name> = nixpkgs.lib.nixosSystem {
      system = "aarch64-linux";

      modules = [ ... ]; # here's where your config goes
    };
  }
}

Note that private keys are a lot harder than public.

2 Likes