{
  inputs = let
    mkCustomUrl = url: {inherit url;};

    mkInput = url: {url = "github:${url}";};

    mkFollowingNixpkgs = url: {
      url = "github:${url}";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    mkFollowing = url: input: {
      url = "github:${url}";
      inputs.${input}.follows = input;
    };

    mkWithSubmodules = url: {
      inherit url;
      submodules = true;
      type = "git";
    };
  in {
    determinate = mkInput "DeterminateSystems/determinate";
    agenix = mkInput "ryantm/agenix";
    catppuccin = mkInput "catppuccin/nix";
    chaotic = mkInput "chaotic-cx/nyx/nyxpkgs-unstable";
    emacs = mkCustomUrl "git+https://git.pupbrained.xyz/pupbrained/nixmacs.git";
    hyprland = mkWithSubmodules "https://github.com/hyprwm/Hyprland";
    hyprland-plugins = mkFollowing "hyprwm/hyprland-plugins" "hyprland";
    hyprpanel = mkInput "Jas-SinghFSU/HyprPanel";
    impermanence = mkInput "nix-community/impermanence";
    nix-colors = mkInput "Misterio77/nix-colors";
    nixos-facter-modules = mkInput "numtide/nixos-facter-modules";
    nixpkgs = mkInput "NixOS/nixpkgs/nixos-unstable";
    nixvim = mkInput "pupbrained/nvim-config";
    treefmt-nix = mkInput "numtide/treefmt-nix";
    xmonad-contrib = mkInput "xmonad/xmonad-contrib";
    wezterm = mkInput "wez/wezterm?dir=nix";
    zen-browser = mkInput "qlexqndru/zen-browser-flake";

    niri = mkFollowingNixpkgs "sodiboo/niri-flake";
    cosmic = mkFollowingNixpkgs "lilyinstarlight/nixos-cosmic";
    darwin = mkFollowingNixpkgs "LnL7/nix-darwin/master";
    home-manager = mkFollowingNixpkgs "nix-community/home-manager";
    nix-index-database = mkFollowingNixpkgs "nix-community/nix-index-database";
    snowfall-flake = mkFollowingNixpkgs "snowfallorg/flake";
    snowfall-lib = mkFollowingNixpkgs "snowfallorg/lib/dev";
  };

  outputs = {...} @ inputs:
    with inputs;
      snowfall-lib.mkFlake {
        inherit inputs;
        src = ./.;

        overlays = [
          hyprpanel.overlay
          snowfall-flake.overlays.default
        ];

        channels-config = {
          allowAliases = true;
          allowUnfree = true;
          allowUnsupportedSystem = true;
          cudaSupport = true;
          permittedInsecurePackages = ["freeimage-unstable-2021-11-01"];
          home-manager.useGlobalPkgs = true;
        };

        systems.modules.nixos =
          [
            agenix.nixosModules.default
            catppuccin.nixosModules.catppuccin
            chaotic.nixosModules.default
            cosmic.nixosModules.default
            determinate.nixosModules.default
            impermanence.nixosModules.impermanence
            nixos-facter-modules.nixosModules.facter
          ]
          ++ xmonad-contrib.nixosModules;

        systems.modules.darwin = [
          "${home-manager}/nix-darwin"
        ];

        outputs-builder = channels: {
          formatter = treefmt-nix.lib.mkWrapper channels.nixpkgs {
            projectRootFile = "flake.nix";

            programs = {
              alejandra.enable = true;
              deadnix.enable = true;
              jsonfmt.enable = true;
              stylua.enable = true;
              taplo.enable = true;
            };
          };

          devShells.default = with channels.nixpkgs;
            mkShellNoCC {
              packages = [
                alejandra
                git
                lua-language-server
                nvfetcher
                statix

                (writeScriptBin "build" ''
                  sudo nix run \
                    --option experimental-features "nix-command flakes" \
                    --option extra-substituters https://numtide.cachix.org \
                    --option extra-trusted-public-keys numtide.cachix.org-1:2ps1kLBUWjxIneOy1Ik6cQjb41X0iXVXeHigGmycPPE= \
                    github:numtide/nixos-facter -- -o systems/${system}/$(hostname)/facter.json
                  nix fmt
                  nh os switch
                '')
                (writeScriptBin "up" "nix flake update && nvfetcher")
              ];
            };
        };
      };
}
