{
  description = "CentralCloud unified portal (Elixir/Phoenix umbrella)";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
    flake-utils.url = "github:numtide/flake-utils";
  };

  nixConfig = {
    extra-substituters = [
      "https://cache.centralcloud.com/default"
    ];
    extra-trusted-public-keys = [
      "default:ywfU21WX06iOn2Ec2lae1jYh4w8LO4IQkmp06vJzsk8="
    ];
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};

        # Erlang OTP 28 without wxwidgets (avoids gstreamer→hotdoc→clang chain)
        erlang_28_headless = pkgs.beamPackages.erlang.override {
          wxGTK32     = null;
          libGL       = null;
          libGLU      = null;
          wrapGAppsHook3 = pkgs.buildEnv { name = "empty"; paths = []; };
          xorg        = { libX11 = null; };
        };

        # Elixir 1.20.0-rc.4 — not yet in nixpkgs; override elixir_1_19 against headless OTP 28
        elixir_1_20_rc4 = (pkgs.beamPackages.elixir_1_19.override {
          erlang = erlang_28_headless;
        }).overrideAttrs (_old: {
          version = "1.20.0-rc.4";
          src = pkgs.fetchFromGitHub {
            owner = "elixir-lang";
            repo  = "elixir";
            rev   = "v1.20.0-rc.4";
            hash  = "sha256-sboB+GW3T+t9gEcOGtd6NllmIlyWio1+cgWyyxE+484=";
          };
        });
      in {
        devShells.default = pkgs.mkShell {
          buildInputs = with pkgs; [
            elixir_1_20_rc4    # 1.20.0-rc.4 built from source against OTP 28
            erlang_28_headless # OTP 28.5, no wx/gui (headless server use)
            nodejs_22          # Phoenix asset pipeline
            inotify-tools      # LiveReload on Linux
          ];

          shellHook = ''
            export MIX_HOME=$HOME/.mix
            export HEX_HOME=$HOME/.hex
            export PATH=$MIX_HOME/bin:$HEX_HOME/bin:$PATH
            echo "Elixir $(elixir --version | head -1)"
            echo "Mix $(mix --version)"
          '';
        };
      });
}
