{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";

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

    # KDE config
    plasma-manager = {
      url = "github:pjones/plasma-manager";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.home-manager.follows = "home-manager";
    };

    # Secret management
    agenix = {
      url = "github:ryantm/agenix";
      inputs.nixpkgs.follows = "nixpkgs";
    };

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

  outputs = {
    self,
    nixpkgs,
    home-manager,
    plasma-manager,
    agenix,
    nix-hyprland,
    ...
  } @ inputs: let
    inherit (self) outputs;

    hosts = [
      "luna"
      "terra"
      "solis"
      "artemis"
    ];

    systems = [
      "aarch64-linux"
      "i686-linux"
      "x86_64-linux"
      "aarch64-darwin"
      "x86_64-darwin"
    ];
    forAllSystems = nixpkgs.lib.genAttrs systems;

    lib = import ./lib {inherit inputs;};
  in {
    formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra);

    nixosConfigurations = nixpkgs.lib.genAttrs hosts (host:
      nixpkgs.lib.nixosSystem {
        specialArgs = {
          inherit inputs outputs lib;
        };
        modules = [
          ./modules
          ./dots
          ./machines/${host}/configuration.nix
          home-manager.nixosModules.home-manager
          agenix.nixosModules.default
          nix-hyprland.nixosModules.default
          {
            home-manager.sharedModules = [plasma-manager.homeModules.plasma-manager];
          }
        ];
      });
  };
}
