{
  lib,
  pkgs,
  config,
  ...
}:
{
  imports = [
    ../../common/global
    ../../common/impermanence-common.nix  # Impermanence with custom root config (see hardware.nix)
    ../../common/resource-limits.nix
    ../../common/sshd.nix
    ../../common/user-ppetru.nix
    ../../common/wifi.nix
    # Note: No systemd-boot.nix - Raspberry Pi uses generic-extlinux-compatible (from sd-image module)
    ./hardware.nix
  ];

  hardware = {
    raspberry-pi."4".apply-overlays-dtmerge.enable = true;
    deviceTree = {
      enable = true;
      filter = "*rpi-4-*.dtb";
    };
  };

  networking.hostName = "stinky";

  # Configure impermanence for tmpfs root (filesystem config in hardware.nix)
  custom.impermanence.persistPath = "/nix/persist";

  # Tailscale configuration
  services.tailscaleAutoconnect.authkey = "tskey-auth-kZC8HX3wSw11CNTRL-7QvqxAphyzM7QeMUTKXv2Ng2RK4XCmg9A";

  # OctoPrint for 3D printer
  services.octoprint = {
    enable = true;
  };

  # Persist OctoPrint data
  environment.persistence.${config.custom.impermanence.persistPath}.directories = [
    "/var/lib/octoprint"
  ];

  # Pi HQ Camera support
  boot.kernelModules = [ "bcm2835-v4l2" ];

  environment.systemPackages = with pkgs; [
    libcamera
    libraspberrypi
    raspberrypi-eeprom
  ];

  # Firewall: Allow access to OctoPrint
  networking.firewall.allowedTCPPorts = [
    5000  # OctoPrint
  ];

  # Override global default (stinky is a new system with 25.05)
  system.stateVersion = lib.mkForce "25.05";
}
