Cannot update flake lock file it fetches the wrong nixpkgs.url input "Not Found" "404"

when trying to update the flake lock file:

[user@hostname:~]$ sudo nix flake lock
error:
       … while updating the lock file of flake 'path:/home/user?lastModified=0&narHash=sha256-oMz0/hdGUERHv06iAz9HojyzKD6gZqe%2BBPGWEugiF1E%3D'

       … while updating the flake input 'nixpkgs'

       … while fetching the input 'github:nixos/nixos-24.05'

       error: unable to download 'https://api.github.com/repos/nixos/nixos-24.05/commits/HEAD': HTTP error 404

       response body:

       {
         "message": "Not Found",
         "documentation_url": "https://docs.github.com/rest/commits/commits#get-a-commit",
         "status": "404"
       }
# flake.nix
{
  description = "A simple NixOS flake";

  inputs = {
    # NixOS official package source, using the nixos-24.05 branch here
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-24.05";
    home-manager.url = "github:nix-community/home-manager?ref=release-24.05";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = { self, nixpkgs, home-manager, ... }: {
    # Please replace my-nixos with your hostname
    nixosConfigurations = {
    hostname = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [
        # Import the previous configuration.nix we used,
        # so the old configuration file still takes effect
        ./configuration.nix
	home-manager.nixosModules.home-manager {
	home-manager.useGlobalPkgs = true;
	home-manager.useUserPackages = true;
	home-manager.users.user = import ./home.nix;
	}
      ];
    };
  };
};
}

Is there something wrong with this? I tried to remove cache by
sudo nixos-rebuild switch --flake .#hostname --refresh
or
sudo nixos-rebuild switch --flake .#hostname --option eval-cache false --show-trace --verbose

Full config:

Try github:NixOS/nixpkgs/nixos-24.05.

1 Like

I used to have that, the issue is probably with some caching:

sudo nixos-rebuild switch --flake .#hostname --option eval-cache false --impure --show-trace --verbose --refresh
$ nix --extra-experimental-features nix-command flakes build --out-link /tmp/nixos-rebuild.3lLkAo/nixos-rebuild .#nixosConfigurations."hostname".config.system.build.nixos-rebuild --option eval-cache false --impure --show-trace --verbose --refresh
error:
       … while updating the lock file of flake 'path:/home/user?lastModified=0&narHash=sha256-z2iAumV4cN22GR5HSef4CL7hqmtiLa9VbvGhQrGZfFs%3D'

       … while updating the flake input 'nixpkgs'

       … while fetching the input 'github:nixos/nixos-24.05'

       error: unable to download 'https://api.github.com/repos/nixos/nixos-24.05/commits/HEAD': HTTP error 404

       response body:

       {
         "message": "Not Found",
         "documentation_url": "https://docs.github.com/rest/commits/commits#get-a-commit",
         "status": "404"
       }

after your suggestion in inputs.nixpkgs.url

[user@hostname:~]$ NIXPKGS_ALLOW_UNFREE=1 nix build github:nixos/nixpkgs/nixos-24.05#hostname --impure

This however works…

EDIT:
Removing the cache works:

rm -rf ~/.cache/nix
[user@hostname:/etc/nixos]$ sudo nixos-rebuild switch --flake .#hostname --option eval-cache false --impure --show-trace --verbose --refresh
$ nix --extra-experimental-features nix-command flakes build --out-link /tmp/nixos-rebuild.4ttTif/nixos-rebuild .#nixosConfigurations."hostname".config.system.build.nixos-rebuild --option eval-cache false --impure --show-trace --verbose --refresh
$ exec /nix/store/18zr0fxqs5k1brllvfwkmk4c2sf1lg98-nixos-rebuild/bin/nixos-rebuild switch --flake .#hostname --option eval-cache false --impure --show-trace --verbose --refresh
building the system configuration...
Building in flake mode.
$ nix --extra-experimental-features nix-command flakes build .#nixosConfigurations."hostname".config.system.build.toplevel --option eval-cache false --impure --show-trace --verbose --refresh --out-link /tmp/nixos-rebuild.K2mT3z/result
$ sudo nix-env -p /nix/var/nix/profiles/system --set /nix/store/3kzzk7whd6g3c6389fzjn66nmarxvrh1-nixos-system-hostname-24.05.20240724.d0907b7
$ sudo systemd-run -E LOCALE_ARCHIVE -E NIXOS_INSTALL_BOOTLOADER= --collect --no-ask-password --pipe --quiet --same-dir --service-type=exec --unit=nixos-rebuild-switch-to-configuration --wait true
Using systemd-run to switch configuration.
$ sudo systemd-run -E LOCALE_ARCHIVE -E NIXOS_INSTALL_BOOTLOADER= --collect --no-ask-password --pipe --quiet --same-dir --service-type=exec --unit=nixos-rebuild-switch-to-configuration --wait /nix/store/3kzzk7whd6g3c6389fzjn66nmarxvrh1-nixos-system-hostname-24.05.20240724.d0907b7/bin/switch-to-configuration switch
activating the configuration...
setting up /etc...
reloading user units for user...
restarting sysinit-reactivation.target

Removing the cache works

rm -rf ~/.cache/nix

However it is not the correct long-term solution

actually just cd /etc/nixos should work.