{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

  outputs = { self, nixpkgs }: let
    inherit (nixpkgs) lib;

    systems = [
      "x86_64-linux"
      "aarch64-linux"
    ];

    forAllSystems = f: lib.genAttrs systems (system: let
      pkgs = import nixpkgs {
        inherit system;
        overlays = [
          self.overlays.${system}.default
        ];
      };
    in f system pkgs);
  in {
    devShells = forAllSystems (system: pkgs: {
      default = pkgs.callPackage ./nix/shell.nix { };
    });

    packages = forAllSystems (system: pkgs: with pkgs; {
      default = self.packages.${system}.heimdal;

      heimdal = pkgs.callPackage ./nix/heimdal {
        src = lib.cleanSource ./.;
        inherit (pkgs.darwin.apple_sdk.frameworks) CoreFoundation Security SystemConfiguration;
        autoreconfHook = pkgs.buildPackages.autoreconfHook269;
      };

      nixosTest = pkgs.testers.runNixOSTest (import ./nix/nixosTest.nix { inherit nixpkgs; });
    });

    overlays = forAllSystems (system: pkgs: {
      default = final: prev: {
        heimdal = self.packages.${system}.heimdal;
      };
    });

    nixosModules = {
      default = self.nixosModules.heimdal;
      heimdal = ./nix/module;
    };
  };
}