{
  description = "Flynn - self-hosted personal AI agent";

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

  outputs =
    { self, nixpkgs, flake-utils }:
    let
      overlays = {
        default = final: _prev: {
          flynn = import ./nix/package.nix { pkgs = final; };
        };
      };
    in
    (flake-utils.lib.eachDefaultSystem (
      system:
      let
        pkgs = import nixpkgs { inherit system; overlays = [ overlays.default ]; };
      in
      {
        packages = {
          default = pkgs.flynn;
          flynn = pkgs.flynn;
        };

        apps.default = flake-utils.lib.mkApp {
          drv = pkgs.flynn;
          exePath = "/bin/flynn";
        };

        devShells.default = pkgs.mkShell {
          packages = [
            pkgs.nodejs_22
            pkgs.pnpm
            pkgs.python3
            pkgs.gnumake
            pkgs.pkg-config
          ];
        };
      }
    ))
    // {
      inherit overlays;
      nixosModules.flynn = import ./nix/module.nix;
    };
}

