{
  description = "PatOS is a minimal, immutable Linux distribution specialized for the Patagia Platform.";

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

  outputs =
    {
      self,
      flake-utils,
      nixpkgs,
    }:
    flake-utils.lib.eachDefaultSystem (
      system:
      let
        pkgs = import nixpkgs { inherit system; };
        patosPkgs = self.packages.${system};
      in
      {
        packages = {
          default = self.packages.${system}.image;
          image = pkgs.callPackage ./image { inherit patosPkgs; };
          kernel = pkgs.callPackage ./kernel { };
          glibc = pkgs.callPackage ./glibc { };
          systemd = pkgs.callPackage ./systemd { };
          dbus-broker = pkgs.callPackage ./dbus-broker { };
          rootfs = pkgs.callPackage ./rootfs { inherit patosPkgs; };
          initrd = pkgs.callPackage ./rootfs/mkinitrd.nix { inherit patosPkgs; };

          qemu-uefi-tpm = pkgs.callPackage ./utils/qemu-uefi-tpm.nix { };
        };

        checks = {
          simple-test = pkgs.runCommand "simple-test" { } ''
            ${self.packages.${system}.default}/bin/my-program
            touch $out
          '';
        };

        formatter = pkgs.nixpkgs-fmt;

        devShells.default = pkgs.mkShell {
          buildInputs = with pkgs; [
            erofs-utils
            just
            nixd
            nixfmt-rfc-style
            squashfs-tools-ng
            self.packages.${system}.qemu-uefi-tpm
          ];
        };

      }
    );
}