{
  description = "Nix config entry point";
  # since secrets live in a submodule, enable submodules by default
  inputs.self.submodules = true;
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
    # Home manager
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    # Managing flatpak apps
    nix-flatpak.url = "github:gmodena/nix-flatpak";

    # hyprland, plugins and related utils
    hyprland.url = "github:hyprwm/Hyprland";

    stylix = {
      url = "github:nix-community/stylix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    # zen browser
    zen-browser = {
      url = "github:0xc000022070/zen-browser-flake";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    # power management
    watt = {
      url = "github:NotAShelf/watt/?ref=v0.3.2";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    # secrets
    sops-nix = {
      url = "github:Mic92/sops-nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    # quickshell
    dms-cli = {
      url = "github:AvengeMedia/danklinux";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    dankMaterialShell = {
      url = "github:AvengeMedia/DankMaterialShell";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.dms-cli.follows = "dms-cli";
    };

    nix4vscode = {
      url = "github:nix-community/nix4vscode";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = {
    self,
    nixpkgs,
    nixpkgs-unstable,
    home-manager,
    stylix,
    sops-nix,
    nix4vscode,
    ...
  } @ inputs:
    let
      system = "x86_64-linux";
      username = "remy";
      name = "Rémy";

      pkgs = nixpkgs.legacyPackages.${system};
      pkgs-unstable = nixpkgs-unstable.legacyPackages.${system};

      lib = nixpkgs.lib;

      systems = {
        # HP Spectre x360 2018
        Nixtre = {
          hostModules = [
            ./hosts/spectre-x360-2018
          ];
          userModules = [
            ./users/remy_spectre
            inputs.nix-flatpak.homeManagerModules.nix-flatpak
          ];
          extraModules = [
            inputs.stylix.nixosModules.stylix
            inputs.sops-nix.nixosModules.sops
          ];
        };

        # Portable usb stick
        nichts = {
          hostModules = [
            ./hosts/mobile-usb
          ];
          userModules = [
            ./users/remy_usb
            inputs.nix-flatpak.homeManagerModules.nix-flatpak
          ];
          extraModules = [
            inputs.stylix.nixosModules.stylix
            inputs.sops-nix.nixosModules.sops
          ];
        };

        # Lenovo yoga 7 pro
        nyx = {
          hostModules = [
            ./hosts/yoga-7-pro
          ];
          userModules = [
            ./users/remy_yoga
            inputs.nix-flatpak.homeManagerModules.nix-flatpak
            inputs.dankMaterialShell.homeModules.dankMaterialShell.default

          ];
          extraModules = [
            inputs.stylix.nixosModules.stylix
            inputs.sops-nix.nixosModules.sops
            { nixpkgs.overlays = [ inputs.nix4vscode.overlays.default ]; }
          ];
        };
      };
    in
  {
    # For each entry in `systems` create a nixosConfiguration
    nixosConfigurations = lib.mapAttrs (_name: cfg:
      nixpkgs.lib.nixosSystem {
        inherit system;
        specialArgs = { inherit inputs pkgs-unstable; };
        modules =
          cfg.hostModules ++
          cfg.extraModules ++
          [ home-manager.nixosModules.home-manager {
              # Common home-manager flags
              home-manager = {
                backupFileExtension = ".backup";
                useGlobalPkgs = true;
                useUserPackages = true;
                extraSpecialArgs = { inherit inputs pkgs-unstable; };
              };

              # Merge in all the user fragments for this host
              home-manager.users.remy = lib.mkMerge cfg.userModules;
            }
          ]
        ;
      }
    ) systems;


  #   ## Useful nix build tools
  #   # iso builder TODO
  #   nixosConfigurations.bcachefs-iso = nixpkgs.lib.nixosSystem {
  #     system = "x86_64-linux";
  #     modules = [
  #       "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal-new-kernel-no-zfs.nix"
  #       ({ lib, pkgs, ... }: {
  #         boot.supportedFilesystems = [ "bcachefs" ];
  #         boot.kernelPackages = lib.mkOverride 0 pkgs.linuxPackages_latest;
  #       })
  #     ];
  #   };

    # devshell for this configuration
    devShells.x86_64-linux.default = nixpkgs.legacyPackages.x86_64-linux.mkShell {
      packages = [
        pkgs.sops
      ];

      # tell sops where the public ssh key to "seed" the age key from is located
      SOPS_AGE_SSH_PRIVATE_KEY_FILE = "/home/remy/.ssh/main_key";
    };
  };
}
