summaryrefslogtreecommitdiff
path: root/modules/nixos/features/nvk
diff options
context:
space:
mode:
Diffstat (limited to 'modules/nixos/features/nvk')
-rw-r--r--modules/nixos/features/nvk/default.nix27
-rw-r--r--modules/nixos/features/nvk/disk_cache-include-dri-driver-path-in-cache-key.patch67
-rw-r--r--modules/nixos/features/nvk/mesa.nix123
-rw-r--r--modules/nixos/features/nvk/opencl.patch67
4 files changed, 39 insertions, 245 deletions
diff --git a/modules/nixos/features/nvk/default.nix b/modules/nixos/features/nvk/default.nix
index 9e641ec..977dd3b 100644
--- a/modules/nixos/features/nvk/default.nix
+++ b/modules/nixos/features/nvk/default.nix
@@ -11,6 +11,17 @@ in {
options.features.nvk.enable = lib.mkEnableOption "nvk";
config = lib.mkIf cfg.enable {
+ # make sure we're loading new gsp firmware
+ boot.kernelParams = [
+ "nouveau.config=NvGspRm=1"
+ "nouveau.debug=info,VBIOS=info,gsp=debug"
+ ];
+
+ environment.sessionVariables = {
+ # (fake) advertise vk 1.3
+ MESA_VK_VERSION_OVERRIDE = "1.3";
+ };
+
hardware.opengl = {
package = mesa.drivers;
package32 = mesa32.drivers;
@@ -18,20 +29,12 @@ in {
system.replaceRuntimeDependencies = [
{
- original = pkgs.mesa;
- replacement = mesa;
- }
- {
- original = pkgs.mesa.drivers;
- replacement = mesa.drivers;
- }
- {
- original = pkgs.pkgsi686Linux.mesa;
- replacement = mesa32;
+ original = pkgs.mesa.out;
+ replacement = mesa.out;
}
{
- original = pkgs.pkgsi686Linux.mesa.drivers;
- replacement = mesa32.drivers;
+ original = pkgs.pkgsi686Linux.mesa.out;
+ replacement = mesa32.out;
}
];
};
diff --git a/modules/nixos/features/nvk/disk_cache-include-dri-driver-path-in-cache-key.patch b/modules/nixos/features/nvk/disk_cache-include-dri-driver-path-in-cache-key.patch
deleted file mode 100644
index bd19a9a..0000000
--- a/modules/nixos/features/nvk/disk_cache-include-dri-driver-path-in-cache-key.patch
+++ /dev/null
@@ -1,67 +0,0 @@
-Author: David McFarland <[email protected]>
-Date: Mon Aug 6 15:52:11 2018 -0300
-
- [PATCH] disk_cache: include dri driver path in cache key
-
- This fixes invalid cache hits on NixOS where all shared library
- timestamps in /nix/store are zero.
-
-diff --git a/meson_options.txt b/meson_options.txt
-index 9639c516d49..c0bb86908ae 100644
---- a/meson_options.txt
-+++ b/meson_options.txt
-@@ -513,6 +513,13 @@ option(
- description : 'Enable direct rendering in GLX and EGL for DRI',
- )
-
-+option(
-+ 'disk-cache-key',
-+ type : 'string',
-+ value : '',
-+ description : 'Mesa cache key.'
-+)
-+
- option('egl-lib-suffix',
- type : 'string',
- value : '',
-diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
-index 8298f9d7b32..e622133f566 100644
---- a/src/util/disk_cache.c
-+++ b/src/util/disk_cache.c
-@@ -226,8 +226,10 @@ disk_cache_type_create(const char *gpu_name,
-
- /* Create driver id keys */
- size_t id_size = strlen(driver_id) + 1;
-+ size_t key_size = strlen(DISK_CACHE_KEY) + 1;
- size_t gpu_name_size = strlen(gpu_name) + 1;
- cache->driver_keys_blob_size += id_size;
-+ cache->driver_keys_blob_size += key_size;
- cache->driver_keys_blob_size += gpu_name_size;
-
- /* We sometimes store entire structs that contains a pointers in the cache,
-@@ -248,6 +250,7 @@ disk_cache_type_create(const char *gpu_name,
- uint8_t *drv_key_blob = cache->driver_keys_blob;
- DRV_KEY_CPY(drv_key_blob, &cache_version, cv_size)
- DRV_KEY_CPY(drv_key_blob, driver_id, id_size)
-+ DRV_KEY_CPY(drv_key_blob, DISK_CACHE_KEY, key_size)
- DRV_KEY_CPY(drv_key_blob, gpu_name, gpu_name_size)
- DRV_KEY_CPY(drv_key_blob, &ptr_size, ptr_size_size)
- DRV_KEY_CPY(drv_key_blob, &driver_flags, driver_flags_size)
-diff --git a/src/util/meson.build b/src/util/meson.build
-index c0c1b9d1fa1..442163c5eac 100644
---- a/src/util/meson.build
-+++ b/src/util/meson.build
-@@ -268,7 +268,12 @@ _libmesa_util = static_library(
- include_directories : [inc_util, include_directories('format')],
- dependencies : deps_for_libmesa_util,
- link_with: [libmesa_util_sse41],
-- c_args : [c_msvc_compat_args],
-+ c_args : [
-+ c_msvc_compat_args,
-+ '-DDISK_CACHE_KEY="@0@"'.format(
-+ get_option('disk-cache-key')
-+ ),
-+ ],
- gnu_symbol_visibility : 'hidden',
- build_by_default : false
- )
diff --git a/modules/nixos/features/nvk/mesa.nix b/modules/nixos/features/nvk/mesa.nix
index 9f10ce5..4b622c6 100644
--- a/modules/nixos/features/nvk/mesa.nix
+++ b/modules/nixos/features/nvk/mesa.nix
@@ -29,63 +29,6 @@ SOFTWARE.
pkgs,
...
}: let
- directx-headers = pkgs.directx-headers.overrideAttrs (new: _: {
- version = "1.611.0";
- src = pkgs.fetchFromGitHub {
- owner = "microsoft";
- repo = "DirectX-Headers";
- rev = "v${new.version}";
- hash = "sha256-HG2Zj8hvsgv8oeSDp1eK+1A5bvFL6oQIh5mMFWOFsvk=";
- };
- });
-
- libdrm = pkgs.libdrm.overrideAttrs (new: _: {
- version = "2.4.119";
-
- src = pkgs.fetchFromGitLab {
- domain = "gitlab.freedesktop.org";
- owner = "mesa";
- repo = "drm";
- rev = "libdrm-${new.version}";
- hash = "sha256-bIP3yK3VGZ/WGaUclJpb4nH8y6+zHQlQma+C9Or+Vg8=";
- };
- });
-
- meson = pkgs.meson.overrideAttrs (new: old: let
- badPatches = [
- "https://github.com/mesonbuild/meson/commit/d5252c5d4cf1c1931fef0c1c98dd66c000891d21.patch"
- ];
- in {
- version = "1.3.1";
-
- src = pkgs.fetchFromGitHub {
- owner = "mesonbuild";
- repo = "meson";
- rev = "refs/tags/${new.version}";
- hash = "sha256-KNNtHi3jx0MRiOgmluA4ucZJWB2WeIYdApfHuspbCqg=";
- };
-
- patches = lib.filter (p: !(lib.attrsets.isDerivation p) || !(lib.elem (p.url or null) badPatches)) old.patches;
- });
-
- revert26943 = pkgs.fetchpatch {
- url = "https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26943.diff";
- hash = "sha256-KwIG68mf+aArMlvWBtGJdOFdCn5zTZJG6geWXE7bK44=";
- revert = true;
- };
-
- revert24386_1 = pkgs.fetchpatch {
- url = "https://gitlab.freedesktop.org/mesa/mesa/-/commit//299f9497758ca5d7278e5aafd210aa91d20dfb4d.patch";
- hash = "sha256-ugrkIqJ/Tndimn6YIQSanLVvQ5qZfp2m6GGStHLt8xg=";
- revert = true;
- };
-
- revert24386_2 = pkgs.fetchpatch {
- url = "https://gitlab.freedesktop.org/mesa/mesa/-/commit/1e5bc00715ad8acf3dc323278d0d6a24986bb4ae.patch";
- hash = "sha256-i0+sBeU/c8Eo8WA34aJfMLJOxhd7146+t7H6llGwS+g=";
- revert = true;
- };
-
cargoDeps = {
proc-macro2 = {
version = "1.0.70";
@@ -104,35 +47,8 @@ SOFTWARE.
hash = "sha256-M1S5rD+uH/Z1XLbbU2g622YWNPZ1V5Qt6k+s6+wP7ks=";
};
};
-
- cargoFetch = crate:
- pkgs.fetchurl {
- url = "https://crates.io/api/v1/crates/${crate}/${cargoDeps.${crate}.version}/download";
- inherit (cargoDeps.${crate}) hash;
- };
-
- cargoSubproject = crate: ''
- ln -s ${cargoFetch crate} subprojects/packagecache/${crate}-${cargoDeps.${crate}.version}.tar.gz
- '';
-
- subprojects = lib.concatMapStringsSep "\n" cargoSubproject (lib.attrNames cargoDeps);
-
- replacePatches = patch:
- {
- "opencl.patch" = ./opencl.patch;
- "disk_cache-include-dri-driver-path-in-cache-key.patch" = ./disk_cache-include-dri-driver-path-in-cache-key.patch;
- }
- .${baseNameOf patch}
- or patch;
-
mesa =
(pkgs.mesa.override {
- inherit
- directx-headers
- libdrm
- meson
- ;
-
# we use the new flag for this
enablePatentEncumberedCodecs = false;
@@ -162,33 +78,42 @@ SOFTWARE.
]
else ["auto"];
})
- .overrideAttrs (_new: old: let
- # for some reason this version string won't work with
- # system.replaceRuntimeDependencies /shrug
- actualVersion = "24.0.0-rc1";
- in {
+ .overrideAttrs (new: old: {
version = "24.0.0";
src = pkgs.fetchurl {
urls = [
- "https://archive.mesa3d.org/mesa-${actualVersion}.tar.xz"
- "https://mesa.freedesktop.org/archive/mesa-${actualVersion}.tar.xz"
+ "https://archive.mesa3d.org/mesa-${new.version}.tar.xz"
+ "https://mesa.freedesktop.org/archive/mesa-${new.version}.tar.xz"
];
- hash = "sha256-hvsZnrrNlztnUjgdbTnyOLg+V749aVeMOCQ1OkCujO4=";
+ hash = "sha256-YoWlu7v0P92vtLO3JrFIpKIiRg6JK9G2mq/004DJg1U=";
};
nativeBuildInputs = old.nativeBuildInputs ++ [pkgs.rustc pkgs.rust-bindgen];
- patches =
- map replacePatches old.patches
- ++ lib.optionals (!pkgs.stdenv.hostPlatform.is32bit) [
- revert26943
- revert24386_1
- revert24386_2
+ patches = let
+ badPatches = [
+ "0001-dri-added-build-dependencies-for-systems-using-non-s.patch"
+ "0002-util-Update-util-libdrm.h-stubs-to-allow-loader.c-to.patch"
+ "0003-glx-fix-automatic-zink-fallback-loading-between-hw-a.patch"
];
+ in
+ lib.filter (patch: !(lib.elem (baseNameOf patch) badPatches)) old.patches;
+
+ postPatch = let
+ cargoFetch = crate:
+ pkgs.fetchurl {
+ url = "https://crates.io/api/v1/crates/${crate}/${cargoDeps.${crate}.version}/download";
+ inherit (cargoDeps.${crate}) hash;
+ };
+
+ cargoSubproject = crate: ''
+ ln -s ${cargoFetch crate} subprojects/packagecache/${crate}-${cargoDeps.${crate}.version}.tar.gz
+ '';
- postPatch =
+ subprojects = lib.concatMapStringsSep "\n" cargoSubproject (lib.attrNames cargoDeps);
+ in
old.postPatch
+ ''
mkdir subprojects/packagecache
diff --git a/modules/nixos/features/nvk/opencl.patch b/modules/nixos/features/nvk/opencl.patch
deleted file mode 100644
index c820700..0000000
--- a/modules/nixos/features/nvk/opencl.patch
+++ /dev/null
@@ -1,67 +0,0 @@
-diff --git a/meson.build b/meson.build
-index e4570c5..80203cc 100644
---- a/meson.build
-+++ b/meson.build
-@@ -1797,7 +1797,7 @@ endif
-
- dep_clang = null_dep
- if with_clc
-- llvm_libdir = dep_llvm.get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool: 'libdir')
-+ llvm_libdir = get_option('clang-libdir')
-
- dep_clang = cpp.find_library('clang-cpp', dirs : llvm_libdir, required : false)
-
-diff --git a/meson_options.txt b/meson_options.txt
-index 3d8425f..fa7c913 100644
---- a/meson_options.txt
-+++ b/meson_options.txt
-@@ -1,6 +1,13 @@
- # Copyright © 2017-2019 Intel Corporation
- # SPDX-License-Identifier: MIT
-
-+option(
-+ 'clang-libdir',
-+ type : 'string',
-+ value : '',
-+ description : 'Locations to search for clang libraries.'
-+)
-+
- option(
- 'platforms',
- type : 'array',
-diff --git a/src/gallium/targets/opencl/meson.build b/src/gallium/targets/opencl/meson.build
-index 7c14135..74dc685 100644
---- a/src/gallium/targets/opencl/meson.build
-+++ b/src/gallium/targets/opencl/meson.build
-@@ -39,7 +39,8 @@ if dep_llvm.version().version_compare('>=10.0.0')
- polly_isl_dep = cpp.find_library('PollyISL', dirs : llvm_libdir, required : false)
- endif
-
--dep_clang = cpp.find_library('clang-cpp', dirs : llvm_libdir, required : false)
-+clang_libdir = get_option('clang-libdir')
-+dep_clang = cpp.find_library('clang-cpp', dirs : clang_libdir, required : false)
-
- # meson will return clang-cpp from system dirs if it's not found in llvm_libdir
- linker_rpath_arg = '-Wl,--rpath=@0@'.format(llvm_libdir)
-@@ -123,7 +124,7 @@ if with_opencl_icd
- configuration : _config,
- input : 'mesa.icd.in',
- output : 'mesa.icd',
-- install : true,
-+ install : false,
- install_tag : 'runtime',
- install_dir : join_paths(get_option('sysconfdir'), 'OpenCL', 'vendors'),
- )
-diff --git a/src/gallium/targets/rusticl/meson.build b/src/gallium/targets/rusticl/meson.build
-index 8205ed7..a11b700 100644
---- a/src/gallium/targets/rusticl/meson.build
-+++ b/src/gallium/targets/rusticl/meson.build
-@@ -75,7 +75,7 @@ configure_file(
- configuration : _config,
- input : 'rusticl.icd.in',
- output : 'rusticl.icd',
-- install : true,
-+ install : false,
- install_tag : 'runtime',
- install_dir : join_paths(get_option('sysconfdir'), 'OpenCL', 'vendors'),
- )