Error persists even after allowing unfree and nvidia acceptLicense to true

Even after adding unfree packages and nvidia license acceptance to true, Still I’m getting this following error.
Note: I have added unfree and nvidia accept license in both places:
ksvnixospcconfigs/configuration.nix at 0f8fa33c56d11010988388ce5d5a233657ab551a · vivekanandan-ks/ksvnixospcconfigs · GitHub

ksvnixospcconfigs/flake.nix at 0f8fa33c56d11010988388ce5d5a233657ab551a · vivekanandan-ks/ksvnixospcconfigs · GitHub

Error:

  nh os boot -a /home/ksvnixospc/Documents/ksvnixospcconfigs/
> Building NixOS configuration
evaluation warning: You have set specialArgs.pkgs, which means that options like nixpkgs.config
                    and nixpkgs.overlays will be ignored. If you wish to reuse an already created
                    pkgs, which you know is configured correctly for this NixOS configuration,
                    please import the `nixosModules.readOnlyPkgs` module from the nixpkgs flake or
                    `(modulesPath + "/misc/nixpkgs/read-only.nix"), and set `{ nixpkgs.pkgs = <your pkgs>; }`.
                    This properly disables the ignored options to prevent future surprises.
error:
       … while calling the 'head' builtin
         at /nix/store/cjjpqrp9xy44j5fjh3mygyxy3i7mslj2-source/lib/attrsets.nix:1696:13:
         1695|           if length values == 1 || pred here (elemAt values 1) (head values) then
         1696|             head values
             |             ^
         1697|           else

       … while evaluating the attribute 'value'
         at /nix/store/cjjpqrp9xy44j5fjh3mygyxy3i7mslj2-source/lib/modules.nix:1118:7:
         1117|     // {
         1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |       ^
         1119|       inherit (res.defsFinal') highestPrio;

       … while evaluating the option `system.build.toplevel':

       … while evaluating definitions from `/nix/store/cjjpqrp9xy44j5fjh3mygyxy3i7mslj2-source/nixos/modules/system/activation/top-level.nix':

       … while evaluating the option `warnings':

       … while evaluating definitions from `/nix/store/cjjpqrp9xy44j5fjh3mygyxy3i7mslj2-source/nixos/modules/system/boot/systemd/tmpfiles.nix':

       … while evaluating the option `systemd.tmpfiles.settings.graphics-driver."/run/opengl-driver"."L+".argument':

       … while evaluating definitions from `/nix/store/cjjpqrp9xy44j5fjh3mygyxy3i7mslj2-source/nixos/modules/hardware/graphics.nix':

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

       error: Use of NVIDIA Software requires license acceptance of the license:

         - License For Customer Use of NVIDIA Software [1]

       You can express acceptance by setting acceptLicense to true your nixpkgs.config.
       Example:

         configuration.nix:
           nixpkgs.config.allowUnfree = true;
           nixpkgs.config.nvidia.acceptLicense = true;

         config.nix:
           allowUnfree = true;
           nvidia.acceptLicense = true;

       [1]: https://www.nvidia.com/content/DriverDownloads/licence.php?lang=us
┏━ 1 Errors: 
 ⋮ 
┃        … while evaluating the option `system.build.toplevel':
┃ 
┃        … while evaluating definitions from `/nix/store/cjjpqrp9xy44j5fjh3mygyxy3i7mslj2-source/nixos/modules/system/activation/top-level.nix':
┃ 
┃        … while evaluating the option `warnings':
┃ 
┃        … while evaluating definitions from `/nix/store/cjjpqrp9xy44j5fjh3mygyxy3i7mslj2-source/nixos/modules/system/boot/systemd/tmpfiles.nix':
┃ 
┃        … while evaluating the option `systemd.tmpfiles.settings.graphics-driver."/run/opengl-driver"."L+".argument':
┃ 
┃        … while evaluating definitions from `/nix/store/cjjpqrp9xy44j5fjh3mygyxy3i7mslj2-source/nixos/modules/hardware/graphics.nix':
┃ 
┃        (stack trace truncated; use '--show-trace' to show the full, detailed trace)
┃ 
┃        error: Use of NVIDIA Software requires license acceptance of the license:
┃ 
┃          - License For Customer Use of NVIDIA Software [1]
┃ 
┃        You can express acceptance by setting acceptLicense to true your nixpkgs.config.
┃        Example:
┃ 
┃          configuration.nix:
┃            nixpkgs.config.allowUnfree = true;
┃            nixpkgs.config.nvidia.acceptLicense = true;
┃ 
┃          config.nix:
┃            allowUnfree = true;
┃            nvidia.acceptLicense = true;
┃ 
┃        [1]: https://www.nvidia.com/content/DriverDownloads/licence.php?lang=us
┣━━━                                                             
┗━ ∑ ⚠ Exited with 1 errors reported by nix at 00:49:33 after 10s
Error: 
   0: Failed to build configuration
   1: Command exited with status Exited(1)

Location:
   src/commands.rs:693

How to solve this issue?

This is your problem. Never set pkgs or system in specialArgs nor should you pass them to lib.nixosSystem.

2 Likes

I happened to talk with OP on a Discord we shared, but for the benefit of the group, the issue is caused by passing pkgs as a special arg, which should never be done. It is already a regular arg so will always be available in the module evaluation anyway.

1 Like

Oh ok. Got similar guidance from discord too. Also if I didn’t pass system in the special args, error is throwing up . So I have just given the system for now.

Thanks @waffle8946 @Michael-C-Buckley.

1 Like

You should set nixpkgs.hostPlatform in your NixOS config instead.

1 Like

Wouldn’t passing the system value to specialArgs abd using the value dynamically is a better approach?:thinking:
So that it’s almost only one line changing when moving between systems.
Or I’m missing out something here?

You are circumventing intend and expectations.

Passing stuff from outside should always be the exception, even more so if there are means within the module system itself to achieve the same or a similar goal.

2 Likes

I’m not speaking about my opinion, I’m simply pointing out that passing system via lib.nixosSystem is deprecated and may eventually turn into an error, and the expected way to pass this is via nixpkgs.hostPlatform.
One reason is that system is too nonspecific, since from the cross-compilation perspective there are three possible platforms (build, host, target), and it’s best to be explicit about which one is intended when configuring a nixpkgs instance.

Just recently, even, pkgs.system was deprecated (via warning) in favour of pkgs.stdenv.hostPlatform.system - the more explicit form - for the same reason (though really it was silently deprecated since 2021).

You will likely also need to change your hostname and your disk layout when switching systems - which is why nixos-generate-config will put nixpkgs.hostPlatform into hardware-configuration.nix along with the disks.

And yes as said above, circumventing the module system is usually an antipattern.

2 Likes

If you’re passing specialArgs, you have access to the modules list. If you can pass modules, you can just add a one-line module:

{ nixpkgs.hostPlatform = "something-linux"; }
2 Likes

Makes some sense for me. I would love to see an example of how it’s properly used in a flake.nix and configuration.nix
Also the reply to: @dramforever