Configuration.nix is not formatted properly

nixos-rebuild switch has errors and based on some research it seems like there is an error in my configuration.nix file somewhere yet after a few hours I’ve been unable to figure out where the formatting error is.

The specific error is

... while evaluating the attribute 'config'

321    options = checked options;
322    config = checked ( removeAttrs config [ "_module" ]);
323   _module = checked ( config._module )

There are a few others after that.

{ config, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  networking.hostName = "nixos"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "America/Vancouver";

  # Select internationalisation properties.
  i18n.defaultLocale = "en_CA.UTF-8";

  # Enable the X11 windowing system.
  # You can disable this if you're only using the Wayland session.
  services.xserver.enable = true;

  # Enable the KDE Plasma Desktop Environment.
  services.displayManager.sddm.enable = true;
  services.desktopManager.plasma6.enable = true;

  # Configure keymap in X11
  services.xserver.xkb = {
    layout = "us";
    variant = "dvorak";
  };

  # Configure console keymap
  console.keyMap = "dvorak";

  # Enable CUPS to print documents.
  services.printing.enable = true;

  # Enable sound with pipewire.
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    #jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default,
    # no need to redefine it in your config for now)
    #media-session.enable = true;
  };

  # Enable touchpad support (enabled default in most desktopManager).
  # services.xserver.libinput.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.curtismchale = {
    isNormalUser = true;
    description = "curtismchale";
    extraGroups = [ "networkmanager" "wheel" ];
    packages = with pkgs; [
      kdePackages.kate
      thunderbird
    ];
  };

  # Install firefox.
  programs.firefox.enable = true;

  # Allow unfree packages
  nixpkgs.config.allowUnfree = true;

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = [
    pkgs.gcc
    pkgs.tmux
    pkgs.vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
    pkgs.nerdfonts
    pkgs.neovim
    pkgs.obsidian
    pkgs.git
    pkgs.zoom-us
    pkgs.espanso
    pkgs.slack
    pkgs._1password-gui
    pkgs._1password
    pkgs.kitty
    pkgs.bitwarden-desktop
    pkgs.cifs-utils
    pkgs.tailscale
    pkgs.parsify
  ];

  services.tailscale.enable = true;

	# NixOS has built-in modules to enable 1Password
	# along with some pre-packaged configuration to make
	# it work nicely. You can search what options exist
	# in NixOS at https://search.nixos.org/options

	# Enables the 1Password CLI
	programs._1password = { enable = true; };

	# Enables the 1Password desktop app
	programs._1password-gui = {
	enable = true;
	# this makes system auth etc. work properly
	polkitPolicyOwners = [ "curtismchale" ];
	};

  programs.zsh.enable = true;
  users.defaultUserShell = pkgs.zsh;
  environment.shells = with pkgs; [zsh];

  programs.neovim.enable = true;
  programs.neovim.defaultEditor = true;
  environment.variables.Editor = "nvim";

  #console.useXkbConfig = true;
  #services.xserver.xkb.options = "caps:swapescape";

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  # programs.gnupg.agent = {
  #   enable = true;
  #   enableSSHSupport = true;
  # };

  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  # services.openssh.enable = true;

  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  # This value determines the NixOS release from which the default
  # settings for stateful data, like file locations and database versions
  # on your system were taken. It‘s perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  system.stateVersion = "24.05"; # Did you read the comment?

}

Your config looks fine. Can you post more of the error that you’re getting, and/or double-check that this is definitely the exact contents of /etc/nixos/configuration.nix?

1 Like

And I just ran nixos-rebuild switch from xterm (instead of konsole) and it worked fine. So I wonder if somehow it was cached in konsole and rebuilding an older version of the file?

1 Like

Unless you forgot to save beforehand, I find that extremely unlikely.

1 Like

@waffle8946 I 100% sure I did not forget to save many times because I wondered that as well and used different editors to check the file from my standard NeoVim to Kate to Nano because it was baffling to me that I’d make a change and still see the error on rebuild despite looking at the file without the offending lines in it.