Eval-config returning `called with unexpected argument` when running `nixos-rebuild`

I’m quite new to Nix and NixOS and I’m attempting to install a linux-zen-hyprland operating system. However, in building the flake, I get the following error:

[cone@nixos:~/projects/NixOS]$ nixos-rebuild build-vm --cores 16 --flake .#cone --show-trace
building the system configuration...
error: anonymous function at /nix/store/ismzj4bksv54y4x2b9spfvk9mqhbcwf8-source/nixos/lib/eval-config.nix:11:1 called with unexpected argument 'imports'

       at /nix/store/ismzj4bksv54y4x2b9spfvk9mqhbcwf8-source/flake.nix:22:11:

           21|         nixosSystem = args:
           22|           import ./nixos/lib/eval-config.nix (
             |           ^
           23|             args // {

       … while evaluating 'nixosSystem'

       at /nix/store/ismzj4bksv54y4x2b9spfvk9mqhbcwf8-source/flake.nix:21:23:

           20|
           21|         nixosSystem = args:
             |                       ^
           22|           import ./nixos/lib/eval-config.nix (

       … from call site

       at /nix/store/i4v3659dmfspkz80dhsjm7gvijf77dfx-source/flake.nix:23:34:

           22|     {
           23|       nixosConfigurations.cone = lib.nixosSystem {
             |                                  ^
           24|         inherit system;

My config (flake) is the following:

{
  inputs = {
    # nixos.url = "nixpkgs/nixos-unstable";
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    nixpkgs-wayland.url = "github:nix-community/nixpkgs-wayland";
    hyprland.url = "github:hyprwm/Hyprland";
  };

  outputs = { self, nixpkgs, home-manager, nixpkgs-wayland, hyprland, ... }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs {
        inherit system;
        config.allowUnfree = true;
      };
      lib = nixpkgs.lib;
    in
    {
      nixosConfigurations.cone = lib.nixosSystem {
        inherit system;
        imports = [
          ./hardware-configuration.nix
          hyprland.nixosModules.default
        ];

        boot = {
          loader = {
            systemd-boot.enable = true;
            efi.canTouchEfiVariables = true;
            efi.efiSysMountPoint = "/boot/efi";
          };
          kernelPackages = pkgs.linuxPackages_zen;
          initrd = {
            secrets = {
              "/crypto_keyfile.bin" = null;
            };
            luks.devices = {
              "luks-2ad8d1a2-0348-48a1-be38-c261fc8d369e".device = "/dev/disk/by-uuid/2ad8d1a2-0348-48a1-be38-c261fc8d369e";
              "luks-2ad8d1a2-0348-48a1-be38-c261fc8d369e".keyFile = "/crypto_keyfile.bin";
            };
          };
        };

        environment = {
          variables = {
            NIXOS_OZONE_WL = "1";
            GBM_BACKEND = "nvidia-drm";
            __GL_GSYNC_ALLOWED = "0";
            __GL_VRR_ALLOWED = "0";
            DISABLE_QT5_COMPAT = "0";
            ANKI_WAYLAND = "1";
            DIRENV_LOG_FORMAT = "";
            WLR_DRM_NO_ATOMIC = "1";
            __GLX_VENDOR_LIBRARY_NAME = "nvidia";
            QT_QPA_PLATFORM = "wayland";
            QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
            QT_QPA_PLATFORMTHEME = "qt5ct";
            MOZ_ENABLE_WAYLAND = "1";
            MOZ_USE_XINPUT2 = "1";
            WLR_BACKEND = "vulkan";
            WLR_NO_HARDWARE_CURSORS = "1";
            XDG_SESSION_TYPE = "wayland";
            CLUTTER_BACKEND = "wayland";
            WLR_DRM_DEVICES = "/dev/dri/card1:/dev/dri/card0";
          };
          loginShellInit = ''
            dbus-update-activation-environment --systemd DISPLAY
            eval $(ssh-agent)
            eval $(gnome-keyring-daemon --start)
            export GPG_TTY=$TTY
          '';
          systemPackages = with pkgs; [
            # Graphics
            glxinfo
            vulkan-tools
            glmark2

            wayland
            grim
            slurp

            configure-gtk
            wl-clipboard
          ];
        };

        time.timeZone = "America/Chicago";
        i18n.defaultLocale = "en_US.UTF-8";

        sound.enable = true;
        security.rtkit.enable = true;

        hardware = {
          i2c.enable = true;
          video.hidpi.enable = true;
          nvidia = {
            open = true;
            powerManagement.enable = true;
            modesetting.enable = true;
          };
          opengl = {
            enable = true;
            driSupport = true;
            driSupport32Bit = true;
            extraPackages = with pkgs; [
              vaapiVdpau
              libvdpau-va-gl
              nvidia-vaapi-driver
            ];
          };
          pulseaudio.enable = false;
          bluetooth.enable = true;
        };

        networking = {
          hostName = "nix";
          useDHCP = false;
          networkmanager = {
            enable = true;
            wifi.macAddress = "random";
          };
          nameservers = [
            "1.1.1.1"
            "1.0.0.1"
          ];
        };

        services = {
          xserver = {
            videoDrivers = [ "nvidia" ];
            libinput.enable = true;
            displayManager = {
              gdm = {
                wayland = true;
                nvidiaWayland = true;
              };
              defaultSession = "none+hyprland";
            };
            gnome = {
              glib-networking.enable = true;
              gnome-keyring.enable = true;
            };
            blueman.enable = true;
            pipewire = {
              enable = true;
              alsa.enable = true;
              alsa.support32Bit = true;
              pulse.enable = true;
            };
          };
        };
        xdg.portal = {
          enable = true;
          wlr.enable = true;
          extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
        };

        programs.hyprland = {
          enable = true;
          nvidiaPatches = true;
          xwayland = {
            enable = true;
            hidpi = true;
          };
          wlroots =
            hyprland.packages.${pkgs.system}.wlroots-hyprland.overrideAttrs
              (old: {
                patches =
                  (old.patches or [ ])
                  ++ [
                    (pkgs.fetchpatch {
                      url = "https://aur.archlinux.org/cgit/aur.git/plain/0001-nvidia-format-workaround.patch?h=hyprland-nvidia-screenshare-git";
                      sha256 = "A9f1p5EW++mGCaNq8w7ZJfeWmvTfUm4iO+1KDcnqYX8=";
                    })
                  ];
              });
        };

        nix.settings.trusted-users = [ "root" "cone" ];

        users.users.cone = {
          isNormalUser = true;
          initialPassword = "pass";
          password = "pass";
          extraGroups = [ "networkmanager" "wheel" ]; # Enable ‘sudo’ for the user.
          packages = with pkgs; [
            brave
            alacritty
          ];
        };
      };
    };
}

I’m running NixOS 22.11.1777.cdead16a444 (Raccoon).

It seems like my problem is somewhat related to this issue regarding channels, but I don’t think it’s home-manager specific. I apologize if the error is just some syntax or noob-like error and I appreciate the help.

You’ve fundamentally misunderstood how lib.nixosSystem works. Its argument is not a nixos module. The only thing you put into its argument that actually belongs there is system. You need to also provide a modules attribute and possibly specialArgs.

See the wiki for some basic examples.

That’s what I figured after taking a look at a couple flake examples. I’ve had a bit of trouble understanding flakes, thanks for the help :).