Upgrade nix has a problem for me

when i want to upgrade my nix package i get this error

amir@nixos ~> upgrade-sys
[sudo] password for amir: 
warning: Git tree '/etc/nixos' is dirty
warning: Git tree '/etc/nixos' is dirty
building the system configuration...
warning: Git tree '/etc/nixos' is dirty
error: builder for '/nix/store/m139vk4k6kbzjdad3xvdx6g3qrp1a2cc-nvidia-x11-570.153.02-6.15.drv' failed with exit code 2;
       last 25 log lines:
       > nvidia.o: warning: objtool: _nv045909rm+0x77: 'naked' return found in MITIGATION_RETHUNK build
       > nvidia.o: warning: objtool: _nv045853rm+0x7f: 'naked' return found in MITIGATION_RETHUNK build
       > nvidia.o: warning: objtool: _nv035412rm+0x3e: 'naked' return found in MITIGATION_RETHUNK build
       > nvidia.o: warning: objtool: _nv035411rm+0x27: 'naked' return found in MITIGATION_RETHUNK build
       > nvidia.o: warning: objtool: _nv035415rm+0x37: 'naked' return found in MITIGATION_RETHUNK build
       > nvidia.o: warning: objtool: _nv035414rm+0x24: 'naked' return found in MITIGATION_RETHUNK build
       > nvidia.o: warning: objtool: _nv035413rm+0xca: 'naked' return found in MITIGATION_RETHUNK build
       > nvidia.o: warning: objtool: _nv035416rm+0x193: 'naked' return found in MITIGATION_RETHUNK build
       > nvidia.o: warning: objtool: _nv035418rm+0x17f: 'naked' return found in MITIGATION_RETHUNK build
       > nvidia.o: warning: objtool: _nv013509rm+0x5d: 'naked' return found in MITIGATION_RETHUNK build
       > nvidia.o: warning: objtool: _nv046215rm+0x12f: 'naked' return found in MITIGATION_RETHUNK build
       >   MODPOST Module.symvers
       > WARNING: modpost: missing MODULE_DESCRIPTION() in nvidia.o
       > WARNING: modpost: missing MODULE_DESCRIPTION() in nvidia-uvm.o
       > WARNING: modpost: missing MODULE_DESCRIPTION() in nvidia-modeset.o
       > WARNING: modpost: missing MODULE_DESCRIPTION() in nvidia-drm.o
       > ERROR: modpost: GPL-incompatible module nvidia.ko uses GPL-only symbol '__vma_start_write'
       > ERROR: modpost: GPL-incompatible module nvidia-drm.ko uses GPL-only symbol '__vma_start_write'
       > make[4]: *** [/nix/store/gl4zb4minm4ddaz31lhsx2rr964z1gjl-linux-6.15-dev/lib/modules/6.15.0/source/scripts/Makefile.modpost:147: Module.symvers] Error 1
       > make[3]: *** [/nix/store/gl4zb4minm4ddaz31lhsx2rr964z1gjl-linux-6.15-dev/lib/modules/6.15.0/source/Makefile:1953: modpost] Error 2
       > make[2]: *** [/nix/store/gl4zb4minm4ddaz31lhsx2rr964z1gjl-linux-6.15-dev/lib/modules/6.15.0/source/Makefile:248: __sub-make] Error 2
       > make[2]: Leaving directory '/build/NVIDIA-Linux-x86_64-570.153.02/kernel'
       > make[1]: *** [Makefile:248: __sub-make] Error 2
       > make[1]: Leaving directory '/nix/store/gl4zb4minm4ddaz31lhsx2rr964z1gjl-linux-6.15-dev/lib/modules/6.15.0/source'
       > make: *** [Makefile:115: modules] Error 2
       For full logs, run:
         nix log /nix/store/m139vk4k6kbzjdad3xvdx6g3qrp1a2cc-nvidia-x11-570.153.02-6.15.drv
error: 1 dependencies of derivation '/nix/store/dh8mvlmrp7lva0k52lps2vk4dgj5sk4h-etc.drv' failed to build
error: 1 dependencies of derivation '/nix/store/mf9nwb29mlzxmh6si7854lqp6ir5w42z-firmware.drv' failed to build
error: 1 dependencies of derivation '/nix/store/c85d7l5g89zfzih7zy86dcz6795r19dv-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/h7mhv04nixixi0zfancd6mkhqy20dkyi-nixos-system-nixos-25.11.20250527.4faa5f5.drv' failed to build

this alias for upgrade use

upgrade-sys = "cd /etc/nixos/ && sudo nix flake update && sudo nixos-rebuild switch --upgrade --flake /etc/nixos/ && sudo nixos-rebuild boot --upgrade --flake /etc/nixos/ && cd ~ && conda-shell -c 'conda init fish && conda install python=3.11 -y && pip install -U ipython g4f[all] gallery-dl orjson'";
boot.initrd.kernelModules = [ "nvidia" ];
 services.xserver.videoDrivers = ["nvidia"];
  boot.kernelPackages = pkgs.linuxPackages_latest;
  #boot.kernelPackages = pkgs.linuxKernel.packages.linux_xanmod_latest;
  hardware.nvidia = {
    modesetting.enable = true;
    open = true;
    powerManagement.enable = false;
    powerManagement.finegrained = false;
    nvidiaSettings = true;
    prime = {
	offload = {
	enable = true;
	enableOffloadCmd = true;
	};
#        # Make sure to use the correct Bus ID values for your system!
		intelBusId = "PCI:0:2:0";
		nvidiaBusId = "PCI:1:0:0";
                # amdgpuBusId = "PCI:54:0:0"; For AMD GPU
	};
    package = config.boot.kernelPackages.nvidiaPackages.stable;
  };

how can i fix this error and have successful upgrade ?
thanks

See my answer to the exact same question from yesterday: Cannot Build nvidia-x11-570.153.02-6.15 - #5 by TLATER

It’s the bi-yearly season of kernel changes causing everyone to learn what it actually means for nvidia’s drivers to be third party :stuck_out_tongue:

2 Likes

Thank you. So, does that mean I should change the kernel to the LTS version?

I put a handly lil’ tl;dr to explain exactly what you need to do:

1 Like

Does removing this line automatically switch to the LTS kernel?
What I mean is, does Nix automatically detect this?

If you don’t set that line, your configuration will use the default setting. The default setting is the LTS kernel.

NixOS modules always revert to the default if you don’t set a setting. You should avoid setting as many options as you can, because then upstream takes care of maintaining those for you.

In fact, all the configuration you shared should be simplified to just this:

services.xserver.videoDrivers = [ "nvidia" ];

hardware.nvidia.prime = {
  offload = {
    enable = true;
    enableOffloadCmd = true;
  };
  intelBusId = "PCI:0:2:0";
  nvidiaBusId = "PCI:1:0:0";
};

… since all the other settings are just the defaults (and possibly actively harmful in the case of boot.initrd.kernelModules).

1 Like

Thank you for your help! I have another question.
After the upgrade, I noticed that my kernel was version 14.6 before the upgrade, but after I removed the line, the kernel version changed to 12. Is there a way to manually set the kernel back to version 14.6 or the latest available version before 15?

Of course, if this might cause any issues, please let me know so I don’t proceed, as I don’t have much experience with Nix, and I got the configuration from one of my friends.

Yes, but I would not recommend it unless you really need version 14, since at the end of the month it will go EOL and you’ll have this exact same issue (and will at that point need to downgrade to 12 anyway). Sounds like your hardware is booting fine on version 12, so I’d recommend sticking with it until the next LTS kernel version comes around.

Or in other words, I would recommend not touching boot.kernelPackages unless you have a good reason to, especially if you’re using an nvidia GPU.

1 Like