{
  inputs = rec {
    nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
    nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-25.11";

    nixpkgs-otbr.url = "github:mrene/nixpkgs/openthread-border-router";

    home-manager-stable = {
      url = "github:nix-community/home-manager/release-25.11";
      inputs.nixpkgs.follows = "nixpkgs-stable";
    };

    home-manager-unstable = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs-unstable";
    };

    nixpkgs = nixpkgs-stable;
    home-manager = home-manager-stable;

    # The name "snowfall-lib" is required due to how Snowfall Lib processes your
    # flake's inputs.
    snowfall-lib = {
      url = "github:mjallen18/snowfall-lib";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    nixos-generators = {
      url = "github:nix-community/nixos-generators";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    impermanence.url = "github:nix-community/impermanence";

    lanzaboote.url = "github:nix-community/lanzaboote/v1.0.0";

    nixos-hardware.url = "github:NixOS/nixos-hardware/master";

    sops-nix.url = "github:Mic92/sops-nix";

    steam-rom-manager = {
      url = "github:mjallen18/nix-steam-rom-manager";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.home-manager.follows = "home-manager";
    };

    cosmic.url = "github:lilyinstarlight/nixos-cosmic";

    nix-vscode-extensions.url = "github:nix-community/nix-vscode-extensions";

    authentik-nix.url = "github:nix-community/authentik-nix";

    nixai.url = "github:olafkfreund/nix-ai-help";

    disko = {
      # the fork is needed for partition attributes support
      # url = "github:nvmd/disko/gpt-attrs";
      url = "github:nix-community/disko";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    nixos-raspberrypi = {
      url = "github:mjallen18/nixos-raspberrypi";
      # url = "git+file:///home/admin/dev/nixos-raspberrypi";
      inputs.nixpkgs.follows = "nixpkgs-stable";
    };

    jovian.url = "github:Jovian-Experiments/Jovian-NixOS";

    darwin.url = "github:LnL7/nix-darwin/nix-darwin-25.11";

    nix-homebrew.url = "github:zhaofengli/nix-homebrew";

    homebrew-core = {
      url = "github:homebrew/homebrew-core";
      flake = false;
    };

    homebrew-cask = {
      url = "github:homebrew/homebrew-cask";
      flake = false;
    };

    nixos-apple-silicon.url = "github:nix-community/nixos-apple-silicon";

    pre-commit-hooks-nix = {
      url = "github:cachix/pre-commit-hooks.nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    treefmt-nix = {
      url = "github:numtide/treefmt-nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    nix-index-database = {
      url = "github:nix-community/nix-index-database";
      inputs = {
        nixpkgs.follows = "nixpkgs";
      };
    };

    lsfg-vk = {
      url = "github:pabloaul/lsfg-vk-flake";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    nix-plist-manager.url = "github:sushydev/nix-plist-manager";

    nix-rosetta-builder = {
      url = "github:cpick/nix-rosetta-builder";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    stylix = {
      url = "github:nix-community/stylix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  # We will handle this in the next section.
  outputs =
    inputs:
    inputs.snowfall-lib.mkFlake {
      # You must provide our flake inputs to Snowfall Lib.
      inherit inputs;

      # The `src` must be the root of the flake. See configuration
      # in the next section for information on how you can move your
      # Nix files to a separate directory.
      src = ./.;

      # Add a module to a specific host.
      systems = {
        # common modules
        modules.nixos = with inputs; [
          authentik-nix.nixosModules.default
          disko.nixosModules.disko
          impermanence.nixosModules.impermanence
          lanzaboote.nixosModules.lanzaboote
          sops-nix.nixosModules.sops
          home-manager.nixosModules.home-manager
          nix-index-database.nixosModules.nix-index
          stylix.nixosModules.stylix
        ];

        modules.home = with inputs; [
          nix-index-database.homeManagerModules.nix-index
        ];

        # common darwin modules
        modules.darwin = with inputs; [
          nix-homebrew.darwinModules.nix-homebrew
          home-manager.darwinModules.home-manager
          nix-plist-manager.darwinModules.default
          nix-rosetta-builder.darwinModules.default
          nix-index-database.darwinModules.nix-index
          stylix.darwinModules.stylix
        ];

        # Host config
        hosts = {
          # ######################################################
          #                    Desktop                           #
          # ######################################################
          matt-nixos = {
            modules = with inputs; [
              nixos-hardware.nixosModules.common-cpu-amd
              nixos-hardware.nixosModules.common-cpu-amd-pstate
              # nixos-hardware.nixosModules.common-cpu-amd-zenpower
              nixos-hardware.nixosModules.common-gpu-amd
              nixos-hardware.nixosModules.common-hidpi
              nixos-hardware.nixosModules.common-pc
              lsfg-vk.nixosModules.default
            ];
          };

          # ######################################################
          #                      NAS                             #
          # ######################################################
          jallen-nas = {
            modules = with inputs; [
              nixos-hardware.nixosModules.common-pc
              nixos-hardware.nixosModules.common-cpu-amd
              nixos-hardware.nixosModules.common-cpu-amd-pstate
              # nixos-hardware.nixosModules.common-cpu-amd-zenpower
              nixos-hardware.nixosModules.common-hidpi
              home-manager.nixosModules.home-manager
            ];
          };

          # ######################################################
          #                     allyx                            #
          # ######################################################
          allyx = {
            modules = with inputs; [
              disko.nixosModules.disko
              jovian.nixosModules.jovian
              nixos-hardware.nixosModules.common-cpu-amd
              nixos-hardware.nixosModules.common-cpu-amd-pstate
              # nixos-hardware.nixosModules.common-cpu-amd-zenpower
              nixos-hardware.nixosModules.common-gpu-amd
              nixos-hardware.nixosModules.common-hidpi
              nixos-hardware.nixosModules.common-pc
              lsfg-vk.nixosModules.default
            ];
          };

          # ######################################################
          #                      NUC                             #
          # ######################################################
          nuc-nixos = {
            modules = with inputs; [
              disko.nixosModules.disko
              nixos-hardware.nixosModules.common-cpu-amd
              nixos-hardware.nixosModules.common-cpu-amd-pstate
              # nixos-hardware.nixosModules.common-cpu-amd-zenpower
              nixos-hardware.nixosModules.common-gpu-amd
              nixos-hardware.nixosModules.common-hidpi
              nixos-hardware.nixosModules.common-pc
            ];
          };

          # ######################################################
          #                      Pi4                             #
          # ######################################################
          pi4 = {
            modules = with inputs; [
              disko.nixosModules.disko
              # nixos-raspberrypi.nixosModules.raspberry-pi-4.base
              # nixos-raspberrypi.nixosModules.raspberry-pi-4.display-vc4
              # nixos-raspberrypi.nixosModules.nixpkgs-rpi
              # nixos-raspberrypi.nixosModules.trusted-nix-caches
              # nixos-raspberrypi.lib.inject-overlays
              # nixos-raspberrypi.lib.inject-overlays-global
            ];
          };

          # ######################################################
          #                      Pi5                             #
          # ######################################################
          pi5 = {
            modules = with inputs; [
              disko.nixosModules.disko
              # nixos-raspberrypi.nixosModules.raspberry-pi-5.base
              # nixos-raspberrypi.nixosModules.raspberry-pi-5.display-vc4
              # nixos-raspberrypi.nixosModules.raspberry-pi-5.bluetooth
              # nixos-raspberrypi.nixosModules.raspberry-pi-5.page-size-16k
              # nixos-raspberrypi.nixosModules.nixpkgs-rpi
              # nixos-raspberrypi.nixosModules.trusted-nix-caches
              # nixos-raspberrypi.lib.inject-overlays
              # nixos-raspberrypi.lib.inject-overlays-global
            ];
          };

          # ######################################################
          #                      Mac                             #
          # ######################################################
          macbook-pro-nixos = {
            modules = with inputs; [
              nixos-apple-silicon.nixosModules.default
              lsfg-vk.nixosModules.default
            ];
          };
        };

        overlays = with inputs; [
          nix-vscode-extensions.overlays.default
        ];
      };

      # Configure Snowfall Lib, all of these settings are optional.
      snowfall = {
        # Choose a namespace to use for your flake's packages, library,
        # and overlays.
        namespace = "mjallen";

        # Add flake metadata that can be processed by tools like Snowfall Frost.
        meta = {
          # A slug to use in documentation when displaying things like file paths.
          name = "mjallen";

          # A title to show for your flake, typically the name.
          title = "mjallen Flake";
        };
      };

      channels-config = {
        allowUnfree = true;
        allowUnsupportedSystem = true;
        permittedInsecurePackages = [
          # ...
          # "libsoup-2.74.3"
          # "mbedtls-2.28.10"
        ];
      };

      outputs-builder = channels: {
        formatter = inputs.treefmt-nix.lib.mkWrapper channels.nixpkgs ./treefmt.nix;

        # Add mjallen-lib to the flake outputs
        overlays = {
          mjallen-lib = _final: _prev: {
            mjallen-lib = (import ./lib { inherit inputs; }).mjallen-lib;
          };
        };
      };
    };
}
