{
  description = "Multisystem NixOS Flake of Lennart J. Kurzweg";

  inputs = {
    nixpkgs =          { url = "nixpkgs/nixos-24.05";                                                                        };
    nixpkgs-unstable = { url = "nixpkgs/nixos-unstable";                                                                     };
    nixpkgs-latest =   { url = "github:nixos/nixpkgs?ref=master";                                                            };
    home-manager =     { url = "github:nix-community/home-manager/release-24.05";      inputs.nixpkgs.follows = "nixpkgs";   };
    sops-nix =         { url = "github:Mic92/sops-nix";                                inputs.nixpkgs.follows = "nixpkgs";   };
    lanzaboote =       { url = "github:nix-community/lanzaboote/v0.3.0";                                                     };

    hyprland =         { url = "git+https://github.com/hyprwm/Hyprland?submodules=1";                                        };
    hyprland-plugins = { url = "github:hyprwm/hyprland-plugins";                       inputs.hyprland.follows = "hyprland"; };
    Hyprspace =        { url = "github:KZDKM/Hyprspace";                               inputs.hyprland.follows = "hyprland"; };
    hyprswitch =       { url = "github:h3rmt/hyprswitch/release";                                                            };

    # firefox-addons =   { url = "gitlab:rycee/nur-expressions?dir=pkgs/firefox-addons"; inputs.nixpkgs.follows = "nixpkgs"; };
    zen-browser.url = "github:MarceColl/zen-browser-flake";
  };

  outputs = { self, nixpkgs, nixpkgs-unstable, nixpkgs-latest, home-manager, ... }@inputs: let
    system = "x86_64-linux";
    user   = "nx2";

    config = { allowUnfree = true; allowUnfreePredicate = pkg: builtins.elem (pkgs.lib.getName pkg) (import ./flake-modules/allowed.nix).unfree; };
   
    pkgs          = import nixpkgs          { inherit system config; };
    pkgs-unstable = import nixpkgs-unstable { inherit system config; };
    pkgs-latest   = import nixpkgs-latest   { inherit system config; };

    nvidia-set    = import ./flake-modules/nvidia.nix;
    secrets       = import ./git-crypt/secrets.nix;
    rice          = import ./flake-modules/rice.nix pkgs;
  in {
    nixosConfigurations = let
      make-nixos-system = host: nixpkgs.lib.nixosSystem { 
        inherit system;
        modules = [ ./configuration.nix ];
        specialArgs = let
          nvidia = nvidia-set // {
            enable = if (host == "NxXPS" || host == "NxNORTH") then true else false;
            prime = if (host == "NxXPS") then true else false;
          }; 
        in { inherit inputs user host pkgs-unstable pkgs-latest secrets rice nvidia; };
      };
    in {
      NxXPS = make-nixos-system "NxXPS";
      NxNORTH = make-nixos-system "NxNORTH"; 
      NxACE = make-nixos-system "NxACE"; 
    };

    homeConfigurations = let 
      make-home-configuration = host: user: home-manager.lib.homeManagerConfiguration {
        inherit pkgs;
        modules = [ ./home.nix ];
        extraSpecialArgs = let
          nvidia = nvidia-set // {
            enable = if (host == "NxXPS" || host == "NxNORTH") then true else false;
            prime = if (host == "NxXPS") then true else false;
          }; 
        in { inherit inputs system user host pkgs-unstable pkgs-latest rice secrets nvidia; };
      };
    in {
      "${user}@NxXPS" = make-home-configuration "NxXPS" user; 
      "${user}@NxNORTH" = make-home-configuration "NxNORTH" user; 
      "${user}@NxACE" = make-home-configuration "NxACE" user; 
      "tv@NxACE" = make-home-configuration "NxACE" "tv"; 
    };
  };
}
