Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos: hardware.nvidia.package option for selecting nvidia package #49703

Closed
wants to merge 1 commit into from

Conversation

FRidh
Copy link
Member

@FRidh FRidh commented Nov 3, 2018

Make it possible to select a derivation to use. This also moves some
logic that belongs to the derivation back into it.

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

hardware.nvidia.package = lib.mkOption {
type = lib.types.package;
default = config.boot.kernelPackages.nvidia_x11;
defaultText = "config.boot.kernelPackages.nvidia_x11";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking we should also get rid of the aliases and use instead

config.boot.kernelPackages.nvidiaPackages.stable

@FRidh
Copy link
Member Author

FRidh commented Nov 4, 2018

Note this breaks the config for people using nvidiaXX in videoDrivers.

@coreyoconnor
Copy link
Contributor

AFAICT overriding the linuxPackages derivation can achieve the same. EG:

  nixpkgs.config =
  {
    packageOverrides = super: let self = super.pkgs; in
    {
      linuxPackages = super.linuxPackages_4_18.extend (self: super: {
        nvidiaPackages = super.nvidiaPackages // {
          stable = self.nvidiaPackages.stable_390;
        };
      });
    };
};

@FRidh
Copy link
Member Author

FRidh commented Nov 11, 2018

@coreyoconnor yep, there are typically multiple ways to achieve the same output. This is about user interface and having a consistent way of selecting a package in a module.

Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make sense to add an assertion that checks for any nvidiaxx values in the driver list and error out with the corresponding equivalent config after this change.

@@ -96,6 +78,16 @@ in
shows the Intel GPU at "00:02.0", set this option to "PCI:0:2:0".
'';
};

hardware.nvidia.package = lib.mkOption {
type = lib.types.package;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lib is already with'd above.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was not addressed, but it's just a nitpick. What I meant is that you can replace type = lib.types.package with type = types.package

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, I just think we should keep the lib prefix.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh why? I know some people don't like with, but either we use it for the whole file or not at all. I wouldn't mind either, but this mixed style is odd.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any resolution to this?

nixos/modules/hardware/video/nvidia.nix Outdated Show resolved Hide resolved
@eadwu
Copy link
Member

eadwu commented Dec 22, 2018

In case this ever gets merged, it might be a good idea to change https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/hardware/video/bumblebee.nix#L80 as well for those who still use Bumblebee.

@FRidh
Copy link
Member Author

FRidh commented Dec 30, 2018

The module will now check for driver names with versions. It's ugly but it functions.

Regarding bumblebee, I am not sure how to solve that. In that case, one would ideally also be able to point to a specific nvidia package. Clearly, I don't want to duplicate this logic in that module. I suppose the nvidia module could be extended to operate differently in case bumblebee is activated. E.g., all the options are offered, but actually loading the kernel module would depend on whether bumblebee is activated. I'll keep it out of this PR.

@FRidh
Copy link
Member Author

FRidh commented Jan 3, 2019

@vcunat @infinisil could you give this (one more) look? I intend to otherwise merge in a couple of days.

hasDeprecated = drivers: any isDeprecated drivers;
in if (hasDeprecated drivers) then
throw ''
Selecting an nvidia driver has been modified for NixOS 19.03. The version is now set using `hardware.nvidia.package`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should show in the error message already what package the user should choose based on their previous setting. We have all the information we need to make a better error message and ease the transition for users.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I guess it should be fine to simply add one "legacy" example and maybe also one "beta" example.

Copy link
Member

@vcunat vcunat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appears to be OK to me.

BTW, note: #50861 (comment)

@nixos-discourse
Copy link

This pull request has been mentioned on Nix community. There might be relevant details there:

https://discourse.nixos.org/t/use-nvidia-410-drivers-on-nixos/1364/16

@baracoder
Copy link
Contributor

This PR is stale for half a year, with only two minor changes required.
ping @FRidh @infinisil @vcunat
Can we move it forward somehow?

@felschr
Copy link
Member

felschr commented Mar 14, 2020

ping

@stale
Copy link

stale bot commented Sep 10, 2020

Hello, I'm a bot and I thank you in the name of the community for your contributions.

Nixpkgs is a busy repository, and unfortunately sometimes PRs get left behind for too long. Nevertheless, we'd like to help committers reach the PRs that are still important. This PR has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.

If this is still important to you and you'd like to remove the stale label, we ask that you leave a comment. Your comment can be as simple as "still important to me". But there's a bit more you can do:

If you received an approval by an unprivileged maintainer and you are just waiting for a merge, you can @ mention someone with merge permissions and ask them to help. You might be able to find someone relevant by using Git blame on the relevant files, or via GitHub's web interface. You can see if someone's a member of the nixpkgs-committers team, by hovering with the mouse over their username on the web interface, or by searching them directly on the list.

If your PR wasn't reviewed at all, it might help to find someone who's perhaps a user of the package or module you are changing, or alternatively, ask once more for a review by the maintainer of the package/module this is about. If you don't know any, you can use Git blame on the relevant files, or GitHub's web interface to find someone who touched the relevant files in the past.

If your PR has had reviews and nevertheless got stale, make sure you've responded to all of the reviewer's requests / questions. Usually when PR authors show responsibility and dedication, reviewers (privileged or not) show dedication as well. If you've pushed a change, it's possible the reviewer wasn't notified about your push via email, so you can always officially request them for a review, or just @ mention them and say you've addressed their comments.

Lastly, you can always ask for help at our Discourse Forum, or more specifically, at this thread or at #nixos' IRC channel.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Sep 10, 2020
@baracoder
Copy link
Contributor

I would still like it 👍

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Sep 10, 2020
@ftrojahn
Copy link

+1 Like to have this, too.

@eadwu
Copy link
Member

eadwu commented Sep 17, 2020

I can probably maintain this PR until it's merged and if @FRidh doesn't have the time?

Not sure if ownership can be switched but I'll probably create a new PR if needed.

Make it possible to select a derivation to use. This also moves some
logic that belongs to the derivation back into it.
@FRidh
Copy link
Member Author

FRidh commented Sep 17, 2020

I've rebased this PR (and it builds again) but I don't intend to go further with it. Feel free to take it over! Creating a new PR is fine.

@FRidh
Copy link
Member Author

FRidh commented Jan 31, 2021

#99323

@FRidh FRidh closed this Jan 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet