I am trying to get the new nvidia 560 to install on nixos. I added the unstable branch, and then specified the driver from that branch:
“{
services.xserver.videoDrivers = [ “nvidia” ];
hardware.nvidia.package = (import {}).linuxPackages.nvidiaPackages.latest;
}”
but got the error:
"error:
… while calling the ‘head’ builtin
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/attrsets.nix:1575:11:
1574| || pred here (elemAt values 1) (head values) then
1575| head values
| ^
1576| else
… while evaluating the attribute 'value'
at /nix/var/nix/profiles/per-user/root/channels/nixos/lib/modules.nix:809:9:
808| in warnDeprecation opt //
809| { value = builtins.addErrorContext "while evaluating the option ${showOption loc}':" value;
| ^
810| inherit (res.defsFinal') highestPrio;
(stack trace truncated; use '--show-trace' to show the full trace)
error: Package ‘nvidia-x11-560.35.03-6.6.51’ in /nix/store/hwxpwash11jh29gm8hlxqxwbzcrh5kdq-nixos-unstable/nixos-unstable/pkgs/os-specific/linux/nvidia-x11/generic.nix:236 has an unfree license (‘unfreeRedistributable’), refusing to evaluate.
a) To temporarily allow unfree packages, you can use an environment variable
for a single invocation of the nix tools.
$ export NIXPKGS_ALLOW_UNFREE=1
Note: When using nix shell, nix build, nix develop, etc with a flake,
then pass --impure in order to allow use of environment variables.
b) For nixos-rebuild you can set
{ nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.
Alternatively you can configure a predicate to allow specific packages:
{ nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
"nvidia-x11"
];
}
c) For nix-env, nix-build, nix-shell or any other Nix command you can add
{ allowUnfree = true; }
to ~/.config/nixpkgs/config.nix."
even though I have unfree packages enabled. I found some others online with the same problem, but they didn’t explain their solutions well enough for me to recreate. Any help?
(For future reference: stick ``` on a line by itself before and after blocks of code like this to format it correctly.)
From the import {} I imagine you have a <nixpkgs> in there that got eaten by formatting. Don’t re-import Nixpkgs from your config; just use pkgs.linuxPackages.nvidiaPackages.latest. (Your config file should start with { config, lib, pkgs, ... }: which puts the pkgs variable in scope.)
If you import a second nixpkgs It’s a new instance and doesn’t have the same config settings. You would need to put config.allowUnfree = true; in the args (or inherit config; to inherit all config).
so where would either of these strings go in the config? I already have nixpkgs.config.allowUnfree = true; in my config, do I need it again somewhere else? I tried (import {nixpkgs.config.allowUnfree = true;}) but it told me it refused to elaborate and then gave me the same options for allowing unfree packages.
ok, aside from the basic syntax errors here, you should know that you can’t get just the nvidia kernel module from unstable. That’s going to be built for the kernel from unstable, and you can’t use a kernel module for a different kernel build.