{
  lib,
  outputs,
  ...
}: {
  # Apply overlays
  nixpkgs = {
    # TODO: apply this to hm and nixos without duplicate code
    overlays = builtins.attrValues outputs.overlays;
    config = {
      allowUnfree = true;
      allowUnfreePredicate = _: true; # TODO: what is this
      warn-dirty = false;
      permittedInsecurePackages = [
        "olm-3.2.16"
      ];
    };
  };

  nix.settings.auto-optimise-store = lib.mkDefault true;
  nix.settings.experimental-features = [
    "nix-command"
    "flakes"
    "ca-derivations"
  ];
  # warn-dirty = false;

  # Setup binary caches
  nix.settings = {
    substituters = [
      "https://nix-community.cachix.org"
      "https://cache.nixos.org/"
      "https://hyprland.cachix.org"
      "http://binarycache.julian-mutter.de"
    ];
    trusted-public-keys = [
      "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
      "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
      "binarycache.julian-mutter.de:oJ67uRFwRhNPKL58CHzy3QQLv38Kx7OA1K+6xlEPu7E="
    ];

    trusted-users = [
      "root"
      "@wheel"
    ]; # needed for devenv to add custom caches
  };

  nix.gc = {
    automatic = true;
    dates = "weekly";
    # Keep the last 3 generations
    options = "--delete-older-than +3";
  };

  programs.nix-ld.enable = true;

  # TODO: is this useful?, what does it do?
  # nix.settings.flake-registry = ""; # Disable global flake registry
  # Add each flake input as a registry and nix_path
  # registry = lib.mapAttrs (_: flake: { inherit flake; }) flakeInputs;
  # nixPath = lib.mapAttrsToList (n: _: "${n}=flake:${n}") flakeInputs;
}