Error: file 'nixos-config' was not found

I’m trying to update my nvidia drivers by editing my configuration.nix but I get the error

error:
   … while evaluating the attribute 'config'

     at /nix/store/xblysc3prg1zqsi59fr36nj6wdiqryzp-source/lib/modules.nix:334:9:

      333|         options = checked options;
      334|         config = checked (removeAttrs config [ "_module" ]);
         |         ^
      335|         _module = checked (config._module);

   … while calling the 'seq' builtin

     at /nix/store/xblysc3prg1zqsi59fr36nj6wdiqryzp-source/lib/modules.nix:334:18:

      333|         options = checked options;
      334|         config = checked (removeAttrs config [ "_module" ]);
         |                  ^
      335|         _module = checked (config._module);

   (stack trace truncated; use '--show-trace' to show the full trace)

   error: file 'nixos-config' was not found in the Nix search path (add it using $NIX_PATH or -I)

   at «none»:0: (source not available)
building Nix...
error:
   … while evaluating the attribute 'config'

     at /nix/store/xblysc3prg1zqsi59fr36nj6wdiqryzp-source/lib/modules.nix:334:9:

      333|         options = checked options;
      334|         config = checked (removeAttrs config [ "_module" ]);
         |         ^
      335|         _module = checked (config._module);

   … while calling the 'seq' builtin

     at /nix/store/xblysc3prg1zqsi59fr36nj6wdiqryzp-source/lib/modules.nix:334:18:

      333|         options = checked options;
      334|         config = checked (removeAttrs config [ "_module" ]);
         |                  ^
      335|         _module = checked (config._module);

   (stack trace truncated; use '--show-trace' to show the full trace)

   error: file 'nixos-config' was not found in the Nix search path (add it using $NIX_PATH or -I)

   at «none»:0: (source not available)
building the system configuration...
error:
   … while evaluating the attribute 'config.system.build.toplevel'

     at /nix/store/xblysc3prg1zqsi59fr36nj6wdiqryzp-source/lib/modules.nix:334:9:

      333|         options = checked options;
      334|         config = checked (removeAttrs config [ "_module" ]);
         |         ^
      335|         _module = checked (config._module);

   … while calling the 'seq' builtin

     at /nix/store/xblysc3prg1zqsi59fr36nj6wdiqryzp-source/lib/modules.nix:334:18:

      333|         options = checked options;
      334|         config = checked (removeAttrs config [ "_module" ]);
         |                  ^
      335|         _module = checked (config._module);

   (stack trace truncated; use '--show-trace' to show the full trace)

   error: file 'nixos-config' was not found in the Nix search path (add it using $NIX_PATH or -I)

   at «none»:0: (source not available)

I don’t think theres anything wrong with my configuration.nix though.

{ 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 = "madmanmo"; # 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 = "187.1.3.4,localhost,internal.domain";

# Enable networking
networking.networkmanager.enable = true;

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

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

i18n.extraLocaleSettings = {
  LC_ADDRESS = "en_US.UTF-8";
  LC_IDENTIFICATION = "en_US.UTF-8";
  LC_MEASUREMENT = "en_US.UTF-8";
  LC_MONETARY = "en_US.UTF-8";
  LC_NAME = "en_US.UTF-8";
  LC_NUMERIC = "en_US.UTF-8";
  LC_PAPER = "en_US.UTF-8";
};

# Configure keymap in X11
services.xserver = {
  layout = "us";
  xkbVariant = "";
};

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

  # Enable sound with pipewire
  services.pipewire = {
  enable = true;
  pulse.enable = true;
  jack.enable = true;
  };

 # Firefox
programs.firefox.enable = true;

# Hyprland
programs.hyprland = {
  enable = true;
  xwayland.enable = true;
};

environment.sessionVariables = {
  # If your cursor becomes invisible
  WLR_NO_HARDWARE_CURSOR = "1";
  # Hint electron apps to use wayland
  NIXOS_OZONE_WL = "1";
};
 xdg.portal = {
  enable = true;
  extraPortals = with pkgs; [
    xdg-desktop-portal-kde
    xdg-desktop-portal-gtk
    xdg-desktop-portal-hyprland
  ];
};

# Nvidia
# Enable OpenGL
hardware.opengl = {
enable = true;
};

# Load nvidia driver for Xorg and Wayland
services.xserver.videoDrivers = ["nvidia"];

hardware.nvidia.modesetting.enable = true;
hardware.nvidia.powerManagement.enable = false;
hardware.nvidia.powerManagement.finegrained = false;
hardware.nvidia.open = false;
hardware.nvidia.nvidiaSettings = true;
# Special config to load the latest (535 or 550) driver for the support of the 4070 SU>
config.boot.kernelPackages.nvidiaPackages.mkDriver {
  version = "555.58";
  sha256_64bit = "sha256-bXvcXkg2kQZuCNKRZM5QoTaTjF4l2TtrsKUvyicj5ew=";
  sha256_aarch64 = "sha256-7XswQwW1iFP4ji5mbRQ6PVEhD4SGWpjUJe1o8zoXYRE=";
  openSha256 = "sha256-hEAmFISMuXm8tbsrB+WiUcEFuSGRNZ37aKWvf0WJ2/c=";
  settingsSha256 = "sha256-vWnrXlBCb3K5uVkDFmJDVq51wrCoqgPF03lSjZOuU8M=";
  persistencedSha256 = "sha256-lyYxDuGDTMdGxX3CaiWUh1IQuQlkI2hPEs5LI20vEVw=";
};


# Steam
programs.steam = {
  enable = true;
 remotePlay.openFirewall = true;
 # Open ports in the firewall for Steam Remote Play
 dedicatedServer.openFirewall = true;
 # Open ports in the firewall for Source Dedicated Server
};

# File managment
programs.thunar.enable = true;
programs.thunar.plugins = with pkgs.xfce; [
   thunar-archive-plugin
   thunar-volman
];
services.gvfs.enable = true; # Mount, trash, etc,.
services.tumbler.enable = true; # Thumbnail support for images

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

# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
#  vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is al>
pkgs.waybar
pkgs.wlogout
pkgs.swaynotificationcenter
pkgs.networkmanagerapplet
pkgs.swww
pkgs.starship
pkgs.gvfs
pkgs.gnome.file-roller
        libnotify
        wget
pkgs.emacsPackages.doom
       cava
      obs-studio
      kitty
      tofi
      fastfetch
      discord
 ];

fonts.packages = with pkgs; [
 (nerdfonts.override { fonts = [ "JetBrainsMono" "NerdFontsSymbolsOnly" ]; })
];

# 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?

nix.settings.experimental-features = [ "nix-command" "flakes" ];

}

Not sure if is relevant but I am using flakes and home-manager.

Basic troubleshooting:

  • What command are you running, exactly?
  • Where is your config located?

It would be in my /etc/nixos/. I was running sudo nixos-rebuild switch but after trying --flake I’m convinced that my configuration.nix has moved to my /.dotfiles. When I had brought this issue up to a server they had told me it was something wrong with my configuration file. I had told them I was running h-manager and flakes. I’m assuming the only way to go back is to use the command provided in the terminal and reset the path from using the configuration.nix in my /.dotfiles, to the one in my /etc/nixos/ folder?

What do you mean by “moved to your /.dotfiles”?
It’s your config, you decided where it goes, files don’t move on their own.

So depending on where you want it to be located, run sudo nixos-rebuild switch --flake /path/to/your/config.

2 Likes

So when I followed a guide to making flakes I didn’t fully understand that the method being shown by copying the configuration and hardware config to the .dotfiles was also changing the path of the my rebuilds. I assumed it was merely a precautionary backup as that’s what I do normally any time I make changes. I know I don’t exactly have to do that with nixos but It’s a habit I like to keep. I thought that the configs in /etc/nixos/ were always referenced there and couldn’t exactly be put somewhere else. I don’t know if I’m explaining that well. Thank you for helping me to understand that.