{ 
  # INFORMATION
  # When building for a system, remember to change the hostname variable below
  description = "NixOS System Config";

  inputs = {
    # NixOS packages
    unstable-nixpkgs.url = "nixpkgs/nixos-unstable";

    # Manage dotfiles in a home directory
    home-manager.url = "github:nix-community/home-manager/release-23.05";
    home-manager.inputs.nixpkgs.follows = "unstable-nixpkgs";

    # Secureboot Configuration
    lanzaboote.url = "github:nix-community/lanzaboote";
    lanzaboote.inputs.nixpkgs.follows = "unstable-nixpkgs";

    # Nix User Repository
    nur.url = "github:nix-community/NUR";

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

    # Encrypted secrets in Nix configuration files
    sops-nix.url = "github:Mic92/sops-nix";  
  };

  outputs = { 
    self,
    unstable-nixpkgs, 
    home-manager, 
    lanzaboote, 
    nur, 
    sops-nix, 
    nixos-hardware, 
    ... 
  }@inputs:
  let
    # Variables - Remember to set these
    hostname = "nixos-laptop"; # Should probably set this in a minimal configuration.nix?
    system = "x86_64-linux";
    hmStateVersion = "23.05";

    pkgs = import unstable-nixpkgs {
      inherit system;
      config = { allowUnfree = true; };
    };

    lib = unstable-nixpkgs.lib;
  in {
    # NixOS Configuration files:
    nixosConfigurations = {
      # Declare a generic configuration using the $hostname variable:
      ${hostname} = lib.nixosSystem { 
        inherit system;
        specialArgs = { 
          inherit hostname;
        };
        modules = [
          # Configuration Imports
          ./configuration.nix # Common NixOS Configuration
          ./hosts/${hostname} # Hardware-specific Configuration

          # Flake Imports
          sops-nix.nixosModules.sops                     # Handle secrets
          lanzaboote.nixosModules.lanzaboote             # SecureBoot Configuration
          nur.nixosModules.nur                           # NixOS User Repository
          # nixos-hardware.nixosModules.lenovo-thinkpad-p1 # Thinkpad P1 hardware configuration

          # Home Manager settings
          home-manager.nixosModules.home-manager {
            home-manager = {
              useGlobalPkgs   = true;
              useUserPackages = true;
              users.albert.imports = [ 
                ({ config, ... }: import ./users/albert/home.nix  {
                  inherit config pkgs hostname hmStateVersion;
                })
              ];
              users.root.imports = [ 
                ({ config, ... }: import ./users/root/home.nix  {
                  inherit config pkgs hostname hmStateVersion;
                })
              ];
            }; # home-manager
            nixpkgs.overlays = [
              nur.overlay
            ];
          } # home-manager
        ]; # modules
      }; # lib.nixosSystem - ${hostname}
    }; # nixosConfiguration
  }; # in
}