From ae5bc98bb7b1cbec930fd146e25ae033a440df00 Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Sun, 26 Apr 2020 20:10:32 +0200 Subject: [PATCH] Remove the need for an overlay nvidia_x11 was overrode in an overlay. It is no longer the case and the override is now explicit. This will allows the creation of a `nixGL.nix` file callable with `callPackage`. This change is a preliminary work for inclusion in `nixpkgs`, as requested in #16. It will also highly improve the use on nixGL in other project because user won't have to pass a non initialized `nixpkgs`. --- default.nix | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/default.nix b/default.nix index e6fd2c2..de21356 100644 --- a/default.nix +++ b/default.nix @@ -39,26 +39,7 @@ let name = oldAttrs.name + "-${_nvidiaVersion}"; }); - overlay = self: super: - { - linuxPackages = super.linuxPackages // - { - nvidia_x11 = (super.linuxPackages.nvidia_x11.override { - }).overrideAttrs(oldAttrs: rec { - name = "nvidia-${_nvidiaVersion}"; - src = let url ="http://download.nvidia.com/XFree86/Linux-x86_64/${_nvidiaVersion}/NVIDIA-Linux-x86_64-${_nvidiaVersion}.run"; - in if nvidiaHash != null - then super.fetchurl { - inherit url; - sha256 = nvidiaHash; - } else - builtins.fetchurl url; - useGLVND = true; - }); - }; - }; - - nixpkgs = pkgs { overlays = [overlay]; config = {allowUnfree = true;};}; + nixpkgs = pkgs {config = {allowUnfree = true;};}; writeExecutable = { name, text } : nixpkgs.writeTextFile { inherit name text; @@ -81,7 +62,18 @@ let in with nixpkgs; rec { - nvidia = linuxPackages.nvidia_x11; + nvidia = (linuxPackages.nvidia_x11.override { + }).overrideAttrs(oldAttrs: rec { + name = "nvidia-${_nvidiaVersion}"; + src = let url ="http://download.nvidia.com/XFree86/Linux-x86_64/${_nvidiaVersion}/NVIDIA-Linux-x86_64-${_nvidiaVersion}.run"; + in if nvidiaHash != null + then fetchurl { + inherit url; + sha256 = nvidiaHash; + } else + builtins.fetchurl url; + useGLVND = true; + }); nvidiaLibsOnly = nvidia.override { libsOnly = true; @@ -93,7 +85,7 @@ rec { text = '' #!/usr/bin/env sh export LD_LIBRARY_PATH=${lib.makeLibraryPath [nvidia]}:$LD_LIBRARY_PATH - ${bumblebee}/bin/optirun --ldpath ${lib.makeLibraryPath ([libglvnd nvidia] ++ lib.optionals enable32bits [nvidia.lib32 pkgsi686Linux.libglvnd])} "$@" + ${bumblebee.override {nvidia_x11 = nvidia; nvidia_x11_i686 = nvidia.lib32;}}/bin/optirun --ldpath ${lib.makeLibraryPath ([libglvnd nvidia] ++ lib.optionals enable32bits [nvidia.lib32 pkgsi686Linux.libglvnd])} "$@" ''; });