I have not been able to install nvidia drivers for months

was hoping 23.05 would solve it, but no.

no package will compile, no matter version, open source, proprietary, vulkan beta. at the moment all seem to throw this same error:

/build/NVIDIA-Linux-x86_64-515.49.25/kernel/nvidia/nv-mmap.c:593:23: error: assignment of read-only member ‘vm_flags’

anyone else had this problem and/or know how to solve it?


Could you share some details about the procedure/setup/configuration you are using to install the drivers?

just basic stuff in configuration.nix. i’ve included <nixos-hardware/common/gpu/nvidia/prime.nix> and various combinations of:

services.xserver.videoDrivers = [ “intel” “nvidia” ];
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.vulkan_beta;
#hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.production;
#hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.latest;
#hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_470;
#hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_340;
hardware.nvidia.open = false;

(it’s a laptop with integrated intel and discreet nvidia gpus)

i’m not a sophisticated nixos user. it’s a pretty basic setup. i’ve just upgraded to 23.05, but i’ve been getting errors long before also on 22.11

here’s when i try the legacy 470 version:

/build/NVIDIA-Linux-x86_64-470.161.03/kernel/nvidia/nv-acpi.c:84:19: error: initialization of ‘void (*)(struct acpi_device )’ from incompatible pointer type 'int ()(struct acpi_device *, int)’ [8;;Warning Options (Using the GNU Compiler Collection (GCC))]
84 | .remove = nv_acpi_remove_two_args,

and then again, a bunch of errors like this:

/build/NVIDIA-Linux-x86_64-470.161.03/kernel/nvidia/nv-mmap.c:599:23: error: assignment of read-only member ‘vm_flags’
599 | vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND;

Could you try with services.xserver.videoDrivers = [ "intel" "nvidia" ]; alone, without the include or any other related setting?

solene, thank you for your replies.

i’ve done what you suggested. here is the result, much the same:

/build/NVIDIA-Linux-x86_64-520.56.06/kernel/nvidia/nv-mmap.c: In function ‘nvidia_mmap_numa’:
/build/NVIDIA-Linux-x86_64-520.56.06/kernel/nvidia/nv-mmap.c:446:19: error: assignment of read-only member ‘vm_flags’
446 | vma->vm_flags |= VM_MIXEDMAP;
| ^~
/build/NVIDIA-Linux-x86_64-520.56.06/kernel/nvidia/nv-dma.c: In function ‘nv_dma_use_map_resource’:
/build/NVIDIA-Linux-x86_64-520.56.06/kernel/nvidia/nv-dma.c:783:5: warning: ISO C90 forbids mixed declarations and code [8;;Warning Options (Using the GNU Compiler Collection (GCC))]
783 | const struct dma_map_ops *ops = get_dma_ops(dma_dev->dev);
| ^~~~~
/build/NVIDIA-Linux-x86_64-520.56.06/kernel/nvidia/nv-mmap.c: In function ‘nvidia_mmap_helper’:
/build/NVIDIA-Linux-x86_64-520.56.06/kernel/nvidia/nv-mmap.c:580:23: error: assignment of read-only member ‘vm_flags’
580 | vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND;

…and several more vm_flags errors.

the c90 warning made me think it could be a c standard thing, though i’m not a c programmer and anyway i don’t know how to get nix to adjust the compiler flags

i started out with just services.xserver.videoDrivers = [ "intel" "nvidia" ]; and only started trying the other stuff when the compile began to error out.

Are you using latest linux kernel? It seems nvidia drivers with 6.3 have some issues Driver 470.182.03 fails to compile with Linux 6.3.1 - #2 by arnab.bhar - Linux - NVIDIA Developer Forums

You’re not actually running nixos-23.05. You’re building version 520.56.06 of the nvidia driver, but nixos-23.05 was released with version 530.41.03. If I build with nixos-22.11, it builds 520.56.06, and it fails if I use linux 6.3 with the same error as your’s. If I use the default linux 5.15, it builds fine. But yea, you’re not running NixOS 23.05, and in NixOS 22.11, the solution is to not use linux 6.3. EDIT: And to be clear, it builds fine for linux 6.3 on nixos-23.05

thanks, ej. you spotted my mistake(s). i seem to have mismanaged channels and packages. for example i thought i had upgraded to 23.05 but had not. must have made a typo. need to get a better grip on what is on my system.

thank you to solene and ej for your help.

1 Like