{
  inputs = {
    # Track channels with commits tested and built by hydra
    nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
    nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
    nixpkgs-master.url = "github:nixos/nixpkgs/master";

    nixpkgs-nc-spreed-signaling-pr.url = "github:hensoko/nixpkgs/nextcloud-spreed-signaling";

    home-manager.url = "github:nix-community/home-manager/release-24.11";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";

    flake-parts.url = "github:hercules-ci/flake-parts";

    simple-nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-24.11";
    simple-nixos-mailserver.inputs.nixpkgs-24_11.follows = "nixpkgs";
    simple-nixos-mailserver.inputs.nixpkgs.follows = "nixpkgs-unstable";

    invoiceplane-template.url = "git+https://git.pub.solar/momo/invoiceplane-templates.git";
    invoiceplane-template.inputs.nixpkgs.follows = "nixpkgs";
    invoiceplane-template.inputs.flake-parts.follows = "flake-parts";
  };

  outputs =
    inputs@{ self, ... }:
    inputs.flake-parts.lib.mkFlake { inherit inputs; } {
      systems = [
        "x86_64-linux"
        "aarch64-linux"
      ];

      imports = [
        inputs.flake-parts.flakeModules.easyOverlay
        ./lib
        ./overlays
        ./modules
      ];

      perSystem =
        args@{
          system,
          pkgs,
          config,
          lib,
          ...
        }:
        {
          packages = import ./pkgs args;
          overlayAttrs = config.packages;

          _module.args = {
            inherit inputs;
            pkgs = import inputs.nixpkgs {
              inherit system;
            };
            unstable = import inputs.nixpkgs-unstable { inherit system; };
          };

          checks =
            let
              nixos-lib = import (inputs.nixpkgs + "/nixos/lib") { };
              testDir = builtins.attrNames (builtins.readDir ./tests);
              testFiles = builtins.filter (n: builtins.match "^.*.nix$" n != null) testDir;
            in
            builtins.listToAttrs (
              map (x: {
                name = "test-${lib.strings.removeSuffix ".nix" x}";
                value = nixos-lib.runTest (
                  import (./tests + "/${x}") {
                    inherit self;
                    inherit pkgs;
                    inherit lib;
                    inherit config;
                  }
                );
              }) testFiles
            );

          devShells.default = pkgs.mkShell {
            buildInputs = with pkgs; [
              nix-fast-build
              cachix
              editorconfig-checker
              nodePackages.prettier
              nvfetcher
              shellcheck
              shfmt
              treefmt2
              nixos-generators
              jq
              mob
            ];
          };

          devShells.ci = pkgs.mkShell { buildInputs = with pkgs; [ nodejs_22 ]; };
        };

      flake = {
        formatter."x86_64-linux" = inputs.nixpkgs.legacyPackages."x86_64-linux".nixfmt-rfc-style;
      };
    };
}