New flake, error: path ... does not exist

I just installed Nix and have been trying to create a starter nix flake and can’t get it to compile. I am getting a “Path does not exist error.” Below is the information I think will help (thanks in advance):

Flake.nix

 {
  description = "My flake";

  inputs = {
    nixpkgs-unstable.url = "github:nixos/nixpkgs?ref=nixos-unstable";
    nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-25.05";
    home-manager.url = "github:nix-community/home-manager";
    home-manager.inputs.nixpkgs.follows = "nixpkgs-unstable";
  };
  
  outputs = { self, nixpkgs-unstable, nixpkgs-stable, home-manager, ... } @ inputs:
  {
    nixosConfigurations = {
      legion5g8 = nixpkgs-unstable.lib.nixosSystem {
        system = "x86_64-linux";
        
        modules = [
          ./hosts/legion5g8/configuration.nix
          ./hosts/legion5g8/hardware-configuration.nix

          # Overlay to expose stable as pkgs.stable
          ({ config, pkgs, ... }: {
            nixpkgs.overlays = [
              (final: prev: {
                stable = import nixpkgs-stable {
                  system = "x86_64-linux";
                  config.allowUnfree = true;
                };
              })
            ];

            nixpkgs.config.allowUnfree = true;
          })

          home-manager.nixosModules.home-manager
          {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;
            # home-manager.users.ben = import;
          }
      ];
    };  
  };
};
}

nix flake show .
git+file:///home/ben/nix-config
└───nixosConfigurations
└───legion5g8: NixOS configuration

[ben@nixos:~/nix-config/hosts/legion5g8]$

{ 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;

  # Use latest kernel.
  boot.kernelPackages = pkgs.linuxPackages_latest;

  networking.hostName = "legion5g8";
  # 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/Indiana/Indianapolis";

  # 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";
    LC_TELEPHONE = "en_US.UTF-8";
    LC_TIME = "en_US.UTF-8";
  };

  # Enable the X11 windowing system.
  services.xserver.enable = true;

  # Enable the GNOME Desktop Environment.
  #services.xserver.displayManager.gdm.enable = true;
  #services.xserver.desktopManager.gnome.enable = true;
  services.xserver.desktopManager.budgie.enable = true;
  services.xserver.displayManager.lightdm.enable = true;


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

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

  # Enable sound with pipewire.
  services.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 OpenGL hardware support.
  hardware.opengl = {
  	enable = true;
  	driSupport32Bit = true;
  };

  # Enable the Nvidia driver.
  services.xserver.videoDrivers = [ "amdgpu" "nvidia"];
  hardware.nvidia = {
  	modesetting.enable = true;
  	powerManagement.enable = true;
  	powerManagement.finegrained = true;
  	open = false;
    nvidiaSettings = true;
    package = config.boot.kernelPackages.nvidiaPackages.stable;

    # PRIME offloading is what enables hybrid graphics on a laptop
  	prime = {
  	  offload = {
  	    enable = true;
  		enableOffloadCmd = true;
  	};
      #	lspci | grep -E "VGA|3D"
  	  amdgpuBusId = "PCI:06:00:0";
  	  nvidiaBusId = "PCI:01:00:0";
    };
  };

  boot.initrd.kernelModules = [ "amdgpu"];
  
  # example below says "use dedicated Nvidia for steam"
  # nvidia-offload steam
  
  # Enable touchpad support (enabled default in most desktopManager).
  # services.xserver.libinput.enable = true;
  virtualisation.docker.enable = true;
  #hardware.nvidia-container-toolkit.enable = true;
  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.ben = {
    isNormalUser = true;
    description = "ben";
    extraGroups = [ "networkmanager" "wheel" "docker"];
    packages = with pkgs; [
    #  thunderbird
    ];
  };

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

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

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
   micro # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
   wget
   jujutsu
   helix
   ghostty
   pciutils
   gitFull
  ];

  # 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 = "25.05"; # Did you read the comment?
}

Remember to git add (or at minimum, git add -N) any untracked files that are supposed to be part of the flake evaluation. Nix doesn’t copy untracked files to the store before evaluating the flake, so the untracked files “don’t exist”.

1 Like

omg, I can’t believe it was so easy. I didn’t want to commit anything until it worked, but once I added the files, it worked. Thank you!

sorry, just passing through, you got a typo (?), should be:

nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";

is that right?

It’s not a typo, it’s the same thing.

You don’t need to commit the files. Staging the untracked files or even git add --intent-to-add would suffice. Once they are tracked, even that is no longer necessary. (Though it’s a best practice to commit early/often of course.)