From 08e318096831eb3aae369910ba75e27f59367e2f Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sun, 15 Sep 2024 12:11:39 +0100 Subject: gentoo auto-resync : 15:09:2024 - 12:11:38 --- x11-drivers/Manifest.gz | Bin 4705 -> 4711 bytes x11-drivers/nvidia-drivers/Manifest | 19 +- x11-drivers/nvidia-drivers/files/nvidia-470.conf | 8 +- x11-drivers/nvidia-drivers/files/nvidia-545.conf | 8 +- x11-drivers/nvidia-drivers/files/nvidia-555.conf | 8 +- .../nvidia-drivers/files/system-sleep.elogind | 7 + .../nvidia-drivers-470.256.02-r1.ebuild | 494 ++++++++++++++++++ .../nvidia-drivers-470.256.02.ebuild | 438 ---------------- .../nvidia-drivers-525.147.05-r1.ebuild | 577 +++++++++++++++++++++ .../nvidia-drivers-525.147.05.ebuild | 521 ------------------- .../nvidia-drivers-535.183.01-r1.ebuild | 577 +++++++++++++++++++++ .../nvidia-drivers-535.183.01.ebuild | 521 ------------------- .../nvidia-drivers-550.107.02-r1.ebuild | 556 ++++++++++++++++++++ .../nvidia-drivers-550.107.02.ebuild | 500 ------------------ .../nvidia-drivers-550.40.71-r1.ebuild | 558 ++++++++++++++++++++ .../nvidia-drivers/nvidia-drivers-550.40.71.ebuild | 502 ------------------ .../nvidia-drivers-560.35.03-r1.ebuild | 571 ++++++++++++++++++++ .../nvidia-drivers/nvidia-drivers-560.35.03.ebuild | 515 ------------------ 18 files changed, 3365 insertions(+), 3015 deletions(-) create mode 100644 x11-drivers/nvidia-drivers/files/system-sleep.elogind create mode 100644 x11-drivers/nvidia-drivers/nvidia-drivers-470.256.02-r1.ebuild delete mode 100644 x11-drivers/nvidia-drivers/nvidia-drivers-470.256.02.ebuild create mode 100644 x11-drivers/nvidia-drivers/nvidia-drivers-525.147.05-r1.ebuild delete mode 100644 x11-drivers/nvidia-drivers/nvidia-drivers-525.147.05.ebuild create mode 100644 x11-drivers/nvidia-drivers/nvidia-drivers-535.183.01-r1.ebuild delete mode 100644 x11-drivers/nvidia-drivers/nvidia-drivers-535.183.01.ebuild create mode 100644 x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02-r1.ebuild delete mode 100644 x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02.ebuild create mode 100644 x11-drivers/nvidia-drivers/nvidia-drivers-550.40.71-r1.ebuild delete mode 100644 x11-drivers/nvidia-drivers/nvidia-drivers-550.40.71.ebuild create mode 100644 x11-drivers/nvidia-drivers/nvidia-drivers-560.35.03-r1.ebuild delete mode 100644 x11-drivers/nvidia-drivers/nvidia-drivers-560.35.03.ebuild (limited to 'x11-drivers') diff --git a/x11-drivers/Manifest.gz b/x11-drivers/Manifest.gz index a17d9abed47f..516059d4309e 100644 Binary files a/x11-drivers/Manifest.gz and b/x11-drivers/Manifest.gz differ diff --git a/x11-drivers/nvidia-drivers/Manifest b/x11-drivers/nvidia-drivers/Manifest index af8567d940c0..7e569a00d2a0 100644 --- a/x11-drivers/nvidia-drivers/Manifest +++ b/x11-drivers/nvidia-drivers/Manifest @@ -1,8 +1,8 @@ AUX 95-nvidia-settings-r1 54 BLAKE2B 598067babb48bd0f5680300cf3cbb37ac804edb3131c47510d3350511b918cd47fcf44f1ccd4746e4a41f2f8aa36511f20c2c6f313010e89a79b7869771b9ee6 SHA512 de9edf678c64ca3d10c912397800b2cb651ef9108b33ece97a4cc1e86dad0a9e81986cca6b96cfe80740d9cb433de7ef93f29be45178db714ee408c7f6570ac7 AUX nvidia-390.conf 797 BLAKE2B 7cb7dc58841d2e7cf28f677939031a20ff820e2d46f799177c6004d94e73c308d2a9ee81fca476ff7ab4846a275cce996f68a53a7a9f819c3d57b5dace1d40e2 SHA512 17cabfcaa4b7323c635d1491e46710624d13396c019591499993662a20df39c8e3fa843387594aeb66d70cf38ab9fde7bee85dd1ab37eaa637a315fd52328222 -AUX nvidia-470.conf 1219 BLAKE2B 334975e048d2cafbbf5fc9d0a74ce9cea4af82103be4d02539d91bb3da4fb39fbb24f64dd6240a526259306c5b971323c00104e2254893fd433f3ef56c9ba8f2 SHA512 6e218dd8da6cfd2d13a259a461348221b65d8475e018c0a6ef5856fd177748306569751545171237c84ccbe3ac526231184bcbe286507f18b32a3518c40bdcb7 -AUX nvidia-545.conf 1449 BLAKE2B 128abdb32edafac6e81bd056e3174daf21905ee553ff4f65e25af211f5610f92d02ff25e32060e6a7832e3b25902ab748a5491df560e84e44ab9db6c3c7edb72 SHA512 c01e2c19537d9fd6a766d459b0f0e8affefb881141f5d5a897d02860cd23e3365c76ae0f6fc89108d4c9263ebd672e34b6fb78b8e6efbc11cb81ba5bf631c46e -AUX nvidia-555.conf 1755 BLAKE2B 65c2c0daeac96d03550abf5d2ef99e785a06f3810a490f4d67c18f7c07b10e8482598feeffb9cb8ce7ce15f5ec6313ba784c4be23d747616634673fd89e0b9fd SHA512 8f1bc3189a8819a566cb57fa3e8f6a2eee124b3eefd7469f821cee7d4f424ed5dd96e8c112bbc1bf554ed8bfa7b33c3457710467459313b05d37141a7e6602ee +AUX nvidia-470.conf 1316 BLAKE2B b7ebe612ba932592b7b280042cd635486f0f2ce65a70d6213d796b46904b2151cdd6bd9ac531149ae1274207b5e18435d03fd44b5e8d54d659cd2e5e20356243 SHA512 c84ce3668ff80357c789de305ba40b31e55208204afd3a155f280aaa836b233d56e6543832e0d5735874a4e8ef0688c0e6ddd31b6d85dd2a19c454b592abab52 +AUX nvidia-545.conf 1546 BLAKE2B 29ec9b17749bfc23483726adbe69ea2ef7c0edd98276be3ac0af15039b97b9fa937b5bf1766ed7e04bd9182dd0739dfd06260e99c977c9106048e8530bb8bdbe SHA512 bf8a37e57caf762d316ba6ce4e75af65ca81065c9c4e2345809ca804991cb23a804e1524e9497be4be59cd8201d4108d4a1c015e21b32c74dc922cf2545ce1b5 +AUX nvidia-555.conf 1852 BLAKE2B 8a21c6cf9607575d4a9b6feef8b57718071505d65e5c78842322bdf5995f55a2d7f997535b4afa23b8db84116dd6c0d732a23c338cdd2b9605d296281db9c4d8 SHA512 8ed7c6775b6b22b28cd3c60c5964f9648887ebff8add09dd03ed02daa2495c5a0871ec31fc679a235e6713d25428dae866af2170b25fbb26bef4a51dd188c18a AUX nvidia-drivers-390.154-clang15-x86.patch 1085 BLAKE2B 5bb221407b280f2dde69ef2b37317606bec1c108dbc56653898cfa9318de6e47df21e5b38943212caf13bc6412f2427fad7c534491d868d03399091e2146daaa SHA512 1349c1c715b2f09e64a5e91412aceabc80041d070a6bbacfdf7038872f1f4a798bbc63277d47a25d1a5b28b573b3d5bd6295dadbbdbf245f5cfb0241879a3bc4 AUX nvidia-drivers-390.154-clang15.patch 2915 BLAKE2B e9799aee3c6b814ecdc40e83d2e495acad046f18c88fe8c1b5fead1c9cd0fab3d0a0a2924730dadec5eb8ea1e2d2132c495298d6ab108c015721bab911a4da79 SHA512 6e1c99ae8efb06aa4fc3accb4cee55f43a6498f94fca064fd4b9b007a3555913a5cef042d4e74b6f24a3eb6f14988f810d0c848d34ae81835fbae8ec32cf0cf0 AUX nvidia-drivers-470.141.03-clang15.patch 3757 BLAKE2B 9cec15b57c82c8e24f89a025a73bf78e3d7ea5df681cf803888ca4ad8b96976b433717d01c9fdad5036cb06376345bef64dd05287791ed0ce7dc2a06c8a79aab SHA512 10ed0fa6b1fdf24fbc18432a9b94b1c1b9d7d6003926272d3c924d72a298c1d3a8875b43a42472d701864fe9dda35d75f9cf7c51ca841d20b989ed46ed994311 @@ -21,6 +21,7 @@ AUX nvidia-settings-390.144-desktop.patch 433 BLAKE2B 5f2eacf1cb1d8ad1ba2cd7163f AUX nvidia-settings-390.144-no-gtk2.patch 367 BLAKE2B 59a60b103df6b187009417dca22caaf45292b94005d92df9e513804e5137959ffeda1d9abd5506cbb5c7be604023d2c59f0841190b03502542ad0c2d3f084a10 SHA512 421558442a2228f6ffdb82b2bd6862cbc286b8ba259c4970f54dcc445a988575864404f2c3933d2436d8d40de1bf0e34ee7ed855742c5d677094c260e32a1e66 AUX nvidia-settings-390.144-raw-ldflags.patch 468 BLAKE2B bf4c00a76351e6c3d1587b4f71be61fac8cc516fa22da0a47538fede92b619eb77b1cc09222cd403175a2015eb2ca745e8cdca90c9dca1b938ca13a2e59810ba SHA512 1fc568bfd1faba1f7af4f4b07715912b7f1d8103626ec0c9fcbb465ded606059ca264f386fe415105ab9f95c4ab173bf4b784ea7380bf17ab6979f56fbd01757 AUX nvidia-settings-530.30.02-desktop.patch 406 BLAKE2B 63f645d5c9f76349b405c61327bc4f6d44e0716b4ec4c2f1aa012505638be0a329bc9589812d1f164641e4725dd15ac652eed0992161e767325b1310d9cd0718 SHA512 ff0fed69d7d36b2f67f9382055490a031ef8e834119bb18b0f71d1265afe92fad44cb11d6fabc5e3750a434c51e4660cfaa3347d062036d975fd341967187494 +AUX system-sleep.elogind 177 BLAKE2B 207d06f14e507dbaad58b94d7500ef415bf2ed842124edb149b42bacff7192d575aabb4b4576d2e84575a3039c9864b427625d748dcd051764f00ab8050d6520 SHA512 e727e5957ef719ca3f3a72f260f5bbcd2f95c5c8e1a3ae158afc95e6c043fa7a597ce33dde03cc0d55d6f9e9254c6d0798b51419d8df22137795a4f3d9b28cda DIST NVIDIA-Linux-aarch64-525.147.05.run 262738232 BLAKE2B 742feded05f659fa9965b2eebcc6a269b0355d08b6f2a686dad47c1acf2c20a359f9a9c33184ab2d51044b8823535bd7606180e31d348f362a016fad74cf476b SHA512 d1d9e49e16ee6cc69340a3458566f89fee7b63effdd8cae3e55e40cdfbd35d1e87b958769fd3b2ce5ab29596d88c3ac68189232d7a1dad8c16773faedcf5b568 DIST NVIDIA-Linux-aarch64-535.183.01.run 269908911 BLAKE2B 93665bfd2c66391b232c0db7faa2b7929048f4eb0ac660726bc45fcee21bcf9b255da5f4fbdc14c281092f31e7603b5b112fc42b3c7d6e4769cdbedf8d0f16b0 SHA512 d2ac1be8c19b359023c31941374911f3adfe1be34aa2821ef582df4c854ac4eefbbcb10aa22583ac8c9d5caf9326bda12ed1ce6343d67479ed37a4887bd17b5e DIST NVIDIA-Linux-aarch64-550.107.02.run 236334785 BLAKE2B 6ed0cfddbe82566e6c9056d10454f6cb289a60e928b05cb64b65ae7ee341888f942e888c556d3e528b3d1228cc1ee14e938fa25c84750f85ab95239fb684f2ff SHA512 a62d5d13089dbc98c022cb3bdf00999d79da7ae370c6e84405ca9e32034f19fcea65ac74845323223f1a8b8f1443e506c60704ba56e6f5add04b2a007d2d443c @@ -69,10 +70,10 @@ DIST nvidia-xconfig-550.107.02.tar.bz2 111170 BLAKE2B dbf2b0b7f7b71f17ce5a0b6ae1 DIST nvidia-xconfig-560.35.03.tar.bz2 111203 BLAKE2B 347d4f80b9a16da54fbd7116d0ceafbb15b3b6e78aa1640b8505674b9ffc32056197925b67506d2cbb5d130054944c13246a592d9021f0bb2410ee6e8216df4e SHA512 1a68729b8aa1d3518b43392d4f9af163e2a084c635c08343b25ce761f835801aad203778fd03564ba050ad949a9d2df84fba4c8a48bb1a7afea5e72eb364eb58 DIST open-gpu-kernel-modules-550.40.71.tar.gz 13811934 BLAKE2B 479c08b73afc91a2f09d7a28bd06795db4dd8f253b2787e41e3c5c8bcde5d606f9715f48d8d3f61ed0cc637445db83dbb6e4b09b0b50cbabe358ea13f8ff683e SHA512 81cb651a9a56aebf806b8442a9de70147beec415f6cb26f41e3d60ef31c024dc84f6c9754ccaff6d0112cc0d97a564403f4d64192c57d38c4969a9d026fc1f61 EBUILD nvidia-drivers-390.157.ebuild 14786 BLAKE2B 0aa98cd61987bbcd67e2c117e0acee43d28b54787f1d4dbafa3e871902dc6d066873b8b6cfb57a83b1a17e49b8701925924e4b5f2d2abb22f12494c852a65c8a SHA512 2e85077a050a546a5b6a8f4ec38c27d7269a5993ff04b6f49e6b7a96e2e27ecd84e61730e286470af63e87a314258eb5e6a64a3c93aa7347d27541d9ea30ade7 -EBUILD nvidia-drivers-470.256.02.ebuild 14335 BLAKE2B 4ccf76ce3ee46fec93e8bad162c41b3e00dbdc61eca1225993ec8a68ab3d3c078012ef152b75e5fd2cff6e33f710db588f6bc0b56ddb2b6970a552039bb655fe SHA512 921307b5d9013bfdb04ff23f03884ac8da32d880327c2d52eb85894f216af0359e5319923220a08012b15a572805d870660d5c332a09fb8b7faeb70038f908a9 -EBUILD nvidia-drivers-525.147.05.ebuild 17649 BLAKE2B c587c8ec8f356844b95c4f5dc77cc4c4c684f79c8b67ad745e472c4760925c1e4b736dfaa111fa462ccfe6ebb7e20792937a374aaa347e697180f0087a341bb8 SHA512 4dfd604a3692d4330999617bb96f02dfec0ced6a07dd393113a3ee9dee8c3aa1b9792c3bf17af1d5da6181cbf3c79873ac2cd78ce7b13fb00041696d3f0a6ef1 -EBUILD nvidia-drivers-535.183.01.ebuild 17499 BLAKE2B e06cd90559e3af3ec6f6f3890426b46d10c61a761a4e7e01c8e7b4e86898c43eed802aa06f185b6b4650ad1572c866e55267ce4b0d8b0c626e364976119c2ea6 SHA512 f9d0dbc07c068e4e28de61f81d878b87ef9fe63e31f02f0d3f7587a5fef7c2fa6b237b5cde736f78623db9073244240c2818424633bf8e3fff6d592c97007efa -EBUILD nvidia-drivers-550.107.02.ebuild 16589 BLAKE2B 61e4bb8a4f0f397d2a5a72872b0a85b8e6dea7e3e80e4a66a7f307cf61a9e41be995e74fba3209b36feb84b9d192953f225a5f96b66eeef136fbcd72850e2e05 SHA512 0495d80551cd07d2f8dfe00bc34428ae891d2eca421d50ae86645e4fc32cf3853bf4e82677576e77e00d44f3221c86ab71666c555178bdea6aae9b41bd1639c2 -EBUILD nvidia-drivers-550.40.71.ebuild 16642 BLAKE2B 07a8bfd5f412c20a3dc9e42668bb285bd43605994cd6d27a5fd4d1a23547535929096a791988ad2cd9d1853d1675076925e3d73078994ddff26f9414dd6157f7 SHA512 1f1109b3c68ee0594ba297d55cac251062e04c4f75bdfc2ac3cb4fa4c0251243ba22332af147ffc443dc5bd42fbb51554ad7f3ed7f86895efbaaa23239defb6b -EBUILD nvidia-drivers-560.35.03.ebuild 17350 BLAKE2B c2e380495b2bdfc7c998a4de6584b27235c0688d1a63b2d755481219d9418f95e421e5ddd227afa9d9ea7707e3eb5d5c367d0f8aee27e97924f9a3cda7fbca47 SHA512 430b76702ba826b65bacb4fe883681736b45971ffa8446bab8497909541fc3ac810a757a65cb160a0c986003693dcc43e4745c7d57d0e288eb630ccf5a033f24 +EBUILD nvidia-drivers-470.256.02-r1.ebuild 17333 BLAKE2B 35823d70cff4f6cc62ee0cc748725ef3d6049b2041bd9d25acdd21eee589839981469d1a5a80bed4c3cd4265b3f4a83160ffb6d5054d514a17973f0471c96ffd SHA512 4076abad69b099fa266917db15877c27e0d849b040ff2c486bc1c61f9d5c654a3ca9957e29ff9062a638731ff4ce74e8c93c87b360b401dfcfe92d032245930d +EBUILD nvidia-drivers-525.147.05-r1.ebuild 20647 BLAKE2B 4b2f98045d25202dd2b07431b6958977a468f130ee05bee465748f875233f5973f7084e22cd6d8170bff86987c2a95b4d9605fceb85cf3c53d0143d46bd7ede2 SHA512 92f57b234f4ed899f2c2c68acb4150e96279821775b097ca67ddacc1761fbf53164b07c2aa6f3d3feceb58700780ac93359f5e2babc6a41fd7c6b2490dc12d7b +EBUILD nvidia-drivers-535.183.01-r1.ebuild 20497 BLAKE2B 8d79e450006c54a1bd9acd50ef8dec314b5a658781e6eac388d12ef55df07e027cf5b6796812946ac8f1f26b95ceeb32ba3b11904ce9ea8c6c9a7e879ada4351 SHA512 2cbe6fcf01255afda9f0d6da3a3853f0e49712f4a880943fc3e19169c201b8d78e6c3bba45538767fd80395b58033ff380ecefd33b91aa96cec458b1837702b6 +EBUILD nvidia-drivers-550.107.02-r1.ebuild 19587 BLAKE2B 55c67efa4ac7c2206b89e619940ecb3641f528a9da2a64734bc412bcb907d6cf4868bcefe8f540916d439d2b37ee06381a7de7b604d03e07ffe35b18da529f0f SHA512 54fca7be7815c83c22f1798b86d9ec232605fc711dbd3750c7a7aec6538eee4aa64194755270ceda838a27c8ce296999f196356ed33268ec2c0dc50c1f6bd14c +EBUILD nvidia-drivers-550.40.71-r1.ebuild 19639 BLAKE2B fba51679ad674a628eb5b91b2e731c44d0d965697996ad12edc82e0bb4c7eb28d1b030c1e187e9b797976dd6072cab78e2a4fc1ec0f67c8a702c1fba14c652f9 SHA512 74f75d15dbd13a2512376f33fc77b7a4df71534d29bf137fb76a21c082cb3ef17674aae361d8d1729280d724a4172dcf0902f0e75fa39f2d5c7502aff331e85b +EBUILD nvidia-drivers-560.35.03-r1.ebuild 20347 BLAKE2B 9e9f2014b956e258efeb827eab041fc7ddf380a2f1533ec43ec155f0f7316557aee62a494c87759d1858071d2dd0a1c8d1faa17ee869c667c01728f878a31e07 SHA512 550cb00a9dffc58d2c3558742875f4b6e795914a749b7f950cbb04ea683aae81f9a28afc345f398d1b2aedd8ce3943607e8f3ab37f3f46e6361ad2f0afbe2cf3 MISC metadata.xml 1457 BLAKE2B 10fccbffe28ab58e012aae439123f947acea95eb3bdc4d0e2eb1ec14a92ad24fc2e3e0c248dcce87d9fdec54a65b8e040b2ed048d9ef11054f762f295c24ce39 SHA512 8469884c614a0275f438a0f8d583f2823d1159905ee27402e859c824cc458ac31daf69f2b7960533daaf86e1ca203be745c03e4e67ff12e9bbb2c08b91c667a0 diff --git a/x11-drivers/nvidia-drivers/files/nvidia-470.conf b/x11-drivers/nvidia-drivers/files/nvidia-470.conf index 2b87b67602e0..4dd0badfb271 100644 --- a/x11-drivers/nvidia-drivers/files/nvidia-470.conf +++ b/x11-drivers/nvidia-drivers/files/nvidia-470.conf @@ -9,10 +9,12 @@ blacklist nouveau # Enabling may possibly cause issues with SLI and Reverse PRIME. #options nvidia-drm modeset=1 -# Suspend options. Allocations=0 recommended over =1 unless enable nvidia's -# systemd sleep services (nvidia-hibernate, nvidia-resume, nvidia-suspend). +# Suspend options. Note that Allocations=1 requires suspend hooks currently +# only used when either systemd or elogind is used to suspend. If using +# neither or have issues, try Allocations=0 (revert if it does not help +# as =0 is not recommended). options nvidia \ - NVreg_PreserveVideoMemoryAllocations=0 \ + NVreg_PreserveVideoMemoryAllocations=1 \ NVreg_TemporaryFilePath=/var/tmp # !!! Security Warning !!! diff --git a/x11-drivers/nvidia-drivers/files/nvidia-545.conf b/x11-drivers/nvidia-drivers/files/nvidia-545.conf index d5be9b654091..7c399e0c9490 100644 --- a/x11-drivers/nvidia-drivers/files/nvidia-545.conf +++ b/x11-drivers/nvidia-drivers/files/nvidia-545.conf @@ -14,10 +14,12 @@ blacklist nouveau # experimental, "may" cause issues X mode switching, sleep, or more). #options nvidia-drm fbdev=1 -# Suspend options. Allocations=0 recommended over =1 unless enable nvidia's -# systemd sleep services (nvidia-hibernate, nvidia-resume, nvidia-suspend). +# Suspend options. Note that Allocations=1 requires suspend hooks currently +# only used when either systemd or elogind is used to suspend. If using +# neither or have issues, try Allocations=0 (revert if it does not help +# as =0 is not recommended). options nvidia \ - NVreg_PreserveVideoMemoryAllocations=0 \ + NVreg_PreserveVideoMemoryAllocations=1 \ NVreg_TemporaryFilePath=/var/tmp # !!! Security Warning !!! diff --git a/x11-drivers/nvidia-drivers/files/nvidia-555.conf b/x11-drivers/nvidia-drivers/files/nvidia-555.conf index 98bd87c43080..7f83ba752025 100644 --- a/x11-drivers/nvidia-drivers/files/nvidia-555.conf +++ b/x11-drivers/nvidia-drivers/files/nvidia-555.conf @@ -20,10 +20,12 @@ blacklist nouveau # Cannot be disabled if using USE="kernel-open". #options nvidia NVreg_EnableGpuFirmware=0 -# Suspend options. Allocations=0 recommended over =1 unless enable nvidia's -# systemd sleep services (nvidia-hibernate, nvidia-resume, nvidia-suspend). +# Suspend options. Note that Allocations=1 requires suspend hooks currently +# only used when either systemd or elogind is used to suspend. If using +# neither or have issues, try Allocations=0 (revert if it does not help +# as =0 is not recommended). options nvidia \ - NVreg_PreserveVideoMemoryAllocations=0 \ + NVreg_PreserveVideoMemoryAllocations=1 \ NVreg_TemporaryFilePath=/var/tmp # !!! Security Warning !!! diff --git a/x11-drivers/nvidia-drivers/files/system-sleep.elogind b/x11-drivers/nvidia-drivers/files/system-sleep.elogind new file mode 100644 index 000000000000..d36e2697b86c --- /dev/null +++ b/x11-drivers/nvidia-drivers/files/system-sleep.elogind @@ -0,0 +1,7 @@ +#!/bin/sh +case ${1-} in + pre) nvidia-sleep.sh suspend;; + # run in background given resume is flaky if elogind did not finish + post) nvidia-sleep.sh resume &;; + *) exit 1;; +esac diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-470.256.02-r1.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-470.256.02-r1.ebuild new file mode 100644 index 000000000000..5223357f1af2 --- /dev/null +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-470.256.02-r1.ebuild @@ -0,0 +1,494 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +MODULES_OPTIONAL_IUSE=+modules +inherit desktop flag-o-matic linux-mod-r1 multilib readme.gentoo-r1 +inherit systemd toolchain-funcs unpacker user-info + +MODULES_KERNEL_MAX=6.9 +NV_URI="https://download.nvidia.com/XFree86/" + +DESCRIPTION="NVIDIA Accelerated Graphics Driver" +HOMEPAGE="https://www.nvidia.com/download/index.aspx" +SRC_URI=" + ${NV_URI}Linux-x86_64/${PV}/NVIDIA-Linux-x86_64-${PV}.run + $(printf "${NV_URI}%s/%s-${PV}.tar.bz2 " \ + nvidia-{installer,modprobe,persistenced,settings,xconfig}{,}) +" +# nvidia-installer is unused but here for GPL-2's "distribute sources" +S=${WORKDIR} + +LICENSE="NVIDIA-r2 BSD BSD-2 GPL-2 MIT ZLIB curl openssl" +SLOT="0/${PV%%.*}" +KEYWORDS="-* amd64" +IUSE="+X abi_x86_32 abi_x86_64 persistenced +static-libs +tools" + +COMMON_DEPEND=" + acct-group/video + persistenced? ( + acct-user/nvpd + net-libs/libtirpc:= + ) + tools? ( + >=app-accessibility/at-spi2-core-2.46:2 + dev-libs/glib:2 + dev-libs/jansson:= + media-libs/harfbuzz:= + x11-libs/cairo + x11-libs/gdk-pixbuf:2 + x11-libs/gtk+:3[X] + x11-libs/libX11 + x11-libs/libXext + x11-libs/libXxf86vm + x11-libs/pango + ) +" +RDEPEND=" + ${COMMON_DEPEND} + sys-libs/glibc + X? ( + media-libs/libglvnd[X,abi_x86_32(-)?] + x11-libs/libX11[abi_x86_32(-)?] + x11-libs/libXext[abi_x86_32(-)?] + ) +" +DEPEND=" + ${COMMON_DEPEND} + static-libs? ( + x11-base/xorg-proto + x11-libs/libX11 + x11-libs/libXext + ) + tools? ( + media-libs/libglvnd + sys-apps/dbus + x11-base/xorg-proto + x11-libs/libXrandr + x11-libs/libXv + x11-libs/libvdpau + ) +" +BDEPEND=" + sys-devel/m4 + virtual/pkgconfig +" + +QA_PREBUILT="lib/firmware/* opt/bin/* usr/lib*" + +PATCHES=( + "${FILESDIR}"/nvidia-drivers-470.141.03-clang15.patch + "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch + "${FILESDIR}"/nvidia-settings-390.144-desktop.patch + "${FILESDIR}"/nvidia-settings-390.144-no-gtk2.patch + "${FILESDIR}"/nvidia-settings-390.144-raw-ldflags.patch +) + +pkg_setup() { + use modules && [[ ${MERGE_TYPE} != binary ]] || return + + local CONFIG_CHECK=" + PROC_FS + ~DRM_KMS_HELPER + ~SYSVIPC + ~!AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT + ~!LOCKDEP + ~!SLUB_DEBUG_ON + ~!X86_KERNEL_IBT + !DEBUG_MUTEXES + " + + local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but needed for Xorg auto-detection + of drivers (no custom config), and for nvidia-drm.modeset=1 if used. + Cannot be directly selected in the kernel's menuconfig, and may need + selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or + DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in." + + local ERROR_X86_KERNEL_IBT="CONFIG_X86_KERNEL_IBT: is set and, if the CPU supports the feature, + this *could* lead to modules load failure with ENDBR errors, or to + broken CUDA/NVENC. Please ignore if not having issues, but otherwise + try to unset or pass ibt=off to the kernel's command line." #911142 + + use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764 + + linux-mod-r1_pkg_setup +} + +src_prepare() { + # make patches usable across versions + rm nvidia-modprobe && mv nvidia-modprobe{-${PV},} || die + rm nvidia-persistenced && mv nvidia-persistenced{-${PV},} || die + rm nvidia-settings && mv nvidia-settings{-${PV},} || die + rm nvidia-xconfig && mv nvidia-xconfig{-${PV},} || die + + default + + # prevent detection of incomplete kernel DRM support (bug #603818) + sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \ + -i kernel/conftest.sh || die + + sed 's/__USER__/nvpd/' \ + nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \ + > "${T}"/nvidia-persistenced.service || die +} + +src_compile() { + tc-export AR CC CXX LD OBJCOPY OBJDUMP PKG_CONFIG + local -x RAW_LDFLAGS="$(get_abi_LDFLAGS) $(raw-ldflags)" # raw-ldflags.patch + + # latest branches has proper fixes, but legacy have more issues and are + # not worth the trouble, so doing the lame "fix" for gcc14 (bug #921370) + # TODO: check if still needed on bumps given this branch is supported, + # and reminder to cleanup the CC="${KERNEL_CC}" in modargs if removing + local noerr=( + -Wno-error=implicit-function-declaration + -Wno-error=incompatible-pointer-types + ) + # not *FLAGS to ensure it's used everywhere including conftest.sh + CC+=" $(test-flags-CC "${noerr[@]}")" + use modules && KERNEL_CC+=" $(CC=${KERNEL_CC} test-flags-CC "${noerr[@]}")" + + local xnvflags=-fPIC #840389 + # lto static libraries tend to cause problems without fat objects + tc-is-lto && xnvflags+=" $(test-flags-CC -ffat-lto-objects)" + + NV_ARGS=( + PREFIX="${EPREFIX}"/usr + HOST_CC="$(tc-getBUILD_CC)" + HOST_LD="$(tc-getBUILD_LD)" + NV_USE_BUNDLED_LIBJANSSON=0 + NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out + XNVCTRL_CFLAGS="${xnvflags}" + ) + + local modlist=( nvidia{,-drm,-modeset,-peermem,-uvm}=video:kernel ) + local modargs=( + CC="${KERNEL_CC}" # for the above gcc14 workarounds + IGNORE_CC_MISMATCH=yes NV_VERBOSE=1 + SYSOUT="${KV_OUT_DIR}" SYSSRC="${KV_DIR}" + ) + + # temporary workaround for bug #914468 + use modules && + CPP="${KERNEL_CC} -E" tc-is-clang && addpredict "${KV_OUT_DIR}" + + linux-mod-r1_src_compile + emake "${NV_ARGS[@]}" -C nvidia-modprobe + use persistenced && emake "${NV_ARGS[@]}" -C nvidia-persistenced + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig + + if use tools; then + # avoid noisy *very* noisy logs with deprecation warnings + CFLAGS="-Wno-deprecated-declarations ${CFLAGS}" \ + emake "${NV_ARGS[@]}" -C nvidia-settings + elif use static-libs; then + emake "${NV_ARGS[@]}" -C nvidia-settings/src out/libXNVCtrl.a + fi +} + +src_install() { + local libdir=$(get_libdir) libdir32=$(ABI=x86 get_libdir) + + NV_ARGS+=( DESTDIR="${D}" LIBDIR="${ED}"/usr/${libdir} ) + + local -A paths=( + [APPLICATION_PROFILE]=/usr/share/nvidia + [CUDA_ICD]=/etc/OpenCL/vendors + [EGL_EXTERNAL_PLATFORM_JSON]=/usr/share/egl/egl_external_platform.d + [FIRMWARE]=/lib/firmware/nvidia/${PV} + [GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d + [VULKAN_ICD_JSON]=/usr/share/vulkan + [WINE_LIB]=/usr/${libdir}/nvidia/wine + [XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d + + [GLX_MODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules/extensions + [GLX_MODULE_SYMLINK]=/usr/${libdir}/xorg/modules + [XMODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules + ) + + local skip_files=( + $(usev !X "libGLX_nvidia libglxserver_nvidia libnvidia-ifr") + libGLX_indirect # non-glvnd unused fallback + libnvidia-gtk nvidia-{settings,xconfig} # built from source + # skip wayland-related files, largely broken with 470 at this point + libnvidia-egl-wayland 10_nvidia_wayland libnvidia-vulkan-producer + ) + local skip_modules=( + $(usev !X "nvfbc vdpau xdriver") + $(usev !modules gsp) + installer nvpd # handled separately / built from source + ) + local skip_types=( + GLVND_LIB GLVND_SYMLINK EGL_CLIENT.\* GLX_CLIENT.\* # media-libs/libglvnd + OPENCL_WRAPPER.\* # virtual/opencl + DOCUMENTATION DOT_DESKTOP .\*_SRC DKMS_CONF # handled separately / unused + ) + + local DOCS=( + README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json + nvidia-settings/doc/{FRAMELOCK,NV-CONTROL-API}.txt + ) + local HTML_DOCS=( html/. ) + einstalldocs + + local DISABLE_AUTOFORMATTING=yes + local DOC_CONTENTS="\ +Trusted users should be in the 'video' group to use NVIDIA devices. +You can add yourself by using: gpasswd -a my-user video\ +$(usev modules " + +Like all out-of-tree kernel modules, it is necessary to rebuild +${PN} after upgrading or rebuilding the Linux kernel +by for example running \`emerge @module-rebuild\`. Alternatively, +if using a distribution kernel (sys-kernel/gentoo-kernel{,-bin}), +this can be automated by setting USE=dist-kernel globally. + +Loaded kernel modules also must not mismatch with the installed +${PN} version (excluding -r revision), meaning should +ensure \`eselect kernel list\` points to the kernel that will be +booted before building and preferably reboot after upgrading +${PN} (the ebuild will emit a warning if mismatching). + +See '${EPREFIX}/etc/modprobe.d/nvidia.conf' for modules options.")\ +$(use amd64 && usev !abi_x86_32 " + +Note that without USE=abi_x86_32 on ${PN}, 32bit applications +(typically using wine / steam) will not be able to use GPU acceleration.") + +For additional information or for troubleshooting issues, please see +https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own +documentation that is installed alongside this README." + readme.gentoo_create_doc + + if use modules; then + linux-mod-r1_src_install + + insinto /etc/modprobe.d + newins "${FILESDIR}"/nvidia-470.conf nvidia.conf + + # used for gpu verification with binpkgs (not kept, see pkg_preinst) + insinto /usr/share/nvidia + doins supported-gpus/supported-gpus.json + fi + + emake "${NV_ARGS[@]}" -C nvidia-modprobe install + fowners :video /usr/bin/nvidia-modprobe #505092 + fperms 4710 /usr/bin/nvidia-modprobe + + if use persistenced; then + emake "${NV_ARGS[@]}" -C nvidia-persistenced install + newconfd "${FILESDIR}"/nvidia-persistenced.confd nvidia-persistenced + newinitd "${FILESDIR}"/nvidia-persistenced.initd nvidia-persistenced + systemd_dounit "${T}"/nvidia-persistenced.service + fi + + if use tools; then + emake "${NV_ARGS[@]}" -C nvidia-settings install + + doicon nvidia-settings/doc/nvidia-settings.png + domenu nvidia-settings/doc/nvidia-settings.desktop + + exeinto /etc/X11/xinit/xinitrc.d + newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings + fi + + if use static-libs; then + dolib.a nvidia-settings/src/out/libXNVCtrl.a + + insinto /usr/include/NVCtrl + doins nvidia-settings/src/libXNVCtrl/NVCtrl{Lib,}.h + fi + + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig install + + # mimic nvidia-installer by reading .manifest to install files + # 0:file 1:perms 2:type 3+:subtype/arguments -:module + local m into + while IFS=' ' read -ra m; do + ! [[ ${#m[@]} -ge 2 && ${m[-1]} =~ MODULE: ]] || + [[ " ${m[0]##*/}" =~ ^(\ ${skip_files[*]/%/.*|\\} )$ ]] || + [[ " ${m[2]}" =~ ^(\ ${skip_types[*]/%/|\\} )$ ]] || + has ${m[-1]#MODULE:} "${skip_modules[@]}" && continue + + case ${m[2]} in + MANPAGE) + gzip -dc ${m[0]} | newman - ${m[0]%.gz}; assert + continue + ;; + VDPAU_SYMLINK) m[4]=vdpau/; m[5]=${m[5]#vdpau/};; # .so to vdpau/ + esac + + if [[ -v 'paths[${m[2]}]' ]]; then + into=${paths[${m[2]}]} + elif [[ ${m[2]} == *_BINARY ]]; then + into=/opt/bin + elif [[ ${m[3]} == COMPAT32 ]]; then + use abi_x86_32 || continue + into=/usr/${libdir32} + elif [[ ${m[2]} == *_@(LIB|SYMLINK) ]]; then + into=/usr/${libdir} + else + die "No known installation path for ${m[0]}" + fi + [[ ${m[3]: -2} == ?/ ]] && into+=/${m[3]%/} + [[ ${m[4]: -2} == ?/ ]] && into+=/${m[4]%/} + + if [[ ${m[2]} =~ _SYMLINK$ ]]; then + [[ ${m[4]: -1} == / ]] && m[4]=${m[5]} + dosym ${m[4]} ${into}/${m[0]} + continue + fi + [[ ${m[0]} =~ ^libnvidia-ngx.so ]] && + dosym ${m[0]} ${into}/${m[0]%.so*}.so.1 # soname not in .manifest + + printf -v m[1] %o $((m[1] | 0200)) # 444->644 + insopts -m${m[1]} + insinto ${into} + doins ${m[0]} + done < .manifest || die + insopts -m0644 # reset + + # MODULE:installer non-skipped extras + : "$(systemd_get_sleepdir)" + exeinto "${_#"${EPREFIX}"}" + doexe systemd/system-sleep/nvidia + dobin systemd/nvidia-sleep.sh + systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend}.service + + dobin nvidia-bug-report.sh + + # enabling is needed for sleep to work properly and little reason not to do + # it unconditionally for a better user experience + : "$(systemd_get_systemunitdir)" + local unitdir=${_#"${EPREFIX}"} + # not using relative symlinks to match systemd's own links + dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-hibernate.service + dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-resume.service + dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-suspend.service + dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-resume.service + # also add a custom elogind hook to do the equivalent of the above + exeinto /usr/lib/elogind/system-sleep + newexe "${FILESDIR}"/system-sleep.elogind nvidia + # /dev/null); do + g=$(grep -io "\"devid\":\"$(<${g%vendor}device)\"[^}]*branch\":\"[0-9]*" \ + "${ED}"/usr/share/nvidia/supported-gpus.json 2>/dev/null) + if [[ ${g} ]]; then + g=$((${g##*\"}+1)) + if ver_test -ge ${g}; then + NV_LEGACY_MASK=">=${CATEGORY}/${PN}-${g}" + break + fi + fi + done + rm "${ED}"/usr/share/nvidia/supported-gpus.json || die +} + +pkg_postinst() { + linux-mod-r1_pkg_postinst + + readme.gentoo_print_elog + + if [[ -r /proc/driver/nvidia/version && + $( ${EROOT}/etc/portage/package.mask/${PN}" + else + ewarn " echo '${NV_LEGACY_MASK}' >> ${EROOT}/etc/portage/package.mask" + fi + ewarn "...then downgrade to a legacy[1] branch if possible (not all old versions" + ewarn "are available or fully functional, may need to consider nouveau[2])." + ewarn "[1] https://www.nvidia.com/object/IO_32667.html" + ewarn "[2] https://wiki.gentoo.org/wiki/Nouveau" + fi + + # these can be removed after some time, only to help the transition + # given users are unlikely to do further custom solutions if it works + # (see also https://github.com/elogind/elogind/issues/272) + if grep -riq "^[^#]*HandleNvidiaSleep=yes" "${EROOT}"/etc/elogind/sleep.conf.d/ 2>/dev/null + then + ewarn + ewarn "!!! WARNING !!!" + ewarn "Detected HandleNvidiaSleep=yes in ${EROOT}/etc/elogind/sleep.conf.d/." + ewarn "This 'could' cause issues if used in combination with the new hook" + ewarn "installed by the ebuild to handle sleep using the official upstream" + ewarn "script. It is recommended to disable the option." + fi + if [[ $(realpath "${EROOT}"{/etc,{/usr,}/lib*}/elogind/system-sleep | sort | uniq | \ + xargs -d'\n' grep -Ril nvidia 2>/dev/null | wc -l) -gt 2 ]] + then + ewarn + ewarn "!!! WARNING !!!" + ewarn "Detected a custom script at ${EROOT}{/etc,{/usr,}/lib*}/elogind/system-sleep" + ewarn "referencing NVIDIA. This version of ${PN} has installed its own" + ewarn "hook at ${EROOT}/usr/lib/elogind/system-sleep/nvidia and it is recommended" + ewarn "to remove the custom one to avoid potential issues." + ewarn + ewarn "Feel free to ignore this warning if you know the other NVIDIA-related" + ewarn "scripts can be used together. The warning will be removed in the future." + fi + if [[ ${REPLACING_VERSIONS##* } ]] && + ver_test ${REPLACING_VERSIONS##* } -lt 470.256.02-r1 # may get repeated + then + elog + elog "For suspend/sleep, 'NVreg_PreserveVideoMemoryAllocations=1' is now default" + elog "with this version of ${PN}. This is recommended (or required) by" + elog "major DEs especially with wayland but, *if* experience regressions with" + elog "suspend, try reverting to =0 in '${EROOT}/etc/modprobe.d/nvidia.conf'." + elog + elog "May notably be an issue when using neither systemd nor elogind to suspend." + elog + elog "Also, the systemd suspend/hibernate/resume services are now enabled by" + elog "default, and for openrc+elogind a similar hook has been installed." + fi +} diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-470.256.02.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-470.256.02.ebuild deleted file mode 100644 index 72647eb64cb8..000000000000 --- a/x11-drivers/nvidia-drivers/nvidia-drivers-470.256.02.ebuild +++ /dev/null @@ -1,438 +0,0 @@ -# Copyright 1999-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -MODULES_OPTIONAL_IUSE=+modules -inherit desktop flag-o-matic linux-mod-r1 multilib readme.gentoo-r1 -inherit systemd toolchain-funcs unpacker user-info - -MODULES_KERNEL_MAX=6.9 -NV_URI="https://download.nvidia.com/XFree86/" - -DESCRIPTION="NVIDIA Accelerated Graphics Driver" -HOMEPAGE="https://www.nvidia.com/download/index.aspx" -SRC_URI=" - ${NV_URI}Linux-x86_64/${PV}/NVIDIA-Linux-x86_64-${PV}.run - $(printf "${NV_URI}%s/%s-${PV}.tar.bz2 " \ - nvidia-{installer,modprobe,persistenced,settings,xconfig}{,}) -" -# nvidia-installer is unused but here for GPL-2's "distribute sources" -S=${WORKDIR} - -LICENSE="NVIDIA-r2 BSD BSD-2 GPL-2 MIT ZLIB curl openssl" -SLOT="0/${PV%%.*}" -KEYWORDS="-* amd64" -IUSE="+X abi_x86_32 abi_x86_64 persistenced +static-libs +tools" - -COMMON_DEPEND=" - acct-group/video - persistenced? ( - acct-user/nvpd - net-libs/libtirpc:= - ) - tools? ( - >=app-accessibility/at-spi2-core-2.46:2 - dev-libs/glib:2 - dev-libs/jansson:= - media-libs/harfbuzz:= - x11-libs/cairo - x11-libs/gdk-pixbuf:2 - x11-libs/gtk+:3[X] - x11-libs/libX11 - x11-libs/libXext - x11-libs/libXxf86vm - x11-libs/pango - ) -" -RDEPEND=" - ${COMMON_DEPEND} - sys-libs/glibc - X? ( - media-libs/libglvnd[X,abi_x86_32(-)?] - x11-libs/libX11[abi_x86_32(-)?] - x11-libs/libXext[abi_x86_32(-)?] - ) -" -DEPEND=" - ${COMMON_DEPEND} - static-libs? ( - x11-base/xorg-proto - x11-libs/libX11 - x11-libs/libXext - ) - tools? ( - media-libs/libglvnd - sys-apps/dbus - x11-base/xorg-proto - x11-libs/libXrandr - x11-libs/libXv - x11-libs/libvdpau - ) -" -BDEPEND=" - sys-devel/m4 - virtual/pkgconfig -" - -QA_PREBUILT="lib/firmware/* opt/bin/* usr/lib*" - -PATCHES=( - "${FILESDIR}"/nvidia-drivers-470.141.03-clang15.patch - "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch - "${FILESDIR}"/nvidia-settings-390.144-desktop.patch - "${FILESDIR}"/nvidia-settings-390.144-no-gtk2.patch - "${FILESDIR}"/nvidia-settings-390.144-raw-ldflags.patch -) - -pkg_setup() { - use modules && [[ ${MERGE_TYPE} != binary ]] || return - - local CONFIG_CHECK=" - PROC_FS - ~DRM_KMS_HELPER - ~SYSVIPC - ~!AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT - ~!LOCKDEP - ~!SLUB_DEBUG_ON - ~!X86_KERNEL_IBT - !DEBUG_MUTEXES - " - - local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but needed for Xorg auto-detection - of drivers (no custom config), and for nvidia-drm.modeset=1 if used. - Cannot be directly selected in the kernel's menuconfig, and may need - selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or - DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in." - - local ERROR_X86_KERNEL_IBT="CONFIG_X86_KERNEL_IBT: is set and, if the CPU supports the feature, - this *could* lead to modules load failure with ENDBR errors, or to - broken CUDA/NVENC. Please ignore if not having issues, but otherwise - try to unset or pass ibt=off to the kernel's command line." #911142 - - use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764 - - linux-mod-r1_pkg_setup -} - -src_prepare() { - # make patches usable across versions - rm nvidia-modprobe && mv nvidia-modprobe{-${PV},} || die - rm nvidia-persistenced && mv nvidia-persistenced{-${PV},} || die - rm nvidia-settings && mv nvidia-settings{-${PV},} || die - rm nvidia-xconfig && mv nvidia-xconfig{-${PV},} || die - - default - - # prevent detection of incomplete kernel DRM support (bug #603818) - sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \ - -i kernel/conftest.sh || die - - sed 's/__USER__/nvpd/' \ - nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \ - > "${T}"/nvidia-persistenced.service || die -} - -src_compile() { - tc-export AR CC CXX LD OBJCOPY OBJDUMP PKG_CONFIG - local -x RAW_LDFLAGS="$(get_abi_LDFLAGS) $(raw-ldflags)" # raw-ldflags.patch - - # latest branches has proper fixes, but legacy have more issues and are - # not worth the trouble, so doing the lame "fix" for gcc14 (bug #921370) - # TODO: check if still needed on bumps given this branch is supported, - # and reminder to cleanup the CC="${KERNEL_CC}" in modargs if removing - local noerr=( - -Wno-error=implicit-function-declaration - -Wno-error=incompatible-pointer-types - ) - # not *FLAGS to ensure it's used everywhere including conftest.sh - CC+=" $(test-flags-CC "${noerr[@]}")" - use modules && KERNEL_CC+=" $(CC=${KERNEL_CC} test-flags-CC "${noerr[@]}")" - - local xnvflags=-fPIC #840389 - # lto static libraries tend to cause problems without fat objects - tc-is-lto && xnvflags+=" $(test-flags-CC -ffat-lto-objects)" - - NV_ARGS=( - PREFIX="${EPREFIX}"/usr - HOST_CC="$(tc-getBUILD_CC)" - HOST_LD="$(tc-getBUILD_LD)" - NV_USE_BUNDLED_LIBJANSSON=0 - NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out - XNVCTRL_CFLAGS="${xnvflags}" - ) - - local modlist=( nvidia{,-drm,-modeset,-peermem,-uvm}=video:kernel ) - local modargs=( - CC="${KERNEL_CC}" # for the above gcc14 workarounds - IGNORE_CC_MISMATCH=yes NV_VERBOSE=1 - SYSOUT="${KV_OUT_DIR}" SYSSRC="${KV_DIR}" - ) - - # temporary workaround for bug #914468 - use modules && - CPP="${KERNEL_CC} -E" tc-is-clang && addpredict "${KV_OUT_DIR}" - - linux-mod-r1_src_compile - emake "${NV_ARGS[@]}" -C nvidia-modprobe - use persistenced && emake "${NV_ARGS[@]}" -C nvidia-persistenced - use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig - - if use tools; then - # avoid noisy *very* noisy logs with deprecation warnings - CFLAGS="-Wno-deprecated-declarations ${CFLAGS}" \ - emake "${NV_ARGS[@]}" -C nvidia-settings - elif use static-libs; then - emake "${NV_ARGS[@]}" -C nvidia-settings/src out/libXNVCtrl.a - fi -} - -src_install() { - local libdir=$(get_libdir) libdir32=$(ABI=x86 get_libdir) - - NV_ARGS+=( DESTDIR="${D}" LIBDIR="${ED}"/usr/${libdir} ) - - local -A paths=( - [APPLICATION_PROFILE]=/usr/share/nvidia - [CUDA_ICD]=/etc/OpenCL/vendors - [EGL_EXTERNAL_PLATFORM_JSON]=/usr/share/egl/egl_external_platform.d - [FIRMWARE]=/lib/firmware/nvidia/${PV} - [GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d - [VULKAN_ICD_JSON]=/usr/share/vulkan - [WINE_LIB]=/usr/${libdir}/nvidia/wine - [XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d - - [GLX_MODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules/extensions - [GLX_MODULE_SYMLINK]=/usr/${libdir}/xorg/modules - [XMODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules - ) - - local skip_files=( - $(usev !X "libGLX_nvidia libglxserver_nvidia libnvidia-ifr") - libGLX_indirect # non-glvnd unused fallback - libnvidia-gtk nvidia-{settings,xconfig} # built from source - # skip wayland-related files, largely broken with 470 at this point - libnvidia-egl-wayland 10_nvidia_wayland libnvidia-vulkan-producer - ) - local skip_modules=( - $(usev !X "nvfbc vdpau xdriver") - $(usev !modules gsp) - installer nvpd # handled separately / built from source - ) - local skip_types=( - GLVND_LIB GLVND_SYMLINK EGL_CLIENT.\* GLX_CLIENT.\* # media-libs/libglvnd - OPENCL_WRAPPER.\* # virtual/opencl - DOCUMENTATION DOT_DESKTOP .\*_SRC DKMS_CONF # handled separately / unused - ) - - local DOCS=( - README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json - nvidia-settings/doc/{FRAMELOCK,NV-CONTROL-API}.txt - ) - local HTML_DOCS=( html/. ) - einstalldocs - - local DISABLE_AUTOFORMATTING=yes - local DOC_CONTENTS="\ -Trusted users should be in the 'video' group to use NVIDIA devices. -You can add yourself by using: gpasswd -a my-user video\ -$(usev modules " - -Like all out-of-tree kernel modules, it is necessary to rebuild -${PN} after upgrading or rebuilding the Linux kernel -by for example running \`emerge @module-rebuild\`. Alternatively, -if using a distribution kernel (sys-kernel/gentoo-kernel{,-bin}), -this can be automated by setting USE=dist-kernel globally. - -Loaded kernel modules also must not mismatch with the installed -${PN} version (excluding -r revision), meaning should -ensure \`eselect kernel list\` points to the kernel that will be -booted before building and preferably reboot after upgrading -${PN} (the ebuild will emit a warning if mismatching). - -See '${EPREFIX}/etc/modprobe.d/nvidia.conf' for modules options.")\ -$(use amd64 && usev !abi_x86_32 " - -Note that without USE=abi_x86_32 on ${PN}, 32bit applications -(typically using wine / steam) will not be able to use GPU acceleration.") - -For additional information or for troubleshooting issues, please see -https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own -documentation that is installed alongside this README." - readme.gentoo_create_doc - - if use modules; then - linux-mod-r1_src_install - - insinto /etc/modprobe.d - newins "${FILESDIR}"/nvidia-470.conf nvidia.conf - - # used for gpu verification with binpkgs (not kept, see pkg_preinst) - insinto /usr/share/nvidia - doins supported-gpus/supported-gpus.json - fi - - emake "${NV_ARGS[@]}" -C nvidia-modprobe install - fowners :video /usr/bin/nvidia-modprobe #505092 - fperms 4710 /usr/bin/nvidia-modprobe - - if use persistenced; then - emake "${NV_ARGS[@]}" -C nvidia-persistenced install - newconfd "${FILESDIR}"/nvidia-persistenced.confd nvidia-persistenced - newinitd "${FILESDIR}"/nvidia-persistenced.initd nvidia-persistenced - systemd_dounit "${T}"/nvidia-persistenced.service - fi - - if use tools; then - emake "${NV_ARGS[@]}" -C nvidia-settings install - - doicon nvidia-settings/doc/nvidia-settings.png - domenu nvidia-settings/doc/nvidia-settings.desktop - - exeinto /etc/X11/xinit/xinitrc.d - newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings - fi - - if use static-libs; then - dolib.a nvidia-settings/src/out/libXNVCtrl.a - - insinto /usr/include/NVCtrl - doins nvidia-settings/src/libXNVCtrl/NVCtrl{Lib,}.h - fi - - use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig install - - # mimic nvidia-installer by reading .manifest to install files - # 0:file 1:perms 2:type 3+:subtype/arguments -:module - local m into - while IFS=' ' read -ra m; do - ! [[ ${#m[@]} -ge 2 && ${m[-1]} =~ MODULE: ]] || - [[ " ${m[0]##*/}" =~ ^(\ ${skip_files[*]/%/.*|\\} )$ ]] || - [[ " ${m[2]}" =~ ^(\ ${skip_types[*]/%/|\\} )$ ]] || - has ${m[-1]#MODULE:} "${skip_modules[@]}" && continue - - case ${m[2]} in - MANPAGE) - gzip -dc ${m[0]} | newman - ${m[0]%.gz}; assert - continue - ;; - VDPAU_SYMLINK) m[4]=vdpau/; m[5]=${m[5]#vdpau/};; # .so to vdpau/ - esac - - if [[ -v 'paths[${m[2]}]' ]]; then - into=${paths[${m[2]}]} - elif [[ ${m[2]} == *_BINARY ]]; then - into=/opt/bin - elif [[ ${m[3]} == COMPAT32 ]]; then - use abi_x86_32 || continue - into=/usr/${libdir32} - elif [[ ${m[2]} == *_@(LIB|SYMLINK) ]]; then - into=/usr/${libdir} - else - die "No known installation path for ${m[0]}" - fi - [[ ${m[3]: -2} == ?/ ]] && into+=/${m[3]%/} - [[ ${m[4]: -2} == ?/ ]] && into+=/${m[4]%/} - - if [[ ${m[2]} =~ _SYMLINK$ ]]; then - [[ ${m[4]: -1} == / ]] && m[4]=${m[5]} - dosym ${m[4]} ${into}/${m[0]} - continue - fi - [[ ${m[0]} =~ ^libnvidia-ngx.so ]] && - dosym ${m[0]} ${into}/${m[0]%.so*}.so.1 # soname not in .manifest - - printf -v m[1] %o $((m[1] | 0200)) # 444->644 - insopts -m${m[1]} - insinto ${into} - doins ${m[0]} - done < .manifest || die - insopts -m0644 # reset - - # MODULE:installer non-skipped extras - : "$(systemd_get_sleepdir)" - exeinto "${_#"${EPREFIX}"}" - doexe systemd/system-sleep/nvidia - dobin systemd/nvidia-sleep.sh - systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend}.service - - dobin nvidia-bug-report.sh - - # symlink non-versioned so nvidia-settings can use it even if misdetected - dosym nvidia-application-profiles-${PV}-key-documentation \ - ${paths[APPLICATION_PROFILE]}/nvidia-application-profiles-key-documentation - - # don't attempt to strip firmware files (silences errors) - dostrip -x ${paths[FIRMWARE]} - - # sandbox issues with /dev/nvidiactl (and /dev/char wrt bug #904292) - # are widespread and sometime affect revdeps of packages built with - # USE=opencl/cuda making it hard to manage in ebuilds (minimal set, - # ebuilds should handle manually if need others or addwrite) - insinto /etc/sandbox.d - newins - 20nvidia <<<'SANDBOX_PREDICT="/dev/nvidiactl:/dev/char"' -} - -pkg_preinst() { - use modules || return - - # set video group id based on live system (bug #491414) - local g=$(egetent group video | cut -d: -f3) - [[ ${g} =~ ^[0-9]+$ ]] || die "Failed to determine video group id (got '${g}')" - sed -i "s/@VIDEOGID@/${g}/" "${ED}"/etc/modprobe.d/nvidia.conf || die - - # try to find driver mismatches using temporary supported-gpus.json - for g in $(grep -l 0x10de /sys/bus/pci/devices/*/vendor 2>/dev/null); do - g=$(grep -io "\"devid\":\"$(<${g%vendor}device)\"[^}]*branch\":\"[0-9]*" \ - "${ED}"/usr/share/nvidia/supported-gpus.json 2>/dev/null) - if [[ ${g} ]]; then - g=$((${g##*\"}+1)) - if ver_test -ge ${g}; then - NV_LEGACY_MASK=">=${CATEGORY}/${PN}-${g}" - break - fi - fi - done - rm "${ED}"/usr/share/nvidia/supported-gpus.json || die -} - -pkg_postinst() { - linux-mod-r1_pkg_postinst - - readme.gentoo_print_elog - - if [[ -r /proc/driver/nvidia/version && - $( ${EROOT}/etc/portage/package.mask/${PN}" - else - ewarn " echo '${NV_LEGACY_MASK}' >> ${EROOT}/etc/portage/package.mask" - fi - ewarn "...then downgrade to a legacy[1] branch if possible (not all old versions" - ewarn "are available or fully functional, may need to consider nouveau[2])." - ewarn "[1] https://www.nvidia.com/object/IO_32667.html" - ewarn "[2] https://wiki.gentoo.org/wiki/Nouveau" - fi -} diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-525.147.05-r1.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-525.147.05-r1.ebuild new file mode 100644 index 000000000000..de085dd0ad2b --- /dev/null +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-525.147.05-r1.ebuild @@ -0,0 +1,577 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +MODULES_OPTIONAL_IUSE=+modules +inherit desktop flag-o-matic linux-mod-r1 multilib readme.gentoo-r1 +inherit systemd toolchain-funcs unpacker user-info + +MODULES_KERNEL_MAX=6.7 # 6.6 for arm64 (see below) +NV_URI="https://download.nvidia.com/XFree86/" + +DESCRIPTION="NVIDIA Accelerated Graphics Driver" +HOMEPAGE="https://www.nvidia.com/download/index.aspx" +SRC_URI=" + amd64? ( ${NV_URI}Linux-x86_64/${PV}/NVIDIA-Linux-x86_64-${PV}.run ) + arm64? ( ${NV_URI}Linux-aarch64/${PV}/NVIDIA-Linux-aarch64-${PV}.run ) + $(printf "${NV_URI}%s/%s-${PV}.tar.bz2 " \ + nvidia-{installer,modprobe,persistenced,settings,xconfig}{,}) + ${NV_URI}NVIDIA-kernel-module-source/NVIDIA-kernel-module-source-${PV}.tar.xz +" +# nvidia-installer is unused but here for GPL-2's "distribute sources" +S=${WORKDIR} + +LICENSE="NVIDIA-r2 BSD BSD-2 GPL-2 MIT ZLIB curl openssl" +SLOT="0/${PV%%.*}" +KEYWORDS="-* amd64 ~arm64" +IUSE="+X abi_x86_32 abi_x86_64 kernel-open persistenced powerd +static-libs +tools wayland" +REQUIRED_USE="kernel-open? ( modules )" + +COMMON_DEPEND=" + acct-group/video + X? ( x11-libs/libpciaccess ) + persistenced? ( + acct-user/nvpd + net-libs/libtirpc:= + ) + tools? ( + >=app-accessibility/at-spi2-core-2.46:2 + dev-libs/glib:2 + dev-libs/jansson:= + media-libs/harfbuzz:= + x11-libs/cairo + x11-libs/gdk-pixbuf:2 + x11-libs/gtk+:3[X] + x11-libs/libX11 + x11-libs/libXext + x11-libs/libXxf86vm + x11-libs/pango + ) +" +RDEPEND=" + ${COMMON_DEPEND} + sys-libs/glibc + X? ( + media-libs/libglvnd[X,abi_x86_32(-)?] + x11-libs/libX11[abi_x86_32(-)?] + x11-libs/libXext[abi_x86_32(-)?] + ) + powerd? ( sys-apps/dbus[abi_x86_32(-)?] ) + wayland? ( + gui-libs/egl-gbm + >=gui-libs/egl-wayland-1.1.10 + media-libs/libglvnd + ) +" +DEPEND=" + ${COMMON_DEPEND} + static-libs? ( + x11-base/xorg-proto + x11-libs/libX11 + x11-libs/libXext + ) + tools? ( + media-libs/libglvnd + sys-apps/dbus + x11-base/xorg-proto + x11-libs/libXrandr + x11-libs/libXv + x11-libs/libvdpau + ) +" +BDEPEND=" + sys-devel/m4 + virtual/pkgconfig +" + +QA_PREBUILT="lib/firmware/* opt/bin/* usr/lib*" + +PATCHES=( + "${FILESDIR}"/nvidia-drivers-470.223.02-gpl-pfn_valid.patch + "${FILESDIR}"/nvidia-drivers-525.116.04-clang-unused-option.patch + "${FILESDIR}"/nvidia-drivers-525.147.05-gcc14.patch + "${FILESDIR}"/nvidia-kernel-module-source-515.86.01-raw-ldflags.patch + "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch + "${FILESDIR}"/nvidia-settings-390.144-desktop.patch + "${FILESDIR}"/nvidia-settings-390.144-raw-ldflags.patch +) + +pkg_setup() { + use modules && [[ ${MERGE_TYPE} != binary ]] || return + + local CONFIG_CHECK=" + PROC_FS + ~DRM_KMS_HELPER + ~SYSVIPC + ~!LOCKDEP + ~!SLUB_DEBUG_ON + !DEBUG_MUTEXES + $(usev powerd '~CPU_FREQ') + " + + local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but needed for Xorg auto-detection + of drivers (no custom config), and for wayland / nvidia-drm.modeset=1. + Cannot be directly selected in the kernel's menuconfig, and may need + selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or + DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in." + + local ERROR_X86_KERNEL_IBT="CONFIG_X86_KERNEL_IBT: is set and, if the CPU supports the feature, + this *could* lead to modules load failure with ENDBR errors, or to + broken CUDA/NVENC. Please ignore if not having issues, but otherwise + try to unset or pass ibt=off to the kernel's command line." #911142 + use kernel-open || CONFIG_CHECK+=" ~!X86_KERNEL_IBT" + + use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764 + + use kernel-open && CONFIG_CHECK+=" MMU_NOTIFIER" #843827 + local ERROR_MMU_NOTIFIER="CONFIG_MMU_NOTIFIER: is not set but needed to build with USE=kernel-open. + Cannot be directly selected in the kernel's menuconfig, and may need + selection of another option that requires it such as CONFIG_KVM." + + # screen_info is marked GPL on non-x86 in 6.7 and cannot be used + # (patchable, but just avoid advertising compatibility for now) + # https://forums.developer.nvidia.com/t/278367 + use arm64 && MODULES_KERNEL_MAX=6.6 + + linux-mod-r1_pkg_setup +} + +src_prepare() { + # make patches usable across versions + rm nvidia-modprobe && mv nvidia-modprobe{-${PV},} || die + rm nvidia-persistenced && mv nvidia-persistenced{-${PV},} || die + rm nvidia-settings && mv nvidia-settings{-${PV},} || die + rm nvidia-xconfig && mv nvidia-xconfig{-${PV},} || die + mv NVIDIA-kernel-module-source-${PV} kernel-module-source || die + + default + + # prevent detection of incomplete kernel DRM support (bug #603818) + sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \ + -i kernel{,-module-source/kernel-open}/conftest.sh || die + + # adjust service files + sed 's/__USER__/nvpd/' \ + nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \ + > "${T}"/nvidia-persistenced.service || die + use !powerd || # file is missing on arm64 (masked) + sed -i "s|/usr|${EPREFIX}/opt|" systemd/system/nvidia-powerd.service || die + + # use alternative vulkan icd option if USE=-X (bug #909181) + use X || sed -i 's/"libGLX/"libEGL/' nvidia_{layers,icd}.json || die + + # enable nvidia-drm.modeset=1 by default with USE=wayland + cp "${FILESDIR}"/nvidia-470.conf "${T}"/nvidia.conf || die + use !wayland || sed -i '/^#.*modeset=1$/s/^#//' "${T}"/nvidia.conf || die + + # makefile attempts to install wayland library even if not built + use wayland || sed -i 's/ WAYLAND_LIB_install$//' \ + nvidia-settings/src/Makefile || die + + # temporary option, nvidia will remove in the future + use !kernel-open || + sed -i '/blacklist/a\ +\ +# Enable using kernel-open with workstation GPUs (experimental)\ +options nvidia NVreg_OpenRmEnableUnsupportedGpus=1' "${T}"/nvidia.conf || die +} + +src_compile() { + tc-export AR CC CXX LD OBJCOPY OBJDUMP PKG_CONFIG + local -x RAW_LDFLAGS="$(get_abi_LDFLAGS) $(raw-ldflags)" # raw-ldflags.patch + + local xnvflags=-fPIC #840389 + # lto static libraries tend to cause problems without fat objects + tc-is-lto && xnvflags+=" $(test-flags-CC -ffat-lto-objects)" + + NV_ARGS=( + PREFIX="${EPREFIX}"/usr + HOST_CC="$(tc-getBUILD_CC)" + HOST_LD="$(tc-getBUILD_LD)" + BUILD_GTK2LIB= + NV_USE_BUNDLED_LIBJANSSON=0 + NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out + WAYLAND_AVAILABLE=$(usex wayland 1 0) + XNVCTRL_CFLAGS="${xnvflags}" + ) + + if use modules; then + local o_cflags=${CFLAGS} o_cxxflags=${CXXFLAGS} o_ldflags=${LDFLAGS} + + local modlistargs=video:kernel + if use kernel-open; then + modlistargs+=-module-source:kernel-module-source/kernel-open + + # environment flags are normally unused for modules, but nvidia + # uses it for building the "blob" and it is a bit fragile + filter-flags -fno-plt #912949 + filter-lto + CC=${KERNEL_CC} CXX=${KERNEL_CXX} strip-unsupported-flags + fi + + local modlist=( nvidia{,-drm,-modeset,-peermem,-uvm}=${modlistargs} ) + local modargs=( + IGNORE_CC_MISMATCH=yes NV_VERBOSE=1 + SYSOUT="${KV_OUT_DIR}" SYSSRC="${KV_DIR}" + ) + + # temporary workaround for bug #914468 + CPP="${KERNEL_CC} -E" tc-is-clang && addpredict "${KV_OUT_DIR}" + + linux-mod-r1_src_compile + CFLAGS=${o_cflags} CXXFLAGS=${o_cxxflags} LDFLAGS=${o_ldflags} + fi + + emake "${NV_ARGS[@]}" -C nvidia-modprobe + use persistenced && emake "${NV_ARGS[@]}" -C nvidia-persistenced + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig + + if use tools; then + # avoid noisy *very* noisy logs with deprecation warnings + CFLAGS="-Wno-deprecated-declarations ${CFLAGS}" \ + emake "${NV_ARGS[@]}" -C nvidia-settings + elif use static-libs; then + # pretend GTK+3 is available, not actually used (bug #880879) + emake "${NV_ARGS[@]}" BUILD_GTK3LIB=1 \ + -C nvidia-settings/src out/libXNVCtrl.a + fi +} + +src_install() { + local libdir=$(get_libdir) libdir32=$(ABI=x86 get_libdir) + + NV_ARGS+=( DESTDIR="${D}" LIBDIR="${ED}"/usr/${libdir} ) + + local -A paths=( + [APPLICATION_PROFILE]=/usr/share/nvidia + [CUDA_ICD]=/etc/OpenCL/vendors + [EGL_EXTERNAL_PLATFORM_JSON]=/usr/share/egl/egl_external_platform.d + [FIRMWARE]=/lib/firmware/nvidia/${PV} + [GBM_BACKEND_LIB_SYMLINK]=/usr/${libdir}/gbm + [GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d + [VULKAN_ICD_JSON]=/usr/share/vulkan + [WINE_LIB]=/usr/${libdir}/nvidia/wine + [XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d + + [GLX_MODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules/extensions + [GLX_MODULE_SYMLINK]=/usr/${libdir}/xorg/modules + [XMODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules + ) + + local skip_files=( + $(usev !X "libGLX_nvidia libglxserver_nvidia") + $(usev !wayland libnvidia-vulkan-producer) + libGLX_indirect # non-glvnd unused fallback + libnvidia-{gtk,wayland-client} nvidia-{settings,xconfig} # from source + libnvidia-egl-gbm 15_nvidia_gbm # gui-libs/egl-gbm + libnvidia-egl-wayland 10_nvidia_wayland # gui-libs/egl-wayland + ) + local skip_modules=( + $(usev !X "nvfbc vdpau xdriver") + $(usev !modules gsp) + $(usev !powerd powerd) + installer nvpd # handled separately / built from source + ) + local skip_types=( + GLVND_LIB GLVND_SYMLINK EGL_CLIENT.\* GLX_CLIENT.\* # media-libs/libglvnd + OPENCL_WRAPPER.\* # virtual/opencl + DOCUMENTATION DOT_DESKTOP .\*_SRC DKMS_CONF SYSTEMD_UNIT # handled separately / unused + ) + + local DOCS=( + README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json + nvidia-settings/doc/{FRAMELOCK,NV-CONTROL-API}.txt + ) + local HTML_DOCS=( html/. ) + einstalldocs + + local DISABLE_AUTOFORMATTING=yes + local DOC_CONTENTS="\ +Trusted users should be in the 'video' group to use NVIDIA devices. +You can add yourself by using: gpasswd -a my-user video\ +$(usev modules " + +Like all out-of-tree kernel modules, it is necessary to rebuild +${PN} after upgrading or rebuilding the Linux kernel +by for example running \`emerge @module-rebuild\`. Alternatively, +if using a distribution kernel (sys-kernel/gentoo-kernel{,-bin}), +this can be automated by setting USE=dist-kernel globally. + +Loaded kernel modules also must not mismatch with the installed +${PN} version (excluding -r revision), meaning should +ensure \`eselect kernel list\` points to the kernel that will be +booted before building and preferably reboot after upgrading +${PN} (the ebuild will emit a warning if mismatching). + +See '${EPREFIX}/etc/modprobe.d/nvidia.conf' for modules options.")\ +$(use amd64 && usev !abi_x86_32 " + +Note that without USE=abi_x86_32 on ${PN}, 32bit applications +(typically using wine / steam) will not be able to use GPU acceleration.") + +For additional information or for troubleshooting issues, please see +https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own +documentation that is installed alongside this README." + readme.gentoo_create_doc + + if use modules; then + linux-mod-r1_src_install + + insinto /etc/modprobe.d + doins "${T}"/nvidia.conf + + # used for gpu verification with binpkgs (not kept, see pkg_preinst) + insinto /usr/share/nvidia + doins supported-gpus/supported-gpus.json + fi + + emake "${NV_ARGS[@]}" -C nvidia-modprobe install + fowners :video /usr/bin/nvidia-modprobe #505092 + fperms 4710 /usr/bin/nvidia-modprobe + + if use persistenced; then + emake "${NV_ARGS[@]}" -C nvidia-persistenced install + newconfd "${FILESDIR}"/nvidia-persistenced.confd nvidia-persistenced + newinitd "${FILESDIR}"/nvidia-persistenced.initd nvidia-persistenced + systemd_dounit "${T}"/nvidia-persistenced.service + fi + + if use tools; then + emake "${NV_ARGS[@]}" -C nvidia-settings install + + doicon nvidia-settings/doc/nvidia-settings.png + domenu nvidia-settings/doc/nvidia-settings.desktop + + exeinto /etc/X11/xinit/xinitrc.d + newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings + fi + + if use static-libs; then + dolib.a nvidia-settings/src/out/libXNVCtrl.a + + insinto /usr/include/NVCtrl + doins nvidia-settings/src/libXNVCtrl/NVCtrl{Lib,}.h + fi + + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig install + + # mimic nvidia-installer by reading .manifest to install files + # 0:file 1:perms 2:type 3+:subtype/arguments -:module + local m into + while IFS=' ' read -ra m; do + ! [[ ${#m[@]} -ge 2 && ${m[-1]} =~ MODULE: ]] || + [[ " ${m[0]##*/}" =~ ^(\ ${skip_files[*]/%/.*|\\} )$ ]] || + [[ " ${m[2]}" =~ ^(\ ${skip_types[*]/%/|\\} )$ ]] || + has ${m[-1]#MODULE:} "${skip_modules[@]}" && continue + + case ${m[2]} in + MANPAGE) + gzip -dc ${m[0]} | newman - ${m[0]%.gz}; assert + continue + ;; + GBM_BACKEND_LIB_SYMLINK) m[4]=../${m[4]};; # missing ../ + VDPAU_SYMLINK) m[4]=vdpau/; m[5]=${m[5]#vdpau/};; # .so to vdpau/ + esac + + if [[ -v 'paths[${m[2]}]' ]]; then + into=${paths[${m[2]}]} + elif [[ ${m[2]} == *_BINARY ]]; then + into=/opt/bin + elif [[ ${m[3]} == COMPAT32 ]]; then + use abi_x86_32 || continue + into=/usr/${libdir32} + elif [[ ${m[2]} == *_@(LIB|SYMLINK) ]]; then + into=/usr/${libdir} + else + die "No known installation path for ${m[0]}" + fi + [[ ${m[3]: -2} == ?/ ]] && into+=/${m[3]%/} + [[ ${m[4]: -2} == ?/ ]] && into+=/${m[4]%/} + + if [[ ${m[2]} =~ _SYMLINK$ ]]; then + [[ ${m[4]: -1} == / ]] && m[4]=${m[5]} + dosym ${m[4]} ${into}/${m[0]} + continue + fi + [[ ${m[0]} =~ ^libnvidia-ngx.so|^libnvidia-egl-gbm.so ]] && + dosym ${m[0]} ${into}/${m[0]%.so*}.so.1 # soname not in .manifest + + printf -v m[1] %o $((m[1] | 0200)) # 444->644 + insopts -m${m[1]} + insinto ${into} + doins ${m[0]} + done < .manifest || die + insopts -m0644 # reset + + # MODULE:installer non-skipped extras + : "$(systemd_get_sleepdir)" + exeinto "${_#"${EPREFIX}"}" + doexe systemd/system-sleep/nvidia + dobin systemd/nvidia-sleep.sh + systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend}.service + + dobin nvidia-bug-report.sh + + # MODULE:powerd extras + if use powerd; then + newinitd "${FILESDIR}"/nvidia-powerd.initd nvidia-powerd #923117 + systemd_dounit systemd/system/nvidia-powerd.service + + insinto /usr/share/dbus-1/system.d + doins nvidia-dbus.conf + fi + + # enabling is needed for sleep to work properly and little reason not to do + # it unconditionally for a better user experience + : "$(systemd_get_systemunitdir)" + local unitdir=${_#"${EPREFIX}"} + # not using relative symlinks to match systemd's own links + dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-hibernate.service + dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-resume.service + dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-suspend.service + dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-resume.service + # also add a custom elogind hook to do the equivalent of the above + exeinto /usr/lib/elogind/system-sleep + newexe "${FILESDIR}"/system-sleep.elogind nvidia + # /dev/null); do + g=$(grep -io "\"devid\":\"$(<${g%vendor}device)\"[^}]*branch\":\"[0-9]*" \ + "${ED}"/usr/share/nvidia/supported-gpus.json 2>/dev/null) + if [[ ${g} ]]; then + g=$((${g##*\"}+1)) + if ver_test -ge ${g}; then + NV_LEGACY_MASK=">=${CATEGORY}/${PN}-${g}" + break + fi + fi + done + rm "${ED}"/usr/share/nvidia/supported-gpus.json || die +} + +pkg_postinst() { + linux-mod-r1_pkg_postinst + + readme.gentoo_print_elog + + if [[ -r /proc/driver/nvidia/version && + $( ${EROOT}/etc/portage/package.mask/${PN}" + else + ewarn " echo '${NV_LEGACY_MASK}' >> ${EROOT}/etc/portage/package.mask" + fi + ewarn "...then downgrade to a legacy[1] branch if possible (not all old versions" + ewarn "are available or fully functional, may need to consider nouveau[2])." + ewarn "[1] https://www.nvidia.com/object/IO_32667.html" + ewarn "[2] https://wiki.gentoo.org/wiki/Nouveau" + fi + + if use kernel-open; then + ewarn + ewarn "Open source variant of ${PN} was selected, be warned it is experimental" + ewarn "and only for modern GPUs (e.g. GTX 1650+). Try to disable if run into issues." + ewarn "Please also see: ${EROOT}/usr/share/doc/${PF}/html/kernel_open.html" + fi + + if use wayland && use modules && [[ ! -v NV_HAD_WAYLAND ]]; then + elog + elog "With USE=wayland, this version of ${PN} sets nvidia-drm.modeset=1" + elog "in '${EROOT}/etc/modprobe.d/nvidia.conf'. This feature is considered" + elog "experimental but is required for wayland." + elog + elog "If you experience issues, either disable wayland or edit nvidia.conf." + elog "Of note, may possibly cause issues with SLI and Reverse PRIME." + fi + + # these can be removed after some time, only to help the transition + # given users are unlikely to do further custom solutions if it works + # (see also https://github.com/elogind/elogind/issues/272) + if grep -riq "^[^#]*HandleNvidiaSleep=yes" "${EROOT}"/etc/elogind/sleep.conf.d/ 2>/dev/null + then + ewarn + ewarn "!!! WARNING !!!" + ewarn "Detected HandleNvidiaSleep=yes in ${EROOT}/etc/elogind/sleep.conf.d/." + ewarn "This 'could' cause issues if used in combination with the new hook" + ewarn "installed by the ebuild to handle sleep using the official upstream" + ewarn "script. It is recommended to disable the option." + fi + if [[ $(realpath "${EROOT}"{/etc,{/usr,}/lib*}/elogind/system-sleep | sort | uniq | \ + xargs -d'\n' grep -Ril nvidia 2>/dev/null | wc -l) -gt 2 ]] + then + ewarn + ewarn "!!! WARNING !!!" + ewarn "Detected a custom script at ${EROOT}{/etc,{/usr,}/lib*}/elogind/system-sleep" + ewarn "referencing NVIDIA. This version of ${PN} has installed its own" + ewarn "hook at ${EROOT}/usr/lib/elogind/system-sleep/nvidia and it is recommended" + ewarn "to remove the custom one to avoid potential issues." + ewarn + ewarn "Feel free to ignore this warning if you know the other NVIDIA-related" + ewarn "scripts can be used together. The warning will be removed in the future." + fi + if [[ ${REPLACING_VERSIONS##* } ]] && + ver_test ${REPLACING_VERSIONS##* } -lt 525.147.05-r1 # may get repeated + then + elog + elog "For suspend/sleep, 'NVreg_PreserveVideoMemoryAllocations=1' is now default" + elog "with this version of ${PN}. This is recommended (or required) by" + elog "major DEs especially with wayland but, *if* experience regressions with" + elog "suspend, try reverting to =0 in '${EROOT}/etc/modprobe.d/nvidia.conf'." + elog + elog "May notably be an issue when using neither systemd nor elogind to suspend." + elog + elog "Also, the systemd suspend/hibernate/resume services are now enabled by" + elog "default, and for openrc+elogind a similar hook has been installed." + fi +} diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-525.147.05.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-525.147.05.ebuild deleted file mode 100644 index 69c715a9288b..000000000000 --- a/x11-drivers/nvidia-drivers/nvidia-drivers-525.147.05.ebuild +++ /dev/null @@ -1,521 +0,0 @@ -# Copyright 1999-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -MODULES_OPTIONAL_IUSE=+modules -inherit desktop flag-o-matic linux-mod-r1 multilib readme.gentoo-r1 -inherit systemd toolchain-funcs unpacker user-info - -MODULES_KERNEL_MAX=6.7 # 6.6 for arm64 (see below) -NV_URI="https://download.nvidia.com/XFree86/" - -DESCRIPTION="NVIDIA Accelerated Graphics Driver" -HOMEPAGE="https://www.nvidia.com/download/index.aspx" -SRC_URI=" - amd64? ( ${NV_URI}Linux-x86_64/${PV}/NVIDIA-Linux-x86_64-${PV}.run ) - arm64? ( ${NV_URI}Linux-aarch64/${PV}/NVIDIA-Linux-aarch64-${PV}.run ) - $(printf "${NV_URI}%s/%s-${PV}.tar.bz2 " \ - nvidia-{installer,modprobe,persistenced,settings,xconfig}{,}) - ${NV_URI}NVIDIA-kernel-module-source/NVIDIA-kernel-module-source-${PV}.tar.xz -" -# nvidia-installer is unused but here for GPL-2's "distribute sources" -S=${WORKDIR} - -LICENSE="NVIDIA-r2 BSD BSD-2 GPL-2 MIT ZLIB curl openssl" -SLOT="0/${PV%%.*}" -KEYWORDS="-* amd64 ~arm64" -IUSE="+X abi_x86_32 abi_x86_64 kernel-open persistenced powerd +static-libs +tools wayland" -REQUIRED_USE="kernel-open? ( modules )" - -COMMON_DEPEND=" - acct-group/video - X? ( x11-libs/libpciaccess ) - persistenced? ( - acct-user/nvpd - net-libs/libtirpc:= - ) - tools? ( - >=app-accessibility/at-spi2-core-2.46:2 - dev-libs/glib:2 - dev-libs/jansson:= - media-libs/harfbuzz:= - x11-libs/cairo - x11-libs/gdk-pixbuf:2 - x11-libs/gtk+:3[X] - x11-libs/libX11 - x11-libs/libXext - x11-libs/libXxf86vm - x11-libs/pango - ) -" -RDEPEND=" - ${COMMON_DEPEND} - sys-libs/glibc - X? ( - media-libs/libglvnd[X,abi_x86_32(-)?] - x11-libs/libX11[abi_x86_32(-)?] - x11-libs/libXext[abi_x86_32(-)?] - ) - powerd? ( sys-apps/dbus[abi_x86_32(-)?] ) - wayland? ( - gui-libs/egl-gbm - >=gui-libs/egl-wayland-1.1.10 - media-libs/libglvnd - ) -" -DEPEND=" - ${COMMON_DEPEND} - static-libs? ( - x11-base/xorg-proto - x11-libs/libX11 - x11-libs/libXext - ) - tools? ( - media-libs/libglvnd - sys-apps/dbus - x11-base/xorg-proto - x11-libs/libXrandr - x11-libs/libXv - x11-libs/libvdpau - ) -" -BDEPEND=" - sys-devel/m4 - virtual/pkgconfig -" - -QA_PREBUILT="lib/firmware/* opt/bin/* usr/lib*" - -PATCHES=( - "${FILESDIR}"/nvidia-drivers-470.223.02-gpl-pfn_valid.patch - "${FILESDIR}"/nvidia-drivers-525.116.04-clang-unused-option.patch - "${FILESDIR}"/nvidia-drivers-525.147.05-gcc14.patch - "${FILESDIR}"/nvidia-kernel-module-source-515.86.01-raw-ldflags.patch - "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch - "${FILESDIR}"/nvidia-settings-390.144-desktop.patch - "${FILESDIR}"/nvidia-settings-390.144-raw-ldflags.patch -) - -pkg_setup() { - use modules && [[ ${MERGE_TYPE} != binary ]] || return - - local CONFIG_CHECK=" - PROC_FS - ~DRM_KMS_HELPER - ~SYSVIPC - ~!LOCKDEP - ~!SLUB_DEBUG_ON - !DEBUG_MUTEXES - $(usev powerd '~CPU_FREQ') - " - - local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but needed for Xorg auto-detection - of drivers (no custom config), and for wayland / nvidia-drm.modeset=1. - Cannot be directly selected in the kernel's menuconfig, and may need - selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or - DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in." - - local ERROR_X86_KERNEL_IBT="CONFIG_X86_KERNEL_IBT: is set and, if the CPU supports the feature, - this *could* lead to modules load failure with ENDBR errors, or to - broken CUDA/NVENC. Please ignore if not having issues, but otherwise - try to unset or pass ibt=off to the kernel's command line." #911142 - use kernel-open || CONFIG_CHECK+=" ~!X86_KERNEL_IBT" - - use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764 - - use kernel-open && CONFIG_CHECK+=" MMU_NOTIFIER" #843827 - local ERROR_MMU_NOTIFIER="CONFIG_MMU_NOTIFIER: is not set but needed to build with USE=kernel-open. - Cannot be directly selected in the kernel's menuconfig, and may need - selection of another option that requires it such as CONFIG_KVM." - - # screen_info is marked GPL on non-x86 in 6.7 and cannot be used - # (patchable, but just avoid advertising compatibility for now) - # https://forums.developer.nvidia.com/t/278367 - use arm64 && MODULES_KERNEL_MAX=6.6 - - linux-mod-r1_pkg_setup -} - -src_prepare() { - # make patches usable across versions - rm nvidia-modprobe && mv nvidia-modprobe{-${PV},} || die - rm nvidia-persistenced && mv nvidia-persistenced{-${PV},} || die - rm nvidia-settings && mv nvidia-settings{-${PV},} || die - rm nvidia-xconfig && mv nvidia-xconfig{-${PV},} || die - mv NVIDIA-kernel-module-source-${PV} kernel-module-source || die - - default - - # prevent detection of incomplete kernel DRM support (bug #603818) - sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \ - -i kernel{,-module-source/kernel-open}/conftest.sh || die - - # adjust service files - sed 's/__USER__/nvpd/' \ - nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \ - > "${T}"/nvidia-persistenced.service || die - use !powerd || # file is missing on arm64 (masked) - sed -i "s|/usr|${EPREFIX}/opt|" systemd/system/nvidia-powerd.service || die - - # use alternative vulkan icd option if USE=-X (bug #909181) - use X || sed -i 's/"libGLX/"libEGL/' nvidia_{layers,icd}.json || die - - # enable nvidia-drm.modeset=1 by default with USE=wayland - cp "${FILESDIR}"/nvidia-470.conf "${T}"/nvidia.conf || die - use !wayland || sed -i '/^#.*modeset=1$/s/^#//' "${T}"/nvidia.conf || die - - # makefile attempts to install wayland library even if not built - use wayland || sed -i 's/ WAYLAND_LIB_install$//' \ - nvidia-settings/src/Makefile || die - - # temporary option, nvidia will remove in the future - use !kernel-open || - sed -i '/blacklist/a\ -\ -# Enable using kernel-open with workstation GPUs (experimental)\ -options nvidia NVreg_OpenRmEnableUnsupportedGpus=1' "${T}"/nvidia.conf || die -} - -src_compile() { - tc-export AR CC CXX LD OBJCOPY OBJDUMP PKG_CONFIG - local -x RAW_LDFLAGS="$(get_abi_LDFLAGS) $(raw-ldflags)" # raw-ldflags.patch - - local xnvflags=-fPIC #840389 - # lto static libraries tend to cause problems without fat objects - tc-is-lto && xnvflags+=" $(test-flags-CC -ffat-lto-objects)" - - NV_ARGS=( - PREFIX="${EPREFIX}"/usr - HOST_CC="$(tc-getBUILD_CC)" - HOST_LD="$(tc-getBUILD_LD)" - BUILD_GTK2LIB= - NV_USE_BUNDLED_LIBJANSSON=0 - NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out - WAYLAND_AVAILABLE=$(usex wayland 1 0) - XNVCTRL_CFLAGS="${xnvflags}" - ) - - if use modules; then - local o_cflags=${CFLAGS} o_cxxflags=${CXXFLAGS} o_ldflags=${LDFLAGS} - - local modlistargs=video:kernel - if use kernel-open; then - modlistargs+=-module-source:kernel-module-source/kernel-open - - # environment flags are normally unused for modules, but nvidia - # uses it for building the "blob" and it is a bit fragile - filter-flags -fno-plt #912949 - filter-lto - CC=${KERNEL_CC} CXX=${KERNEL_CXX} strip-unsupported-flags - fi - - local modlist=( nvidia{,-drm,-modeset,-peermem,-uvm}=${modlistargs} ) - local modargs=( - IGNORE_CC_MISMATCH=yes NV_VERBOSE=1 - SYSOUT="${KV_OUT_DIR}" SYSSRC="${KV_DIR}" - ) - - # temporary workaround for bug #914468 - CPP="${KERNEL_CC} -E" tc-is-clang && addpredict "${KV_OUT_DIR}" - - linux-mod-r1_src_compile - CFLAGS=${o_cflags} CXXFLAGS=${o_cxxflags} LDFLAGS=${o_ldflags} - fi - - emake "${NV_ARGS[@]}" -C nvidia-modprobe - use persistenced && emake "${NV_ARGS[@]}" -C nvidia-persistenced - use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig - - if use tools; then - # avoid noisy *very* noisy logs with deprecation warnings - CFLAGS="-Wno-deprecated-declarations ${CFLAGS}" \ - emake "${NV_ARGS[@]}" -C nvidia-settings - elif use static-libs; then - # pretend GTK+3 is available, not actually used (bug #880879) - emake "${NV_ARGS[@]}" BUILD_GTK3LIB=1 \ - -C nvidia-settings/src out/libXNVCtrl.a - fi -} - -src_install() { - local libdir=$(get_libdir) libdir32=$(ABI=x86 get_libdir) - - NV_ARGS+=( DESTDIR="${D}" LIBDIR="${ED}"/usr/${libdir} ) - - local -A paths=( - [APPLICATION_PROFILE]=/usr/share/nvidia - [CUDA_ICD]=/etc/OpenCL/vendors - [EGL_EXTERNAL_PLATFORM_JSON]=/usr/share/egl/egl_external_platform.d - [FIRMWARE]=/lib/firmware/nvidia/${PV} - [GBM_BACKEND_LIB_SYMLINK]=/usr/${libdir}/gbm - [GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d - [VULKAN_ICD_JSON]=/usr/share/vulkan - [WINE_LIB]=/usr/${libdir}/nvidia/wine - [XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d - - [GLX_MODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules/extensions - [GLX_MODULE_SYMLINK]=/usr/${libdir}/xorg/modules - [XMODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules - ) - - local skip_files=( - $(usev !X "libGLX_nvidia libglxserver_nvidia") - $(usev !wayland libnvidia-vulkan-producer) - libGLX_indirect # non-glvnd unused fallback - libnvidia-{gtk,wayland-client} nvidia-{settings,xconfig} # from source - libnvidia-egl-gbm 15_nvidia_gbm # gui-libs/egl-gbm - libnvidia-egl-wayland 10_nvidia_wayland # gui-libs/egl-wayland - ) - local skip_modules=( - $(usev !X "nvfbc vdpau xdriver") - $(usev !modules gsp) - $(usev !powerd powerd) - installer nvpd # handled separately / built from source - ) - local skip_types=( - GLVND_LIB GLVND_SYMLINK EGL_CLIENT.\* GLX_CLIENT.\* # media-libs/libglvnd - OPENCL_WRAPPER.\* # virtual/opencl - DOCUMENTATION DOT_DESKTOP .\*_SRC DKMS_CONF SYSTEMD_UNIT # handled separately / unused - ) - - local DOCS=( - README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json - nvidia-settings/doc/{FRAMELOCK,NV-CONTROL-API}.txt - ) - local HTML_DOCS=( html/. ) - einstalldocs - - local DISABLE_AUTOFORMATTING=yes - local DOC_CONTENTS="\ -Trusted users should be in the 'video' group to use NVIDIA devices. -You can add yourself by using: gpasswd -a my-user video\ -$(usev modules " - -Like all out-of-tree kernel modules, it is necessary to rebuild -${PN} after upgrading or rebuilding the Linux kernel -by for example running \`emerge @module-rebuild\`. Alternatively, -if using a distribution kernel (sys-kernel/gentoo-kernel{,-bin}), -this can be automated by setting USE=dist-kernel globally. - -Loaded kernel modules also must not mismatch with the installed -${PN} version (excluding -r revision), meaning should -ensure \`eselect kernel list\` points to the kernel that will be -booted before building and preferably reboot after upgrading -${PN} (the ebuild will emit a warning if mismatching). - -See '${EPREFIX}/etc/modprobe.d/nvidia.conf' for modules options.")\ -$(use amd64 && usev !abi_x86_32 " - -Note that without USE=abi_x86_32 on ${PN}, 32bit applications -(typically using wine / steam) will not be able to use GPU acceleration.") - -For additional information or for troubleshooting issues, please see -https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own -documentation that is installed alongside this README." - readme.gentoo_create_doc - - if use modules; then - linux-mod-r1_src_install - - insinto /etc/modprobe.d - doins "${T}"/nvidia.conf - - # used for gpu verification with binpkgs (not kept, see pkg_preinst) - insinto /usr/share/nvidia - doins supported-gpus/supported-gpus.json - fi - - emake "${NV_ARGS[@]}" -C nvidia-modprobe install - fowners :video /usr/bin/nvidia-modprobe #505092 - fperms 4710 /usr/bin/nvidia-modprobe - - if use persistenced; then - emake "${NV_ARGS[@]}" -C nvidia-persistenced install - newconfd "${FILESDIR}"/nvidia-persistenced.confd nvidia-persistenced - newinitd "${FILESDIR}"/nvidia-persistenced.initd nvidia-persistenced - systemd_dounit "${T}"/nvidia-persistenced.service - fi - - if use tools; then - emake "${NV_ARGS[@]}" -C nvidia-settings install - - doicon nvidia-settings/doc/nvidia-settings.png - domenu nvidia-settings/doc/nvidia-settings.desktop - - exeinto /etc/X11/xinit/xinitrc.d - newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings - fi - - if use static-libs; then - dolib.a nvidia-settings/src/out/libXNVCtrl.a - - insinto /usr/include/NVCtrl - doins nvidia-settings/src/libXNVCtrl/NVCtrl{Lib,}.h - fi - - use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig install - - # mimic nvidia-installer by reading .manifest to install files - # 0:file 1:perms 2:type 3+:subtype/arguments -:module - local m into - while IFS=' ' read -ra m; do - ! [[ ${#m[@]} -ge 2 && ${m[-1]} =~ MODULE: ]] || - [[ " ${m[0]##*/}" =~ ^(\ ${skip_files[*]/%/.*|\\} )$ ]] || - [[ " ${m[2]}" =~ ^(\ ${skip_types[*]/%/|\\} )$ ]] || - has ${m[-1]#MODULE:} "${skip_modules[@]}" && continue - - case ${m[2]} in - MANPAGE) - gzip -dc ${m[0]} | newman - ${m[0]%.gz}; assert - continue - ;; - GBM_BACKEND_LIB_SYMLINK) m[4]=../${m[4]};; # missing ../ - VDPAU_SYMLINK) m[4]=vdpau/; m[5]=${m[5]#vdpau/};; # .so to vdpau/ - esac - - if [[ -v 'paths[${m[2]}]' ]]; then - into=${paths[${m[2]}]} - elif [[ ${m[2]} == *_BINARY ]]; then - into=/opt/bin - elif [[ ${m[3]} == COMPAT32 ]]; then - use abi_x86_32 || continue - into=/usr/${libdir32} - elif [[ ${m[2]} == *_@(LIB|SYMLINK) ]]; then - into=/usr/${libdir} - else - die "No known installation path for ${m[0]}" - fi - [[ ${m[3]: -2} == ?/ ]] && into+=/${m[3]%/} - [[ ${m[4]: -2} == ?/ ]] && into+=/${m[4]%/} - - if [[ ${m[2]} =~ _SYMLINK$ ]]; then - [[ ${m[4]: -1} == / ]] && m[4]=${m[5]} - dosym ${m[4]} ${into}/${m[0]} - continue - fi - [[ ${m[0]} =~ ^libnvidia-ngx.so|^libnvidia-egl-gbm.so ]] && - dosym ${m[0]} ${into}/${m[0]%.so*}.so.1 # soname not in .manifest - - printf -v m[1] %o $((m[1] | 0200)) # 444->644 - insopts -m${m[1]} - insinto ${into} - doins ${m[0]} - done < .manifest || die - insopts -m0644 # reset - - # MODULE:installer non-skipped extras - : "$(systemd_get_sleepdir)" - exeinto "${_#"${EPREFIX}"}" - doexe systemd/system-sleep/nvidia - dobin systemd/nvidia-sleep.sh - systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend}.service - - dobin nvidia-bug-report.sh - - # MODULE:powerd extras - if use powerd; then - newinitd "${FILESDIR}"/nvidia-powerd.initd nvidia-powerd #923117 - systemd_dounit systemd/system/nvidia-powerd.service - - insinto /usr/share/dbus-1/system.d - doins nvidia-dbus.conf - fi - - # symlink non-versioned so nvidia-settings can use it even if misdetected - dosym nvidia-application-profiles-${PV}-key-documentation \ - ${paths[APPLICATION_PROFILE]}/nvidia-application-profiles-key-documentation - - # don't attempt to strip firmware files (silences errors) - dostrip -x ${paths[FIRMWARE]} - - # sandbox issues with /dev/nvidiactl (and /dev/char wrt bug #904292) - # are widespread and sometime affect revdeps of packages built with - # USE=opencl/cuda making it hard to manage in ebuilds (minimal set, - # ebuilds should handle manually if need others or addwrite) - insinto /etc/sandbox.d - newins - 20nvidia <<<'SANDBOX_PREDICT="/dev/nvidiactl:/dev/char"' -} - -pkg_preinst() { - has_version "${CATEGORY}/${PN}[wayland]" && NV_HAD_WAYLAND= - - use modules || return - - # set video group id based on live system (bug #491414) - local g=$(egetent group video | cut -d: -f3) - [[ ${g} =~ ^[0-9]+$ ]] || die "Failed to determine video group id (got '${g}')" - sed -i "s/@VIDEOGID@/${g}/" "${ED}"/etc/modprobe.d/nvidia.conf || die - - # try to find driver mismatches using temporary supported-gpus.json - for g in $(grep -l 0x10de /sys/bus/pci/devices/*/vendor 2>/dev/null); do - g=$(grep -io "\"devid\":\"$(<${g%vendor}device)\"[^}]*branch\":\"[0-9]*" \ - "${ED}"/usr/share/nvidia/supported-gpus.json 2>/dev/null) - if [[ ${g} ]]; then - g=$((${g##*\"}+1)) - if ver_test -ge ${g}; then - NV_LEGACY_MASK=">=${CATEGORY}/${PN}-${g}" - break - fi - fi - done - rm "${ED}"/usr/share/nvidia/supported-gpus.json || die -} - -pkg_postinst() { - linux-mod-r1_pkg_postinst - - readme.gentoo_print_elog - - if [[ -r /proc/driver/nvidia/version && - $( ${EROOT}/etc/portage/package.mask/${PN}" - else - ewarn " echo '${NV_LEGACY_MASK}' >> ${EROOT}/etc/portage/package.mask" - fi - ewarn "...then downgrade to a legacy[1] branch if possible (not all old versions" - ewarn "are available or fully functional, may need to consider nouveau[2])." - ewarn "[1] https://www.nvidia.com/object/IO_32667.html" - ewarn "[2] https://wiki.gentoo.org/wiki/Nouveau" - fi - - if use kernel-open; then - ewarn - ewarn "Open source variant of ${PN} was selected, be warned it is experimental" - ewarn "and only for modern GPUs (e.g. GTX 1650+). Try to disable if run into issues." - ewarn "Please also see: ${EROOT}/usr/share/doc/${PF}/html/kernel_open.html" - fi - - if use wayland && use modules && [[ ! -v NV_HAD_WAYLAND ]]; then - elog - elog "With USE=wayland, this version of ${PN} sets nvidia-drm.modeset=1" - elog "in '${EROOT}/etc/modprobe.d/nvidia.conf'. This feature is considered" - elog "experimental but is required for wayland." - elog - elog "If you experience issues, either disable wayland or edit nvidia.conf." - elog "Of note, may possibly cause issues with SLI and Reverse PRIME." - fi -} diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-535.183.01-r1.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-535.183.01-r1.ebuild new file mode 100644 index 000000000000..340237b6525e --- /dev/null +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-535.183.01-r1.ebuild @@ -0,0 +1,577 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +MODULES_OPTIONAL_IUSE=+modules +inherit desktop flag-o-matic linux-mod-r1 multilib readme.gentoo-r1 +inherit systemd toolchain-funcs unpacker user-info + +MODULES_KERNEL_MAX=6.9 +NV_URI="https://download.nvidia.com/XFree86/" + +DESCRIPTION="NVIDIA Accelerated Graphics Driver" +HOMEPAGE="https://www.nvidia.com/download/index.aspx" +SRC_URI=" + amd64? ( ${NV_URI}Linux-x86_64/${PV}/NVIDIA-Linux-x86_64-${PV}.run ) + arm64? ( ${NV_URI}Linux-aarch64/${PV}/NVIDIA-Linux-aarch64-${PV}.run ) + $(printf "${NV_URI}%s/%s-${PV}.tar.bz2 " \ + nvidia-{installer,modprobe,persistenced,settings,xconfig}{,}) + ${NV_URI}NVIDIA-kernel-module-source/NVIDIA-kernel-module-source-${PV}.tar.xz +" +# nvidia-installer is unused but here for GPL-2's "distribute sources" +S=${WORKDIR} + +LICENSE="NVIDIA-r2 Apache-2.0 BSD BSD-2 GPL-2 MIT ZLIB curl openssl" +SLOT="0/${PV%%.*}" +KEYWORDS="-* amd64 ~arm64" +IUSE="+X abi_x86_32 abi_x86_64 kernel-open persistenced powerd +static-libs +tools wayland" +REQUIRED_USE="kernel-open? ( modules )" + +COMMON_DEPEND=" + acct-group/video + X? ( x11-libs/libpciaccess ) + persistenced? ( + acct-user/nvpd + net-libs/libtirpc:= + ) + tools? ( + >=app-accessibility/at-spi2-core-2.46:2 + dev-libs/glib:2 + dev-libs/jansson:= + media-libs/harfbuzz:= + x11-libs/cairo + x11-libs/gdk-pixbuf:2 + x11-libs/gtk+:3[X] + x11-libs/libX11 + x11-libs/libXext + x11-libs/libXxf86vm + x11-libs/pango + ) +" +RDEPEND=" + ${COMMON_DEPEND} + dev-libs/openssl:0/3 + sys-libs/glibc + X? ( + media-libs/libglvnd[X,abi_x86_32(-)?] + x11-libs/libX11[abi_x86_32(-)?] + x11-libs/libXext[abi_x86_32(-)?] + ) + powerd? ( sys-apps/dbus[abi_x86_32(-)?] ) + wayland? ( + gui-libs/egl-gbm + >=gui-libs/egl-wayland-1.1.10 + media-libs/libglvnd + ) +" +DEPEND=" + ${COMMON_DEPEND} + static-libs? ( + x11-base/xorg-proto + x11-libs/libX11 + x11-libs/libXext + ) + tools? ( + media-libs/libglvnd + sys-apps/dbus + x11-base/xorg-proto + x11-libs/libXrandr + x11-libs/libXv + x11-libs/libvdpau + ) +" +BDEPEND=" + sys-devel/m4 + virtual/pkgconfig +" + +QA_PREBUILT="lib/firmware/* opt/bin/* usr/lib*" + +PATCHES=( + "${FILESDIR}"/nvidia-kernel-module-source-515.86.01-raw-ldflags.patch + "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch + "${FILESDIR}"/nvidia-settings-390.144-raw-ldflags.patch + "${FILESDIR}"/nvidia-settings-530.30.02-desktop.patch +) + +pkg_setup() { + use modules && [[ ${MERGE_TYPE} != binary ]] || return + + local CONFIG_CHECK=" + PROC_FS + ~DRM_KMS_HELPER + ~SYSVIPC + ~!LOCKDEP + ~!SLUB_DEBUG_ON + !DEBUG_MUTEXES + $(usev powerd '~CPU_FREQ') + " + + local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but needed for Xorg auto-detection + of drivers (no custom config), and for wayland / nvidia-drm.modeset=1. + Cannot be directly selected in the kernel's menuconfig, and may need + selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or + DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in." + + local ERROR_X86_KERNEL_IBT="CONFIG_X86_KERNEL_IBT: is set and, if the CPU supports the feature, + this *could* lead to modules load failure with ENDBR errors, or to + broken CUDA/NVENC. Please ignore if not having issues, but otherwise + try to unset or pass ibt=off to the kernel's command line." #911142 + use kernel-open || CONFIG_CHECK+=" ~!X86_KERNEL_IBT" + + use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764 + + use kernel-open && CONFIG_CHECK+=" MMU_NOTIFIER" #843827 + local ERROR_MMU_NOTIFIER="CONFIG_MMU_NOTIFIER: is not set but needed to build with USE=kernel-open. + Cannot be directly selected in the kernel's menuconfig, and may need + selection of another option that requires it such as CONFIG_KVM." + + linux-mod-r1_pkg_setup +} + +src_prepare() { + # make patches usable across versions + rm nvidia-modprobe && mv nvidia-modprobe{-${PV},} || die + rm nvidia-persistenced && mv nvidia-persistenced{-${PV},} || die + rm nvidia-settings && mv nvidia-settings{-${PV},} || die + rm nvidia-xconfig && mv nvidia-xconfig{-${PV},} || die + mv NVIDIA-kernel-module-source-${PV} kernel-module-source || die + + default + + kernel_is -ge 6 7 && + eapply "${FILESDIR}"/nvidia-drivers-535.43.22-kernel-6.7.patch + + # prevent detection of incomplete kernel DRM support (bug #603818) + sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \ + -i kernel{,-module-source/kernel-open}/conftest.sh || die + + # adjust service files + sed 's/__USER__/nvpd/' \ + nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \ + > "${T}"/nvidia-persistenced.service || die + use !powerd || # file is missing on arm64 (masked) + sed -i "s|/usr|${EPREFIX}/opt|" systemd/system/nvidia-powerd.service || die + + # use alternative vulkan icd option if USE=-X (bug #909181) + use X || sed -i 's/"libGLX/"libEGL/' nvidia_{layers,icd}.json || die + + # enable nvidia-drm.modeset=1 by default with USE=wayland + cp "${FILESDIR}"/nvidia-470.conf "${T}"/nvidia.conf || die + use !wayland || sed -i '/^#.*modeset=1$/s/^#//' "${T}"/nvidia.conf || die + + # makefile attempts to install wayland library even if not built + use wayland || sed -i 's/ WAYLAND_LIB_install$//' \ + nvidia-settings/src/Makefile || die + + # temporary option, nvidia will remove in the future + use !kernel-open || + sed -i '/blacklist/a\ +\ +# Enable using kernel-open with workstation GPUs (experimental)\ +options nvidia NVreg_OpenRmEnableUnsupportedGpus=1' "${T}"/nvidia.conf || die +} + +src_compile() { + tc-export AR CC CXX LD OBJCOPY OBJDUMP PKG_CONFIG + local -x RAW_LDFLAGS="$(get_abi_LDFLAGS) $(raw-ldflags)" # raw-ldflags.patch + + local xnvflags=-fPIC #840389 + # lto static libraries tend to cause problems without fat objects + tc-is-lto && xnvflags+=" $(test-flags-CC -ffat-lto-objects)" + + NV_ARGS=( + PREFIX="${EPREFIX}"/usr + HOST_CC="$(tc-getBUILD_CC)" + HOST_LD="$(tc-getBUILD_LD)" + BUILD_GTK2LIB= + NV_USE_BUNDLED_LIBJANSSON=0 + NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out + WAYLAND_AVAILABLE=$(usex wayland 1 0) + XNVCTRL_CFLAGS="${xnvflags}" + ) + + if use modules; then + local o_cflags=${CFLAGS} o_cxxflags=${CXXFLAGS} o_ldflags=${LDFLAGS} + + local modlistargs=video:kernel + if use kernel-open; then + modlistargs+=-module-source:kernel-module-source/kernel-open + + # environment flags are normally unused for modules, but nvidia + # uses it for building the "blob" and it is a bit fragile + filter-flags -fno-plt #912949 + filter-lto + CC=${KERNEL_CC} CXX=${KERNEL_CXX} strip-unsupported-flags + fi + + local modlist=( nvidia{,-drm,-modeset,-peermem,-uvm}=${modlistargs} ) + local modargs=( + IGNORE_CC_MISMATCH=yes NV_VERBOSE=1 + SYSOUT="${KV_OUT_DIR}" SYSSRC="${KV_DIR}" + ) + + # temporary workaround for bug #914468 + CPP="${KERNEL_CC} -E" tc-is-clang && addpredict "${KV_OUT_DIR}" + + linux-mod-r1_src_compile + CFLAGS=${o_cflags} CXXFLAGS=${o_cxxflags} LDFLAGS=${o_ldflags} + fi + + emake "${NV_ARGS[@]}" -C nvidia-modprobe + use persistenced && emake "${NV_ARGS[@]}" -C nvidia-persistenced + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig + + if use tools; then + # avoid noisy *very* noisy logs with deprecation warnings + CFLAGS="-Wno-deprecated-declarations ${CFLAGS}" \ + emake "${NV_ARGS[@]}" -C nvidia-settings + elif use static-libs; then + # pretend GTK+3 is available, not actually used (bug #880879) + emake "${NV_ARGS[@]}" BUILD_GTK3LIB=1 \ + -C nvidia-settings/src out/libXNVCtrl.a + fi +} + +src_install() { + local libdir=$(get_libdir) libdir32=$(ABI=x86 get_libdir) + + NV_ARGS+=( DESTDIR="${D}" LIBDIR="${ED}"/usr/${libdir} ) + + local -A paths=( + [APPLICATION_PROFILE]=/usr/share/nvidia + [CUDA_ICD]=/etc/OpenCL/vendors + [EGL_EXTERNAL_PLATFORM_JSON]=/usr/share/egl/egl_external_platform.d + [FIRMWARE]=/lib/firmware/nvidia/${PV} + [GBM_BACKEND_LIB_SYMLINK]=/usr/${libdir}/gbm + [GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d + [OPENGL_DATA]=/usr/share/nvidia + [VULKAN_ICD_JSON]=/usr/share/vulkan + [WINE_LIB]=/usr/${libdir}/nvidia/wine + [XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d + + [GLX_MODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules/extensions + [GLX_MODULE_SYMLINK]=/usr/${libdir}/xorg/modules + [XMODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules + ) + + local skip_files=( + $(usev !X "libGLX_nvidia libglxserver_nvidia") + $(usev !wayland libnvidia-vulkan-producer) + libGLX_indirect # non-glvnd unused fallback + libnvidia-{gtk,wayland-client} nvidia-{settings,xconfig} # from source + libnvidia-egl-gbm 15_nvidia_gbm # gui-libs/egl-gbm + libnvidia-egl-wayland 10_nvidia_wayland # gui-libs/egl-wayland + libnvidia-pkcs11.so # using the openssl3 version instead + ) + local skip_modules=( + $(usev !X "nvfbc vdpau xdriver") + $(usev !modules gsp) + $(usev !powerd powerd) + installer nvpd # handled separately / built from source + ) + local skip_types=( + GLVND_LIB GLVND_SYMLINK EGL_CLIENT.\* GLX_CLIENT.\* # media-libs/libglvnd + OPENCL_WRAPPER.\* # virtual/opencl + DOCUMENTATION DOT_DESKTOP .\*_SRC DKMS_CONF SYSTEMD_UNIT # handled separately / unused + ) + + local DOCS=( + README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json + nvidia-settings/doc/{FRAMELOCK,NV-CONTROL-API}.txt + ) + local HTML_DOCS=( html/. ) + einstalldocs + + local DISABLE_AUTOFORMATTING=yes + local DOC_CONTENTS="\ +Trusted users should be in the 'video' group to use NVIDIA devices. +You can add yourself by using: gpasswd -a my-user video\ +$(usev modules " + +Like all out-of-tree kernel modules, it is necessary to rebuild +${PN} after upgrading or rebuilding the Linux kernel +by for example running \`emerge @module-rebuild\`. Alternatively, +if using a distribution kernel (sys-kernel/gentoo-kernel{,-bin}), +this can be automated by setting USE=dist-kernel globally. + +Loaded kernel modules also must not mismatch with the installed +${PN} version (excluding -r revision), meaning should +ensure \`eselect kernel list\` points to the kernel that will be +booted before building and preferably reboot after upgrading +${PN} (the ebuild will emit a warning if mismatching). + +See '${EPREFIX}/etc/modprobe.d/nvidia.conf' for modules options.")\ +$(use amd64 && usev !abi_x86_32 " + +Note that without USE=abi_x86_32 on ${PN}, 32bit applications +(typically using wine / steam) will not be able to use GPU acceleration.") + +For additional information or for troubleshooting issues, please see +https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own +documentation that is installed alongside this README." + readme.gentoo_create_doc + + if use modules; then + linux-mod-r1_src_install + + insinto /etc/modprobe.d + doins "${T}"/nvidia.conf + + # used for gpu verification with binpkgs (not kept, see pkg_preinst) + insinto /usr/share/nvidia + doins supported-gpus/supported-gpus.json + fi + + emake "${NV_ARGS[@]}" -C nvidia-modprobe install + fowners :video /usr/bin/nvidia-modprobe #505092 + fperms 4710 /usr/bin/nvidia-modprobe + + if use persistenced; then + emake "${NV_ARGS[@]}" -C nvidia-persistenced install + newconfd "${FILESDIR}"/nvidia-persistenced.confd nvidia-persistenced + newinitd "${FILESDIR}"/nvidia-persistenced.initd nvidia-persistenced + systemd_dounit "${T}"/nvidia-persistenced.service + fi + + if use tools; then + emake "${NV_ARGS[@]}" -C nvidia-settings install + + doicon nvidia-settings/doc/nvidia-settings.png + domenu nvidia-settings/doc/nvidia-settings.desktop + + exeinto /etc/X11/xinit/xinitrc.d + newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings + fi + + if use static-libs; then + dolib.a nvidia-settings/src/out/libXNVCtrl.a + + insinto /usr/include/NVCtrl + doins nvidia-settings/src/libXNVCtrl/NVCtrl{Lib,}.h + fi + + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig install + + # mimic nvidia-installer by reading .manifest to install files + # 0:file 1:perms 2:type 3+:subtype/arguments -:module + local m into + while IFS=' ' read -ra m; do + ! [[ ${#m[@]} -ge 2 && ${m[-1]} =~ MODULE: ]] || + [[ " ${m[0]##*/}" =~ ^(\ ${skip_files[*]/%/.*|\\} )$ ]] || + [[ " ${m[2]}" =~ ^(\ ${skip_types[*]/%/|\\} )$ ]] || + has ${m[-1]#MODULE:} "${skip_modules[@]}" && continue + + case ${m[2]} in + MANPAGE) + gzip -dc ${m[0]} | newman - ${m[0]%.gz}; assert + continue + ;; + GBM_BACKEND_LIB_SYMLINK) m[4]=../${m[4]};; # missing ../ + VDPAU_SYMLINK) m[4]=vdpau/; m[5]=${m[5]#vdpau/};; # .so to vdpau/ + esac + + if [[ -v 'paths[${m[2]}]' ]]; then + into=${paths[${m[2]}]} + elif [[ ${m[2]} == EXPLICIT_PATH ]]; then + into=${m[3]} + elif [[ ${m[2]} == *_BINARY ]]; then + into=/opt/bin + elif [[ ${m[3]} == COMPAT32 ]]; then + use abi_x86_32 || continue + into=/usr/${libdir32} + elif [[ ${m[2]} == *_@(LIB|SYMLINK) ]]; then + into=/usr/${libdir} + else + die "No known installation path for ${m[0]}" + fi + [[ ${m[3]: -2} == ?/ ]] && into+=/${m[3]%/} + [[ ${m[4]: -2} == ?/ ]] && into+=/${m[4]%/} + + if [[ ${m[2]} =~ _SYMLINK$ ]]; then + [[ ${m[4]: -1} == / ]] && m[4]=${m[5]} + dosym ${m[4]} ${into}/${m[0]} + continue + fi + [[ ${m[0]} =~ ^libnvidia-ngx.so|^libnvidia-egl-gbm.so ]] && + dosym ${m[0]} ${into}/${m[0]%.so*}.so.1 # soname not in .manifest + + printf -v m[1] %o $((m[1] | 0200)) # 444->644 + insopts -m${m[1]} + insinto ${into} + doins ${m[0]} + done < .manifest || die + insopts -m0644 # reset + + # MODULE:installer non-skipped extras + : "$(systemd_get_sleepdir)" + exeinto "${_#"${EPREFIX}"}" + doexe systemd/system-sleep/nvidia + dobin systemd/nvidia-sleep.sh + systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend}.service + + dobin nvidia-bug-report.sh + + # MODULE:powerd extras + if use powerd; then + newinitd "${FILESDIR}"/nvidia-powerd.initd nvidia-powerd #923117 + systemd_dounit systemd/system/nvidia-powerd.service + + insinto /usr/share/dbus-1/system.d + doins nvidia-dbus.conf + fi + + # enabling is needed for sleep to work properly and little reason not to do + # it unconditionally for a better user experience + : "$(systemd_get_systemunitdir)" + local unitdir=${_#"${EPREFIX}"} + # not using relative symlinks to match systemd's own links + dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-hibernate.service + dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-resume.service + dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-suspend.service + dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-resume.service + # also add a custom elogind hook to do the equivalent of the above + exeinto /usr/lib/elogind/system-sleep + newexe "${FILESDIR}"/system-sleep.elogind nvidia + # /dev/null); do + g=$(grep -io "\"devid\":\"$(<${g%vendor}device)\"[^}]*branch\":\"[0-9]*" \ + "${ED}"/usr/share/nvidia/supported-gpus.json 2>/dev/null) + if [[ ${g} ]]; then + g=$((${g##*\"}+1)) + if ver_test -ge ${g}; then + NV_LEGACY_MASK=">=${CATEGORY}/${PN}-${g}" + break + fi + fi + done + rm "${ED}"/usr/share/nvidia/supported-gpus.json || die +} + +pkg_postinst() { + linux-mod-r1_pkg_postinst + + readme.gentoo_print_elog + + if [[ -r /proc/driver/nvidia/version && + $( ${EROOT}/etc/portage/package.mask/${PN}" + else + ewarn " echo '${NV_LEGACY_MASK}' >> ${EROOT}/etc/portage/package.mask" + fi + ewarn "...then downgrade to a legacy[1] branch if possible (not all old versions" + ewarn "are available or fully functional, may need to consider nouveau[2])." + ewarn "[1] https://www.nvidia.com/object/IO_32667.html" + ewarn "[2] https://wiki.gentoo.org/wiki/Nouveau" + fi + + if use kernel-open; then + ewarn + ewarn "Open source variant of ${PN} was selected, be warned it is experimental" + ewarn "and only for modern GPUs (e.g. GTX 1650+). Try to disable if run into issues." + ewarn "Please also see: ${EROOT}/usr/share/doc/${PF}/html/kernel_open.html" + fi + + if use wayland && use modules && [[ ! -v NV_HAD_WAYLAND ]]; then + elog + elog "With USE=wayland, this version of ${PN} sets nvidia-drm.modeset=1" + elog "in '${EROOT}/etc/modprobe.d/nvidia.conf'. This feature is considered" + elog "experimental but is required for wayland." + elog + elog "If you experience issues, either disable wayland or edit nvidia.conf." + elog "Of note, may possibly cause issues with SLI and Reverse PRIME." + fi + + # these can be removed after some time, only to help the transition + # given users are unlikely to do further custom solutions if it works + # (see also https://github.com/elogind/elogind/issues/272) + if grep -riq "^[^#]*HandleNvidiaSleep=yes" "${EROOT}"/etc/elogind/sleep.conf.d/ 2>/dev/null + then + ewarn + ewarn "!!! WARNING !!!" + ewarn "Detected HandleNvidiaSleep=yes in ${EROOT}/etc/elogind/sleep.conf.d/." + ewarn "This 'could' cause issues if used in combination with the new hook" + ewarn "installed by the ebuild to handle sleep using the official upstream" + ewarn "script. It is recommended to disable the option." + fi + if [[ $(realpath "${EROOT}"{/etc,{/usr,}/lib*}/elogind/system-sleep | sort | uniq | \ + xargs -d'\n' grep -Ril nvidia 2>/dev/null | wc -l) -gt 2 ]] + then + ewarn + ewarn "!!! WARNING !!!" + ewarn "Detected a custom script at ${EROOT}{/etc,{/usr,}/lib*}/elogind/system-sleep" + ewarn "referencing NVIDIA. This version of ${PN} has installed its own" + ewarn "hook at ${EROOT}/usr/lib/elogind/system-sleep/nvidia and it is recommended" + ewarn "to remove the custom one to avoid potential issues." + ewarn + ewarn "Feel free to ignore this warning if you know the other NVIDIA-related" + ewarn "scripts can be used together. The warning will be removed in the future." + fi + if [[ ${REPLACING_VERSIONS##* } ]] && + ver_test ${REPLACING_VERSIONS##* } -lt 535.183.01-r1 # may get repeated + then + elog + elog "For suspend/sleep, 'NVreg_PreserveVideoMemoryAllocations=1' is now default" + elog "with this version of ${PN}. This is recommended (or required) by" + elog "major DEs especially with wayland but, *if* experience regressions with" + elog "suspend, try reverting to =0 in '${EROOT}/etc/modprobe.d/nvidia.conf'." + elog + elog "May notably be an issue when using neither systemd nor elogind to suspend." + elog + elog "Also, the systemd suspend/hibernate/resume services are now enabled by" + elog "default, and for openrc+elogind a similar hook has been installed." + fi +} diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-535.183.01.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-535.183.01.ebuild deleted file mode 100644 index b6e7ae3c70c1..000000000000 --- a/x11-drivers/nvidia-drivers/nvidia-drivers-535.183.01.ebuild +++ /dev/null @@ -1,521 +0,0 @@ -# Copyright 1999-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -MODULES_OPTIONAL_IUSE=+modules -inherit desktop flag-o-matic linux-mod-r1 multilib readme.gentoo-r1 -inherit systemd toolchain-funcs unpacker user-info - -MODULES_KERNEL_MAX=6.9 -NV_URI="https://download.nvidia.com/XFree86/" - -DESCRIPTION="NVIDIA Accelerated Graphics Driver" -HOMEPAGE="https://www.nvidia.com/download/index.aspx" -SRC_URI=" - amd64? ( ${NV_URI}Linux-x86_64/${PV}/NVIDIA-Linux-x86_64-${PV}.run ) - arm64? ( ${NV_URI}Linux-aarch64/${PV}/NVIDIA-Linux-aarch64-${PV}.run ) - $(printf "${NV_URI}%s/%s-${PV}.tar.bz2 " \ - nvidia-{installer,modprobe,persistenced,settings,xconfig}{,}) - ${NV_URI}NVIDIA-kernel-module-source/NVIDIA-kernel-module-source-${PV}.tar.xz -" -# nvidia-installer is unused but here for GPL-2's "distribute sources" -S=${WORKDIR} - -LICENSE="NVIDIA-r2 Apache-2.0 BSD BSD-2 GPL-2 MIT ZLIB curl openssl" -SLOT="0/${PV%%.*}" -KEYWORDS="-* amd64 ~arm64" -IUSE="+X abi_x86_32 abi_x86_64 kernel-open persistenced powerd +static-libs +tools wayland" -REQUIRED_USE="kernel-open? ( modules )" - -COMMON_DEPEND=" - acct-group/video - X? ( x11-libs/libpciaccess ) - persistenced? ( - acct-user/nvpd - net-libs/libtirpc:= - ) - tools? ( - >=app-accessibility/at-spi2-core-2.46:2 - dev-libs/glib:2 - dev-libs/jansson:= - media-libs/harfbuzz:= - x11-libs/cairo - x11-libs/gdk-pixbuf:2 - x11-libs/gtk+:3[X] - x11-libs/libX11 - x11-libs/libXext - x11-libs/libXxf86vm - x11-libs/pango - ) -" -RDEPEND=" - ${COMMON_DEPEND} - dev-libs/openssl:0/3 - sys-libs/glibc - X? ( - media-libs/libglvnd[X,abi_x86_32(-)?] - x11-libs/libX11[abi_x86_32(-)?] - x11-libs/libXext[abi_x86_32(-)?] - ) - powerd? ( sys-apps/dbus[abi_x86_32(-)?] ) - wayland? ( - gui-libs/egl-gbm - >=gui-libs/egl-wayland-1.1.10 - media-libs/libglvnd - ) -" -DEPEND=" - ${COMMON_DEPEND} - static-libs? ( - x11-base/xorg-proto - x11-libs/libX11 - x11-libs/libXext - ) - tools? ( - media-libs/libglvnd - sys-apps/dbus - x11-base/xorg-proto - x11-libs/libXrandr - x11-libs/libXv - x11-libs/libvdpau - ) -" -BDEPEND=" - sys-devel/m4 - virtual/pkgconfig -" - -QA_PREBUILT="lib/firmware/* opt/bin/* usr/lib*" - -PATCHES=( - "${FILESDIR}"/nvidia-kernel-module-source-515.86.01-raw-ldflags.patch - "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch - "${FILESDIR}"/nvidia-settings-390.144-raw-ldflags.patch - "${FILESDIR}"/nvidia-settings-530.30.02-desktop.patch -) - -pkg_setup() { - use modules && [[ ${MERGE_TYPE} != binary ]] || return - - local CONFIG_CHECK=" - PROC_FS - ~DRM_KMS_HELPER - ~SYSVIPC - ~!LOCKDEP - ~!SLUB_DEBUG_ON - !DEBUG_MUTEXES - $(usev powerd '~CPU_FREQ') - " - - local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but needed for Xorg auto-detection - of drivers (no custom config), and for wayland / nvidia-drm.modeset=1. - Cannot be directly selected in the kernel's menuconfig, and may need - selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or - DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in." - - local ERROR_X86_KERNEL_IBT="CONFIG_X86_KERNEL_IBT: is set and, if the CPU supports the feature, - this *could* lead to modules load failure with ENDBR errors, or to - broken CUDA/NVENC. Please ignore if not having issues, but otherwise - try to unset or pass ibt=off to the kernel's command line." #911142 - use kernel-open || CONFIG_CHECK+=" ~!X86_KERNEL_IBT" - - use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764 - - use kernel-open && CONFIG_CHECK+=" MMU_NOTIFIER" #843827 - local ERROR_MMU_NOTIFIER="CONFIG_MMU_NOTIFIER: is not set but needed to build with USE=kernel-open. - Cannot be directly selected in the kernel's menuconfig, and may need - selection of another option that requires it such as CONFIG_KVM." - - linux-mod-r1_pkg_setup -} - -src_prepare() { - # make patches usable across versions - rm nvidia-modprobe && mv nvidia-modprobe{-${PV},} || die - rm nvidia-persistenced && mv nvidia-persistenced{-${PV},} || die - rm nvidia-settings && mv nvidia-settings{-${PV},} || die - rm nvidia-xconfig && mv nvidia-xconfig{-${PV},} || die - mv NVIDIA-kernel-module-source-${PV} kernel-module-source || die - - default - - kernel_is -ge 6 7 && - eapply "${FILESDIR}"/nvidia-drivers-535.43.22-kernel-6.7.patch - - # prevent detection of incomplete kernel DRM support (bug #603818) - sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \ - -i kernel{,-module-source/kernel-open}/conftest.sh || die - - # adjust service files - sed 's/__USER__/nvpd/' \ - nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \ - > "${T}"/nvidia-persistenced.service || die - use !powerd || # file is missing on arm64 (masked) - sed -i "s|/usr|${EPREFIX}/opt|" systemd/system/nvidia-powerd.service || die - - # use alternative vulkan icd option if USE=-X (bug #909181) - use X || sed -i 's/"libGLX/"libEGL/' nvidia_{layers,icd}.json || die - - # enable nvidia-drm.modeset=1 by default with USE=wayland - cp "${FILESDIR}"/nvidia-470.conf "${T}"/nvidia.conf || die - use !wayland || sed -i '/^#.*modeset=1$/s/^#//' "${T}"/nvidia.conf || die - - # makefile attempts to install wayland library even if not built - use wayland || sed -i 's/ WAYLAND_LIB_install$//' \ - nvidia-settings/src/Makefile || die - - # temporary option, nvidia will remove in the future - use !kernel-open || - sed -i '/blacklist/a\ -\ -# Enable using kernel-open with workstation GPUs (experimental)\ -options nvidia NVreg_OpenRmEnableUnsupportedGpus=1' "${T}"/nvidia.conf || die -} - -src_compile() { - tc-export AR CC CXX LD OBJCOPY OBJDUMP PKG_CONFIG - local -x RAW_LDFLAGS="$(get_abi_LDFLAGS) $(raw-ldflags)" # raw-ldflags.patch - - local xnvflags=-fPIC #840389 - # lto static libraries tend to cause problems without fat objects - tc-is-lto && xnvflags+=" $(test-flags-CC -ffat-lto-objects)" - - NV_ARGS=( - PREFIX="${EPREFIX}"/usr - HOST_CC="$(tc-getBUILD_CC)" - HOST_LD="$(tc-getBUILD_LD)" - BUILD_GTK2LIB= - NV_USE_BUNDLED_LIBJANSSON=0 - NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out - WAYLAND_AVAILABLE=$(usex wayland 1 0) - XNVCTRL_CFLAGS="${xnvflags}" - ) - - if use modules; then - local o_cflags=${CFLAGS} o_cxxflags=${CXXFLAGS} o_ldflags=${LDFLAGS} - - local modlistargs=video:kernel - if use kernel-open; then - modlistargs+=-module-source:kernel-module-source/kernel-open - - # environment flags are normally unused for modules, but nvidia - # uses it for building the "blob" and it is a bit fragile - filter-flags -fno-plt #912949 - filter-lto - CC=${KERNEL_CC} CXX=${KERNEL_CXX} strip-unsupported-flags - fi - - local modlist=( nvidia{,-drm,-modeset,-peermem,-uvm}=${modlistargs} ) - local modargs=( - IGNORE_CC_MISMATCH=yes NV_VERBOSE=1 - SYSOUT="${KV_OUT_DIR}" SYSSRC="${KV_DIR}" - ) - - # temporary workaround for bug #914468 - CPP="${KERNEL_CC} -E" tc-is-clang && addpredict "${KV_OUT_DIR}" - - linux-mod-r1_src_compile - CFLAGS=${o_cflags} CXXFLAGS=${o_cxxflags} LDFLAGS=${o_ldflags} - fi - - emake "${NV_ARGS[@]}" -C nvidia-modprobe - use persistenced && emake "${NV_ARGS[@]}" -C nvidia-persistenced - use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig - - if use tools; then - # avoid noisy *very* noisy logs with deprecation warnings - CFLAGS="-Wno-deprecated-declarations ${CFLAGS}" \ - emake "${NV_ARGS[@]}" -C nvidia-settings - elif use static-libs; then - # pretend GTK+3 is available, not actually used (bug #880879) - emake "${NV_ARGS[@]}" BUILD_GTK3LIB=1 \ - -C nvidia-settings/src out/libXNVCtrl.a - fi -} - -src_install() { - local libdir=$(get_libdir) libdir32=$(ABI=x86 get_libdir) - - NV_ARGS+=( DESTDIR="${D}" LIBDIR="${ED}"/usr/${libdir} ) - - local -A paths=( - [APPLICATION_PROFILE]=/usr/share/nvidia - [CUDA_ICD]=/etc/OpenCL/vendors - [EGL_EXTERNAL_PLATFORM_JSON]=/usr/share/egl/egl_external_platform.d - [FIRMWARE]=/lib/firmware/nvidia/${PV} - [GBM_BACKEND_LIB_SYMLINK]=/usr/${libdir}/gbm - [GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d - [OPENGL_DATA]=/usr/share/nvidia - [VULKAN_ICD_JSON]=/usr/share/vulkan - [WINE_LIB]=/usr/${libdir}/nvidia/wine - [XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d - - [GLX_MODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules/extensions - [GLX_MODULE_SYMLINK]=/usr/${libdir}/xorg/modules - [XMODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules - ) - - local skip_files=( - $(usev !X "libGLX_nvidia libglxserver_nvidia") - $(usev !wayland libnvidia-vulkan-producer) - libGLX_indirect # non-glvnd unused fallback - libnvidia-{gtk,wayland-client} nvidia-{settings,xconfig} # from source - libnvidia-egl-gbm 15_nvidia_gbm # gui-libs/egl-gbm - libnvidia-egl-wayland 10_nvidia_wayland # gui-libs/egl-wayland - libnvidia-pkcs11.so # using the openssl3 version instead - ) - local skip_modules=( - $(usev !X "nvfbc vdpau xdriver") - $(usev !modules gsp) - $(usev !powerd powerd) - installer nvpd # handled separately / built from source - ) - local skip_types=( - GLVND_LIB GLVND_SYMLINK EGL_CLIENT.\* GLX_CLIENT.\* # media-libs/libglvnd - OPENCL_WRAPPER.\* # virtual/opencl - DOCUMENTATION DOT_DESKTOP .\*_SRC DKMS_CONF SYSTEMD_UNIT # handled separately / unused - ) - - local DOCS=( - README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json - nvidia-settings/doc/{FRAMELOCK,NV-CONTROL-API}.txt - ) - local HTML_DOCS=( html/. ) - einstalldocs - - local DISABLE_AUTOFORMATTING=yes - local DOC_CONTENTS="\ -Trusted users should be in the 'video' group to use NVIDIA devices. -You can add yourself by using: gpasswd -a my-user video\ -$(usev modules " - -Like all out-of-tree kernel modules, it is necessary to rebuild -${PN} after upgrading or rebuilding the Linux kernel -by for example running \`emerge @module-rebuild\`. Alternatively, -if using a distribution kernel (sys-kernel/gentoo-kernel{,-bin}), -this can be automated by setting USE=dist-kernel globally. - -Loaded kernel modules also must not mismatch with the installed -${PN} version (excluding -r revision), meaning should -ensure \`eselect kernel list\` points to the kernel that will be -booted before building and preferably reboot after upgrading -${PN} (the ebuild will emit a warning if mismatching). - -See '${EPREFIX}/etc/modprobe.d/nvidia.conf' for modules options.")\ -$(use amd64 && usev !abi_x86_32 " - -Note that without USE=abi_x86_32 on ${PN}, 32bit applications -(typically using wine / steam) will not be able to use GPU acceleration.") - -For additional information or for troubleshooting issues, please see -https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own -documentation that is installed alongside this README." - readme.gentoo_create_doc - - if use modules; then - linux-mod-r1_src_install - - insinto /etc/modprobe.d - doins "${T}"/nvidia.conf - - # used for gpu verification with binpkgs (not kept, see pkg_preinst) - insinto /usr/share/nvidia - doins supported-gpus/supported-gpus.json - fi - - emake "${NV_ARGS[@]}" -C nvidia-modprobe install - fowners :video /usr/bin/nvidia-modprobe #505092 - fperms 4710 /usr/bin/nvidia-modprobe - - if use persistenced; then - emake "${NV_ARGS[@]}" -C nvidia-persistenced install - newconfd "${FILESDIR}"/nvidia-persistenced.confd nvidia-persistenced - newinitd "${FILESDIR}"/nvidia-persistenced.initd nvidia-persistenced - systemd_dounit "${T}"/nvidia-persistenced.service - fi - - if use tools; then - emake "${NV_ARGS[@]}" -C nvidia-settings install - - doicon nvidia-settings/doc/nvidia-settings.png - domenu nvidia-settings/doc/nvidia-settings.desktop - - exeinto /etc/X11/xinit/xinitrc.d - newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings - fi - - if use static-libs; then - dolib.a nvidia-settings/src/out/libXNVCtrl.a - - insinto /usr/include/NVCtrl - doins nvidia-settings/src/libXNVCtrl/NVCtrl{Lib,}.h - fi - - use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig install - - # mimic nvidia-installer by reading .manifest to install files - # 0:file 1:perms 2:type 3+:subtype/arguments -:module - local m into - while IFS=' ' read -ra m; do - ! [[ ${#m[@]} -ge 2 && ${m[-1]} =~ MODULE: ]] || - [[ " ${m[0]##*/}" =~ ^(\ ${skip_files[*]/%/.*|\\} )$ ]] || - [[ " ${m[2]}" =~ ^(\ ${skip_types[*]/%/|\\} )$ ]] || - has ${m[-1]#MODULE:} "${skip_modules[@]}" && continue - - case ${m[2]} in - MANPAGE) - gzip -dc ${m[0]} | newman - ${m[0]%.gz}; assert - continue - ;; - GBM_BACKEND_LIB_SYMLINK) m[4]=../${m[4]};; # missing ../ - VDPAU_SYMLINK) m[4]=vdpau/; m[5]=${m[5]#vdpau/};; # .so to vdpau/ - esac - - if [[ -v 'paths[${m[2]}]' ]]; then - into=${paths[${m[2]}]} - elif [[ ${m[2]} == EXPLICIT_PATH ]]; then - into=${m[3]} - elif [[ ${m[2]} == *_BINARY ]]; then - into=/opt/bin - elif [[ ${m[3]} == COMPAT32 ]]; then - use abi_x86_32 || continue - into=/usr/${libdir32} - elif [[ ${m[2]} == *_@(LIB|SYMLINK) ]]; then - into=/usr/${libdir} - else - die "No known installation path for ${m[0]}" - fi - [[ ${m[3]: -2} == ?/ ]] && into+=/${m[3]%/} - [[ ${m[4]: -2} == ?/ ]] && into+=/${m[4]%/} - - if [[ ${m[2]} =~ _SYMLINK$ ]]; then - [[ ${m[4]: -1} == / ]] && m[4]=${m[5]} - dosym ${m[4]} ${into}/${m[0]} - continue - fi - [[ ${m[0]} =~ ^libnvidia-ngx.so|^libnvidia-egl-gbm.so ]] && - dosym ${m[0]} ${into}/${m[0]%.so*}.so.1 # soname not in .manifest - - printf -v m[1] %o $((m[1] | 0200)) # 444->644 - insopts -m${m[1]} - insinto ${into} - doins ${m[0]} - done < .manifest || die - insopts -m0644 # reset - - # MODULE:installer non-skipped extras - : "$(systemd_get_sleepdir)" - exeinto "${_#"${EPREFIX}"}" - doexe systemd/system-sleep/nvidia - dobin systemd/nvidia-sleep.sh - systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend}.service - - dobin nvidia-bug-report.sh - - # MODULE:powerd extras - if use powerd; then - newinitd "${FILESDIR}"/nvidia-powerd.initd nvidia-powerd #923117 - systemd_dounit systemd/system/nvidia-powerd.service - - insinto /usr/share/dbus-1/system.d - doins nvidia-dbus.conf - fi - - # symlink non-versioned so nvidia-settings can use it even if misdetected - dosym nvidia-application-profiles-${PV}-key-documentation \ - ${paths[APPLICATION_PROFILE]}/nvidia-application-profiles-key-documentation - - # don't attempt to strip firmware files (silences errors) - dostrip -x ${paths[FIRMWARE]} - - # sandbox issues with /dev/nvidiactl (and /dev/char wrt bug #904292) - # are widespread and sometime affect revdeps of packages built with - # USE=opencl/cuda making it hard to manage in ebuilds (minimal set, - # ebuilds should handle manually if need others or addwrite) - insinto /etc/sandbox.d - newins - 20nvidia <<<'SANDBOX_PREDICT="/dev/nvidiactl:/dev/char"' -} - -pkg_preinst() { - has_version "${CATEGORY}/${PN}[wayland]" && NV_HAD_WAYLAND= - - use modules || return - - # set video group id based on live system (bug #491414) - local g=$(egetent group video | cut -d: -f3) - [[ ${g} =~ ^[0-9]+$ ]] || die "Failed to determine video group id (got '${g}')" - sed -i "s/@VIDEOGID@/${g}/" "${ED}"/etc/modprobe.d/nvidia.conf || die - - # try to find driver mismatches using temporary supported-gpus.json - for g in $(grep -l 0x10de /sys/bus/pci/devices/*/vendor 2>/dev/null); do - g=$(grep -io "\"devid\":\"$(<${g%vendor}device)\"[^}]*branch\":\"[0-9]*" \ - "${ED}"/usr/share/nvidia/supported-gpus.json 2>/dev/null) - if [[ ${g} ]]; then - g=$((${g##*\"}+1)) - if ver_test -ge ${g}; then - NV_LEGACY_MASK=">=${CATEGORY}/${PN}-${g}" - break - fi - fi - done - rm "${ED}"/usr/share/nvidia/supported-gpus.json || die -} - -pkg_postinst() { - linux-mod-r1_pkg_postinst - - readme.gentoo_print_elog - - if [[ -r /proc/driver/nvidia/version && - $( ${EROOT}/etc/portage/package.mask/${PN}" - else - ewarn " echo '${NV_LEGACY_MASK}' >> ${EROOT}/etc/portage/package.mask" - fi - ewarn "...then downgrade to a legacy[1] branch if possible (not all old versions" - ewarn "are available or fully functional, may need to consider nouveau[2])." - ewarn "[1] https://www.nvidia.com/object/IO_32667.html" - ewarn "[2] https://wiki.gentoo.org/wiki/Nouveau" - fi - - if use kernel-open; then - ewarn - ewarn "Open source variant of ${PN} was selected, be warned it is experimental" - ewarn "and only for modern GPUs (e.g. GTX 1650+). Try to disable if run into issues." - ewarn "Please also see: ${EROOT}/usr/share/doc/${PF}/html/kernel_open.html" - fi - - if use wayland && use modules && [[ ! -v NV_HAD_WAYLAND ]]; then - elog - elog "With USE=wayland, this version of ${PN} sets nvidia-drm.modeset=1" - elog "in '${EROOT}/etc/modprobe.d/nvidia.conf'. This feature is considered" - elog "experimental but is required for wayland." - elog - elog "If you experience issues, either disable wayland or edit nvidia.conf." - elog "Of note, may possibly cause issues with SLI and Reverse PRIME." - fi -} diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02-r1.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02-r1.ebuild new file mode 100644 index 000000000000..430c45687498 --- /dev/null +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02-r1.ebuild @@ -0,0 +1,556 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +MODULES_OPTIONAL_IUSE=+modules +inherit desktop flag-o-matic linux-mod-r1 readme.gentoo-r1 +inherit systemd toolchain-funcs unpacker user-info + +MODULES_KERNEL_MAX=6.10 +NV_URI="https://download.nvidia.com/XFree86/" + +DESCRIPTION="NVIDIA Accelerated Graphics Driver" +HOMEPAGE="https://www.nvidia.com/download/index.aspx" +SRC_URI=" + amd64? ( ${NV_URI}Linux-x86_64/${PV}/NVIDIA-Linux-x86_64-${PV}.run ) + arm64? ( ${NV_URI}Linux-aarch64/${PV}/NVIDIA-Linux-aarch64-${PV}.run ) + $(printf "${NV_URI}%s/%s-${PV}.tar.bz2 " \ + nvidia-{installer,modprobe,persistenced,settings,xconfig}{,}) + ${NV_URI}NVIDIA-kernel-module-source/NVIDIA-kernel-module-source-${PV}.tar.xz +" +# nvidia-installer is unused but here for GPL-2's "distribute sources" +S=${WORKDIR} + +LICENSE="NVIDIA-r2 Apache-2.0 BSD BSD-2 GPL-2 MIT ZLIB curl openssl" +SLOT="0/${PV%%.*}" +KEYWORDS="-* amd64 ~arm64" +IUSE="+X abi_x86_32 abi_x86_64 kernel-open persistenced powerd +static-libs +tools wayland" +REQUIRED_USE="kernel-open? ( modules )" + +COMMON_DEPEND=" + acct-group/video + X? ( x11-libs/libpciaccess ) + persistenced? ( + acct-user/nvpd + net-libs/libtirpc:= + ) + tools? ( + >=app-accessibility/at-spi2-core-2.46:2 + dev-libs/glib:2 + dev-libs/jansson:= + media-libs/harfbuzz:= + x11-libs/cairo + x11-libs/gdk-pixbuf:2 + x11-libs/gtk+:3[X] + x11-libs/libX11 + x11-libs/libXext + x11-libs/libXxf86vm + x11-libs/pango + ) +" +RDEPEND=" + ${COMMON_DEPEND} + dev-libs/openssl:0/3 + sys-libs/glibc + X? ( + media-libs/libglvnd[X,abi_x86_32(-)?] + x11-libs/libX11[abi_x86_32(-)?] + x11-libs/libXext[abi_x86_32(-)?] + ) + powerd? ( sys-apps/dbus[abi_x86_32(-)?] ) + wayland? ( + gui-libs/egl-gbm + >=gui-libs/egl-wayland-1.1.10 + ) +" +DEPEND=" + ${COMMON_DEPEND} + static-libs? ( + x11-base/xorg-proto + x11-libs/libX11 + x11-libs/libXext + ) + tools? ( + media-libs/libglvnd + sys-apps/dbus + x11-base/xorg-proto + x11-libs/libXrandr + x11-libs/libXv + x11-libs/libvdpau + ) +" +BDEPEND=" + sys-devel/m4 + virtual/pkgconfig +" + +QA_PREBUILT="lib/firmware/* opt/bin/* usr/lib*" + +PATCHES=( + "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch + "${FILESDIR}"/nvidia-settings-530.30.02-desktop.patch +) + +pkg_setup() { + use modules && [[ ${MERGE_TYPE} != binary ]] || return + + local CONFIG_CHECK=" + PROC_FS + ~DRM_KMS_HELPER + ~SYSVIPC + ~!LOCKDEP + ~!SLUB_DEBUG_ON + !DEBUG_MUTEXES + $(usev powerd '~CPU_FREQ') + " + + local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but needed for Xorg auto-detection + of drivers (no custom config), and for wayland / nvidia-drm.modeset=1. + Cannot be directly selected in the kernel's menuconfig, and may need + selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or + DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in." + + use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764 + + use kernel-open && CONFIG_CHECK+=" MMU_NOTIFIER" #843827 + local ERROR_MMU_NOTIFIER="CONFIG_MMU_NOTIFIER: is not set but needed to build with USE=kernel-open. + Cannot be directly selected in the kernel's menuconfig, and may need + selection of another option that requires it such as CONFIG_KVM." + + linux-mod-r1_pkg_setup +} + +src_prepare() { + # make patches usable across versions + rm nvidia-modprobe && mv nvidia-modprobe{-${PV},} || die + rm nvidia-persistenced && mv nvidia-persistenced{-${PV},} || die + rm nvidia-settings && mv nvidia-settings{-${PV},} || die + rm nvidia-xconfig && mv nvidia-xconfig{-${PV},} || die + mv NVIDIA-kernel-module-source-${PV} kernel-module-source || die + + default + + # prevent detection of incomplete kernel DRM support (bug #603818) + sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \ + -i kernel{,-module-source/kernel-open}/conftest.sh || die + + # adjust service files + sed 's/__USER__/nvpd/' \ + nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \ + > "${T}"/nvidia-persistenced.service || die + sed -i "s|/usr|${EPREFIX}/opt|" systemd/system/nvidia-powerd.service || die + + # use alternative vulkan icd option if USE=-X (bug #909181) + use X || sed -i 's/"libGLX/"libEGL/' nvidia_{layers,icd}.json || die + + # enable nvidia-drm.modeset=1 by default with USE=wayland + cp "${FILESDIR}"/nvidia-545.conf "${T}"/nvidia.conf || die + use !wayland || sed -i '/^#.*modeset=1$/s/^#//' "${T}"/nvidia.conf || die + + # makefile attempts to install wayland library even if not built + use wayland || sed -i 's/ WAYLAND_LIB_install$//' \ + nvidia-settings/src/Makefile || die +} + +src_compile() { + tc-export AR CC CXX LD OBJCOPY OBJDUMP PKG_CONFIG + + local xnvflags=-fPIC #840389 + # lto static libraries tend to cause problems without fat objects + tc-is-lto && xnvflags+=" $(test-flags-CC -ffat-lto-objects)" + + NV_ARGS=( + PREFIX="${EPREFIX}"/usr + HOST_CC="$(tc-getBUILD_CC)" + HOST_LD="$(tc-getBUILD_LD)" + BUILD_GTK2LIB= + NV_USE_BUNDLED_LIBJANSSON=0 + NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out + WAYLAND_AVAILABLE=$(usex wayland 1 0) + XNVCTRL_CFLAGS="${xnvflags}" + ) + + if use modules; then + local o_cflags=${CFLAGS} o_cxxflags=${CXXFLAGS} o_ldflags=${LDFLAGS} + + local modlistargs=video:kernel + if use kernel-open; then + modlistargs+=-module-source:kernel-module-source/kernel-open + + # environment flags are normally unused for modules, but nvidia + # uses it for building the "blob" and it is a bit fragile + filter-flags -fno-plt #912949 + filter-lto + CC=${KERNEL_CC} CXX=${KERNEL_CXX} strip-unsupported-flags + fi + + local modlist=( nvidia{,-drm,-modeset,-peermem,-uvm}=${modlistargs} ) + local modargs=( + IGNORE_CC_MISMATCH=yes NV_VERBOSE=1 + SYSOUT="${KV_OUT_DIR}" SYSSRC="${KV_DIR}" + ) + + # temporary workaround for bug #914468 + CPP="${KERNEL_CC} -E" tc-is-clang && addpredict "${KV_OUT_DIR}" + + linux-mod-r1_src_compile + CFLAGS=${o_cflags} CXXFLAGS=${o_cxxflags} LDFLAGS=${o_ldflags} + fi + + emake "${NV_ARGS[@]}" -C nvidia-modprobe + use persistenced && emake "${NV_ARGS[@]}" -C nvidia-persistenced + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig + + if use tools; then + # avoid noisy *very* noisy logs with deprecation warnings + CFLAGS="-Wno-deprecated-declarations ${CFLAGS}" \ + emake "${NV_ARGS[@]}" -C nvidia-settings + elif use static-libs; then + # pretend GTK+3 is available, not actually used (bug #880879) + emake "${NV_ARGS[@]}" BUILD_GTK3LIB=1 \ + -C nvidia-settings/src out/libXNVCtrl.a + fi +} + +src_install() { + local libdir=$(get_libdir) libdir32=$(ABI=x86 get_libdir) + + NV_ARGS+=( DESTDIR="${D}" LIBDIR="${ED}"/usr/${libdir} ) + + local -A paths=( + [APPLICATION_PROFILE]=/usr/share/nvidia + [CUDA_ICD]=/etc/OpenCL/vendors + [EGL_EXTERNAL_PLATFORM_JSON]=/usr/share/egl/egl_external_platform.d + [FIRMWARE]=/lib/firmware/nvidia/${PV} + [GBM_BACKEND_LIB_SYMLINK]=/usr/${libdir}/gbm + [GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d + [OPENGL_DATA]=/usr/share/nvidia + [VULKAN_ICD_JSON]=/usr/share/vulkan + [WINE_LIB]=/usr/${libdir}/nvidia/wine + [XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d + + [GLX_MODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules/extensions + [GLX_MODULE_SYMLINK]=/usr/${libdir}/xorg/modules + [XMODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules + ) + + local skip_files=( + $(usev !X "libGLX_nvidia libglxserver_nvidia") + libGLX_indirect # non-glvnd unused fallback + libnvidia-{gtk,wayland-client} nvidia-{settings,xconfig} # from source + libnvidia-egl-gbm 15_nvidia_gbm # gui-libs/egl-gbm + libnvidia-egl-wayland 10_nvidia_wayland # gui-libs/egl-wayland + libnvidia-pkcs11.so # using the openssl3 version instead + ) + local skip_modules=( + $(usev !X "nvfbc vdpau xdriver") + $(usev !modules gsp) + $(usev !powerd powerd) + installer nvpd # handled separately / built from source + ) + local skip_types=( + GLVND_LIB GLVND_SYMLINK EGL_CLIENT.\* GLX_CLIENT.\* # media-libs/libglvnd + OPENCL_WRAPPER.\* # virtual/opencl + DOCUMENTATION DOT_DESKTOP .\*_SRC DKMS_CONF SYSTEMD_UNIT # handled separately / unused + ) + + local DOCS=( + README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json + nvidia-settings/doc/{FRAMELOCK,NV-CONTROL-API}.txt + ) + local HTML_DOCS=( html/. ) + einstalldocs + + local DISABLE_AUTOFORMATTING=yes + local DOC_CONTENTS="\ +Trusted users should be in the 'video' group to use NVIDIA devices. +You can add yourself by using: gpasswd -a my-user video\ +$(usev modules " + +Like all out-of-tree kernel modules, it is necessary to rebuild +${PN} after upgrading or rebuilding the Linux kernel +by for example running \`emerge @module-rebuild\`. Alternatively, +if using a distribution kernel (sys-kernel/gentoo-kernel{,-bin}), +this can be automated by setting USE=dist-kernel globally. + +Loaded kernel modules also must not mismatch with the installed +${PN} version (excluding -r revision), meaning should +ensure \`eselect kernel list\` points to the kernel that will be +booted before building and preferably reboot after upgrading +${PN} (the ebuild will emit a warning if mismatching). + +See '${EPREFIX}/etc/modprobe.d/nvidia.conf' for modules options.")\ +$(use amd64 && usev !abi_x86_32 " + +Note that without USE=abi_x86_32 on ${PN}, 32bit applications +(typically using wine / steam) will not be able to use GPU acceleration.") + +For additional information or for troubleshooting issues, please see +https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own +documentation that is installed alongside this README." + readme.gentoo_create_doc + + if use modules; then + linux-mod-r1_src_install + + insinto /etc/modprobe.d + doins "${T}"/nvidia.conf + + # used for gpu verification with binpkgs (not kept, see pkg_preinst) + insinto /usr/share/nvidia + doins supported-gpus/supported-gpus.json + fi + + emake "${NV_ARGS[@]}" -C nvidia-modprobe install + fowners :video /usr/bin/nvidia-modprobe #505092 + fperms 4710 /usr/bin/nvidia-modprobe + + if use persistenced; then + emake "${NV_ARGS[@]}" -C nvidia-persistenced install + newconfd "${FILESDIR}"/nvidia-persistenced.confd nvidia-persistenced + newinitd "${FILESDIR}"/nvidia-persistenced.initd nvidia-persistenced + systemd_dounit "${T}"/nvidia-persistenced.service + fi + + if use tools; then + emake "${NV_ARGS[@]}" -C nvidia-settings install + + doicon nvidia-settings/doc/nvidia-settings.png + domenu nvidia-settings/doc/nvidia-settings.desktop + + exeinto /etc/X11/xinit/xinitrc.d + newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings + fi + + if use static-libs; then + dolib.a nvidia-settings/src/out/libXNVCtrl.a + + insinto /usr/include/NVCtrl + doins nvidia-settings/src/libXNVCtrl/NVCtrl{Lib,}.h + fi + + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig install + + # mimic nvidia-installer by reading .manifest to install files + # 0:file 1:perms 2:type 3+:subtype/arguments -:module + local m into + while IFS=' ' read -ra m; do + ! [[ ${#m[@]} -ge 2 && ${m[-1]} =~ MODULE: ]] || + [[ " ${m[0]##*/}" =~ ^(\ ${skip_files[*]/%/.*|\\} )$ ]] || + [[ " ${m[2]}" =~ ^(\ ${skip_types[*]/%/|\\} )$ ]] || + has ${m[-1]#MODULE:} "${skip_modules[@]}" && continue + + case ${m[2]} in + MANPAGE) + gzip -dc ${m[0]} | newman - ${m[0]%.gz}; assert + continue + ;; + GBM_BACKEND_LIB_SYMLINK) m[4]=../${m[4]};; # missing ../ + VDPAU_SYMLINK) m[4]=vdpau/; m[5]=${m[5]#vdpau/};; # .so to vdpau/ + esac + + if [[ -v 'paths[${m[2]}]' ]]; then + into=${paths[${m[2]}]} + elif [[ ${m[2]} == EXPLICIT_PATH ]]; then + into=${m[3]} + elif [[ ${m[2]} == *_BINARY ]]; then + into=/opt/bin + elif [[ ${m[3]} == COMPAT32 ]]; then + use abi_x86_32 || continue + into=/usr/${libdir32} + elif [[ ${m[2]} == *_@(LIB|SYMLINK) ]]; then + into=/usr/${libdir} + else + die "No known installation path for ${m[0]}" + fi + [[ ${m[3]: -2} == ?/ ]] && into+=/${m[3]%/} + [[ ${m[4]: -2} == ?/ ]] && into+=/${m[4]%/} + + if [[ ${m[2]} =~ _SYMLINK$ ]]; then + [[ ${m[4]: -1} == / ]] && m[4]=${m[5]} + dosym ${m[4]} ${into}/${m[0]} + continue + fi + [[ ${m[0]} =~ ^libnvidia-ngx.so|^libnvidia-egl-gbm.so ]] && + dosym ${m[0]} ${into}/${m[0]%.so*}.so.1 # soname not in .manifest + + printf -v m[1] %o $((m[1] | 0200)) # 444->644 + insopts -m${m[1]} + insinto ${into} + doins ${m[0]} + done < .manifest || die + insopts -m0644 # reset + + # MODULE:installer non-skipped extras + : "$(systemd_get_sleepdir)" + exeinto "${_#"${EPREFIX}"}" + doexe systemd/system-sleep/nvidia + dobin systemd/nvidia-sleep.sh + systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend}.service + + dobin nvidia-bug-report.sh + + # MODULE:powerd extras + if use powerd; then + newinitd "${FILESDIR}"/nvidia-powerd.initd nvidia-powerd #923117 + systemd_dounit systemd/system/nvidia-powerd.service + + insinto /usr/share/dbus-1/system.d + doins nvidia-dbus.conf + fi + + # enabling is needed for sleep to work properly and little reason not to do + # it unconditionally for a better user experience + : "$(systemd_get_systemunitdir)" + local unitdir=${_#"${EPREFIX}"} + # not using relative symlinks to match systemd's own links + dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-hibernate.service + dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-resume.service + dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-suspend.service + dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-resume.service + # also add a custom elogind hook to do the equivalent of the above + exeinto /usr/lib/elogind/system-sleep + newexe "${FILESDIR}"/system-sleep.elogind nvidia + # /dev/null); do + g=$(grep -io "\"devid\":\"$(<${g%vendor}device)\"[^}]*branch\":\"[0-9]*" \ + "${ED}"/usr/share/nvidia/supported-gpus.json 2>/dev/null) + if [[ ${g} ]]; then + g=$((${g##*\"}+1)) + if ver_test -ge ${g}; then + NV_LEGACY_MASK=">=${CATEGORY}/${PN}-${g}" + break + fi + fi + done + rm "${ED}"/usr/share/nvidia/supported-gpus.json || die +} + +pkg_postinst() { + linux-mod-r1_pkg_postinst + + readme.gentoo_print_elog + + if [[ -r /proc/driver/nvidia/version && + $( ${EROOT}/etc/portage/package.mask/${PN}" + else + ewarn " echo '${NV_LEGACY_MASK}' >> ${EROOT}/etc/portage/package.mask" + fi + ewarn "...then downgrade to a legacy[1] branch if possible (not all old versions" + ewarn "are available or fully functional, may need to consider nouveau[2])." + ewarn "[1] https://www.nvidia.com/object/IO_32667.html" + ewarn "[2] https://wiki.gentoo.org/wiki/Nouveau" + fi + + if use kernel-open && [[ ! -v NV_HAD_KERNEL_OPEN ]]; then + ewarn + ewarn "Open source variant of ${PN} was selected, be warned it is experimental" + ewarn "and only for modern GPUs (e.g. GTX 1650+). Try to disable if run into issues." + ewarn "Please also see: ${EROOT}/usr/share/doc/${PF}/html/kernel_open.html" + fi + + if use wayland && use modules && [[ ! -v NV_HAD_WAYLAND ]]; then + elog + elog "With USE=wayland, this version of ${PN} sets nvidia-drm.modeset=1" + elog "in '${EROOT}/etc/modprobe.d/nvidia.conf'. This feature is considered" + elog "experimental but is required for wayland." + elog + elog "If you experience issues, either disable wayland or edit nvidia.conf." + elog "Of note, may possibly cause issues with SLI and Reverse PRIME." + fi + + # these can be removed after some time, only to help the transition + # given users are unlikely to do further custom solutions if it works + # (see also https://github.com/elogind/elogind/issues/272) + if grep -riq "^[^#]*HandleNvidiaSleep=yes" "${EROOT}"/etc/elogind/sleep.conf.d/ 2>/dev/null + then + ewarn + ewarn "!!! WARNING !!!" + ewarn "Detected HandleNvidiaSleep=yes in ${EROOT}/etc/elogind/sleep.conf.d/." + ewarn "This 'could' cause issues if used in combination with the new hook" + ewarn "installed by the ebuild to handle sleep using the official upstream" + ewarn "script. It is recommended to disable the option." + fi + if [[ $(realpath "${EROOT}"{/etc,{/usr,}/lib*}/elogind/system-sleep | sort | uniq | \ + xargs -d'\n' grep -Ril nvidia 2>/dev/null | wc -l) -gt 2 ]] + then + ewarn + ewarn "!!! WARNING !!!" + ewarn "Detected a custom script at ${EROOT}{/etc,{/usr,}/lib*}/elogind/system-sleep" + ewarn "referencing NVIDIA. This version of ${PN} has installed its own" + ewarn "hook at ${EROOT}/usr/lib/elogind/system-sleep/nvidia and it is recommended" + ewarn "to remove the custom one to avoid potential issues." + ewarn + ewarn "Feel free to ignore this warning if you know the other NVIDIA-related" + ewarn "scripts can be used together. The warning will be removed in the future." + fi + if [[ ${REPLACING_VERSIONS##* } ]] && + ver_test ${REPLACING_VERSIONS##* } -lt 550.107.02-r1 # may get repeated + then + elog + elog "For suspend/sleep, 'NVreg_PreserveVideoMemoryAllocations=1' is now default" + elog "with this version of ${PN}. This is recommended (or required) by" + elog "major DEs especially with wayland but, *if* experience regressions with" + elog "suspend, try reverting to =0 in '${EROOT}/etc/modprobe.d/nvidia.conf'." + elog + elog "May notably be an issue when using neither systemd nor elogind to suspend." + elog + elog "Also, the systemd suspend/hibernate/resume services are now enabled by" + elog "default, and for openrc+elogind a similar hook has been installed." + fi +} diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02.ebuild deleted file mode 100644 index 42c25308f23a..000000000000 --- a/x11-drivers/nvidia-drivers/nvidia-drivers-550.107.02.ebuild +++ /dev/null @@ -1,500 +0,0 @@ -# Copyright 1999-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -MODULES_OPTIONAL_IUSE=+modules -inherit desktop flag-o-matic linux-mod-r1 readme.gentoo-r1 -inherit systemd toolchain-funcs unpacker user-info - -MODULES_KERNEL_MAX=6.10 -NV_URI="https://download.nvidia.com/XFree86/" - -DESCRIPTION="NVIDIA Accelerated Graphics Driver" -HOMEPAGE="https://www.nvidia.com/download/index.aspx" -SRC_URI=" - amd64? ( ${NV_URI}Linux-x86_64/${PV}/NVIDIA-Linux-x86_64-${PV}.run ) - arm64? ( ${NV_URI}Linux-aarch64/${PV}/NVIDIA-Linux-aarch64-${PV}.run ) - $(printf "${NV_URI}%s/%s-${PV}.tar.bz2 " \ - nvidia-{installer,modprobe,persistenced,settings,xconfig}{,}) - ${NV_URI}NVIDIA-kernel-module-source/NVIDIA-kernel-module-source-${PV}.tar.xz -" -# nvidia-installer is unused but here for GPL-2's "distribute sources" -S=${WORKDIR} - -LICENSE="NVIDIA-r2 Apache-2.0 BSD BSD-2 GPL-2 MIT ZLIB curl openssl" -SLOT="0/${PV%%.*}" -KEYWORDS="-* amd64 ~arm64" -IUSE="+X abi_x86_32 abi_x86_64 kernel-open persistenced powerd +static-libs +tools wayland" -REQUIRED_USE="kernel-open? ( modules )" - -COMMON_DEPEND=" - acct-group/video - X? ( x11-libs/libpciaccess ) - persistenced? ( - acct-user/nvpd - net-libs/libtirpc:= - ) - tools? ( - >=app-accessibility/at-spi2-core-2.46:2 - dev-libs/glib:2 - dev-libs/jansson:= - media-libs/harfbuzz:= - x11-libs/cairo - x11-libs/gdk-pixbuf:2 - x11-libs/gtk+:3[X] - x11-libs/libX11 - x11-libs/libXext - x11-libs/libXxf86vm - x11-libs/pango - ) -" -RDEPEND=" - ${COMMON_DEPEND} - dev-libs/openssl:0/3 - sys-libs/glibc - X? ( - media-libs/libglvnd[X,abi_x86_32(-)?] - x11-libs/libX11[abi_x86_32(-)?] - x11-libs/libXext[abi_x86_32(-)?] - ) - powerd? ( sys-apps/dbus[abi_x86_32(-)?] ) - wayland? ( - gui-libs/egl-gbm - >=gui-libs/egl-wayland-1.1.10 - ) -" -DEPEND=" - ${COMMON_DEPEND} - static-libs? ( - x11-base/xorg-proto - x11-libs/libX11 - x11-libs/libXext - ) - tools? ( - media-libs/libglvnd - sys-apps/dbus - x11-base/xorg-proto - x11-libs/libXrandr - x11-libs/libXv - x11-libs/libvdpau - ) -" -BDEPEND=" - sys-devel/m4 - virtual/pkgconfig -" - -QA_PREBUILT="lib/firmware/* opt/bin/* usr/lib*" - -PATCHES=( - "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch - "${FILESDIR}"/nvidia-settings-530.30.02-desktop.patch -) - -pkg_setup() { - use modules && [[ ${MERGE_TYPE} != binary ]] || return - - local CONFIG_CHECK=" - PROC_FS - ~DRM_KMS_HELPER - ~SYSVIPC - ~!LOCKDEP - ~!SLUB_DEBUG_ON - !DEBUG_MUTEXES - $(usev powerd '~CPU_FREQ') - " - - local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but needed for Xorg auto-detection - of drivers (no custom config), and for wayland / nvidia-drm.modeset=1. - Cannot be directly selected in the kernel's menuconfig, and may need - selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or - DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in." - - use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764 - - use kernel-open && CONFIG_CHECK+=" MMU_NOTIFIER" #843827 - local ERROR_MMU_NOTIFIER="CONFIG_MMU_NOTIFIER: is not set but needed to build with USE=kernel-open. - Cannot be directly selected in the kernel's menuconfig, and may need - selection of another option that requires it such as CONFIG_KVM." - - linux-mod-r1_pkg_setup -} - -src_prepare() { - # make patches usable across versions - rm nvidia-modprobe && mv nvidia-modprobe{-${PV},} || die - rm nvidia-persistenced && mv nvidia-persistenced{-${PV},} || die - rm nvidia-settings && mv nvidia-settings{-${PV},} || die - rm nvidia-xconfig && mv nvidia-xconfig{-${PV},} || die - mv NVIDIA-kernel-module-source-${PV} kernel-module-source || die - - default - - # prevent detection of incomplete kernel DRM support (bug #603818) - sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \ - -i kernel{,-module-source/kernel-open}/conftest.sh || die - - # adjust service files - sed 's/__USER__/nvpd/' \ - nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \ - > "${T}"/nvidia-persistenced.service || die - sed -i "s|/usr|${EPREFIX}/opt|" systemd/system/nvidia-powerd.service || die - - # use alternative vulkan icd option if USE=-X (bug #909181) - use X || sed -i 's/"libGLX/"libEGL/' nvidia_{layers,icd}.json || die - - # enable nvidia-drm.modeset=1 by default with USE=wayland - cp "${FILESDIR}"/nvidia-545.conf "${T}"/nvidia.conf || die - use !wayland || sed -i '/^#.*modeset=1$/s/^#//' "${T}"/nvidia.conf || die - - # makefile attempts to install wayland library even if not built - use wayland || sed -i 's/ WAYLAND_LIB_install$//' \ - nvidia-settings/src/Makefile || die -} - -src_compile() { - tc-export AR CC CXX LD OBJCOPY OBJDUMP PKG_CONFIG - - local xnvflags=-fPIC #840389 - # lto static libraries tend to cause problems without fat objects - tc-is-lto && xnvflags+=" $(test-flags-CC -ffat-lto-objects)" - - NV_ARGS=( - PREFIX="${EPREFIX}"/usr - HOST_CC="$(tc-getBUILD_CC)" - HOST_LD="$(tc-getBUILD_LD)" - BUILD_GTK2LIB= - NV_USE_BUNDLED_LIBJANSSON=0 - NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out - WAYLAND_AVAILABLE=$(usex wayland 1 0) - XNVCTRL_CFLAGS="${xnvflags}" - ) - - if use modules; then - local o_cflags=${CFLAGS} o_cxxflags=${CXXFLAGS} o_ldflags=${LDFLAGS} - - local modlistargs=video:kernel - if use kernel-open; then - modlistargs+=-module-source:kernel-module-source/kernel-open - - # environment flags are normally unused for modules, but nvidia - # uses it for building the "blob" and it is a bit fragile - filter-flags -fno-plt #912949 - filter-lto - CC=${KERNEL_CC} CXX=${KERNEL_CXX} strip-unsupported-flags - fi - - local modlist=( nvidia{,-drm,-modeset,-peermem,-uvm}=${modlistargs} ) - local modargs=( - IGNORE_CC_MISMATCH=yes NV_VERBOSE=1 - SYSOUT="${KV_OUT_DIR}" SYSSRC="${KV_DIR}" - ) - - # temporary workaround for bug #914468 - CPP="${KERNEL_CC} -E" tc-is-clang && addpredict "${KV_OUT_DIR}" - - linux-mod-r1_src_compile - CFLAGS=${o_cflags} CXXFLAGS=${o_cxxflags} LDFLAGS=${o_ldflags} - fi - - emake "${NV_ARGS[@]}" -C nvidia-modprobe - use persistenced && emake "${NV_ARGS[@]}" -C nvidia-persistenced - use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig - - if use tools; then - # avoid noisy *very* noisy logs with deprecation warnings - CFLAGS="-Wno-deprecated-declarations ${CFLAGS}" \ - emake "${NV_ARGS[@]}" -C nvidia-settings - elif use static-libs; then - # pretend GTK+3 is available, not actually used (bug #880879) - emake "${NV_ARGS[@]}" BUILD_GTK3LIB=1 \ - -C nvidia-settings/src out/libXNVCtrl.a - fi -} - -src_install() { - local libdir=$(get_libdir) libdir32=$(ABI=x86 get_libdir) - - NV_ARGS+=( DESTDIR="${D}" LIBDIR="${ED}"/usr/${libdir} ) - - local -A paths=( - [APPLICATION_PROFILE]=/usr/share/nvidia - [CUDA_ICD]=/etc/OpenCL/vendors - [EGL_EXTERNAL_PLATFORM_JSON]=/usr/share/egl/egl_external_platform.d - [FIRMWARE]=/lib/firmware/nvidia/${PV} - [GBM_BACKEND_LIB_SYMLINK]=/usr/${libdir}/gbm - [GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d - [OPENGL_DATA]=/usr/share/nvidia - [VULKAN_ICD_JSON]=/usr/share/vulkan - [WINE_LIB]=/usr/${libdir}/nvidia/wine - [XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d - - [GLX_MODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules/extensions - [GLX_MODULE_SYMLINK]=/usr/${libdir}/xorg/modules - [XMODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules - ) - - local skip_files=( - $(usev !X "libGLX_nvidia libglxserver_nvidia") - libGLX_indirect # non-glvnd unused fallback - libnvidia-{gtk,wayland-client} nvidia-{settings,xconfig} # from source - libnvidia-egl-gbm 15_nvidia_gbm # gui-libs/egl-gbm - libnvidia-egl-wayland 10_nvidia_wayland # gui-libs/egl-wayland - libnvidia-pkcs11.so # using the openssl3 version instead - ) - local skip_modules=( - $(usev !X "nvfbc vdpau xdriver") - $(usev !modules gsp) - $(usev !powerd powerd) - installer nvpd # handled separately / built from source - ) - local skip_types=( - GLVND_LIB GLVND_SYMLINK EGL_CLIENT.\* GLX_CLIENT.\* # media-libs/libglvnd - OPENCL_WRAPPER.\* # virtual/opencl - DOCUMENTATION DOT_DESKTOP .\*_SRC DKMS_CONF SYSTEMD_UNIT # handled separately / unused - ) - - local DOCS=( - README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json - nvidia-settings/doc/{FRAMELOCK,NV-CONTROL-API}.txt - ) - local HTML_DOCS=( html/. ) - einstalldocs - - local DISABLE_AUTOFORMATTING=yes - local DOC_CONTENTS="\ -Trusted users should be in the 'video' group to use NVIDIA devices. -You can add yourself by using: gpasswd -a my-user video\ -$(usev modules " - -Like all out-of-tree kernel modules, it is necessary to rebuild -${PN} after upgrading or rebuilding the Linux kernel -by for example running \`emerge @module-rebuild\`. Alternatively, -if using a distribution kernel (sys-kernel/gentoo-kernel{,-bin}), -this can be automated by setting USE=dist-kernel globally. - -Loaded kernel modules also must not mismatch with the installed -${PN} version (excluding -r revision), meaning should -ensure \`eselect kernel list\` points to the kernel that will be -booted before building and preferably reboot after upgrading -${PN} (the ebuild will emit a warning if mismatching). - -See '${EPREFIX}/etc/modprobe.d/nvidia.conf' for modules options.")\ -$(use amd64 && usev !abi_x86_32 " - -Note that without USE=abi_x86_32 on ${PN}, 32bit applications -(typically using wine / steam) will not be able to use GPU acceleration.") - -For additional information or for troubleshooting issues, please see -https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own -documentation that is installed alongside this README." - readme.gentoo_create_doc - - if use modules; then - linux-mod-r1_src_install - - insinto /etc/modprobe.d - doins "${T}"/nvidia.conf - - # used for gpu verification with binpkgs (not kept, see pkg_preinst) - insinto /usr/share/nvidia - doins supported-gpus/supported-gpus.json - fi - - emake "${NV_ARGS[@]}" -C nvidia-modprobe install - fowners :video /usr/bin/nvidia-modprobe #505092 - fperms 4710 /usr/bin/nvidia-modprobe - - if use persistenced; then - emake "${NV_ARGS[@]}" -C nvidia-persistenced install - newconfd "${FILESDIR}"/nvidia-persistenced.confd nvidia-persistenced - newinitd "${FILESDIR}"/nvidia-persistenced.initd nvidia-persistenced - systemd_dounit "${T}"/nvidia-persistenced.service - fi - - if use tools; then - emake "${NV_ARGS[@]}" -C nvidia-settings install - - doicon nvidia-settings/doc/nvidia-settings.png - domenu nvidia-settings/doc/nvidia-settings.desktop - - exeinto /etc/X11/xinit/xinitrc.d - newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings - fi - - if use static-libs; then - dolib.a nvidia-settings/src/out/libXNVCtrl.a - - insinto /usr/include/NVCtrl - doins nvidia-settings/src/libXNVCtrl/NVCtrl{Lib,}.h - fi - - use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig install - - # mimic nvidia-installer by reading .manifest to install files - # 0:file 1:perms 2:type 3+:subtype/arguments -:module - local m into - while IFS=' ' read -ra m; do - ! [[ ${#m[@]} -ge 2 && ${m[-1]} =~ MODULE: ]] || - [[ " ${m[0]##*/}" =~ ^(\ ${skip_files[*]/%/.*|\\} )$ ]] || - [[ " ${m[2]}" =~ ^(\ ${skip_types[*]/%/|\\} )$ ]] || - has ${m[-1]#MODULE:} "${skip_modules[@]}" && continue - - case ${m[2]} in - MANPAGE) - gzip -dc ${m[0]} | newman - ${m[0]%.gz}; assert - continue - ;; - GBM_BACKEND_LIB_SYMLINK) m[4]=../${m[4]};; # missing ../ - VDPAU_SYMLINK) m[4]=vdpau/; m[5]=${m[5]#vdpau/};; # .so to vdpau/ - esac - - if [[ -v 'paths[${m[2]}]' ]]; then - into=${paths[${m[2]}]} - elif [[ ${m[2]} == EXPLICIT_PATH ]]; then - into=${m[3]} - elif [[ ${m[2]} == *_BINARY ]]; then - into=/opt/bin - elif [[ ${m[3]} == COMPAT32 ]]; then - use abi_x86_32 || continue - into=/usr/${libdir32} - elif [[ ${m[2]} == *_@(LIB|SYMLINK) ]]; then - into=/usr/${libdir} - else - die "No known installation path for ${m[0]}" - fi - [[ ${m[3]: -2} == ?/ ]] && into+=/${m[3]%/} - [[ ${m[4]: -2} == ?/ ]] && into+=/${m[4]%/} - - if [[ ${m[2]} =~ _SYMLINK$ ]]; then - [[ ${m[4]: -1} == / ]] && m[4]=${m[5]} - dosym ${m[4]} ${into}/${m[0]} - continue - fi - [[ ${m[0]} =~ ^libnvidia-ngx.so|^libnvidia-egl-gbm.so ]] && - dosym ${m[0]} ${into}/${m[0]%.so*}.so.1 # soname not in .manifest - - printf -v m[1] %o $((m[1] | 0200)) # 444->644 - insopts -m${m[1]} - insinto ${into} - doins ${m[0]} - done < .manifest || die - insopts -m0644 # reset - - # MODULE:installer non-skipped extras - : "$(systemd_get_sleepdir)" - exeinto "${_#"${EPREFIX}"}" - doexe systemd/system-sleep/nvidia - dobin systemd/nvidia-sleep.sh - systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend}.service - - dobin nvidia-bug-report.sh - - # MODULE:powerd extras - if use powerd; then - newinitd "${FILESDIR}"/nvidia-powerd.initd nvidia-powerd #923117 - systemd_dounit systemd/system/nvidia-powerd.service - - insinto /usr/share/dbus-1/system.d - doins nvidia-dbus.conf - fi - - # symlink non-versioned so nvidia-settings can use it even if misdetected - dosym nvidia-application-profiles-${PV}-key-documentation \ - ${paths[APPLICATION_PROFILE]}/nvidia-application-profiles-key-documentation - - # don't attempt to strip firmware files (silences errors) - dostrip -x ${paths[FIRMWARE]} - - # sandbox issues with /dev/nvidiactl others (bug #904292,#921578) - # are widespread and sometime affect revdeps of packages built with - # USE=opencl/cuda making it hard to manage in ebuilds (minimal set, - # ebuilds should handle manually if need others or addwrite) - insinto /etc/sandbox.d - newins - 20nvidia <<<'SANDBOX_PREDICT="/dev/nvidiactl:/dev/nvidia-caps:/dev/char"' -} - -pkg_preinst() { - has_version "${CATEGORY}/${PN}[kernel-open]" && NV_HAD_KERNEL_OPEN= - has_version "${CATEGORY}/${PN}[wayland]" && NV_HAD_WAYLAND= - - use modules || return - - # set video group id based on live system (bug #491414) - local g=$(egetent group video | cut -d: -f3) - [[ ${g} =~ ^[0-9]+$ ]] || die "Failed to determine video group id (got '${g}')" - sed -i "s/@VIDEOGID@/${g}/" "${ED}"/etc/modprobe.d/nvidia.conf || die - - # try to find driver mismatches using temporary supported-gpus.json - for g in $(grep -l 0x10de /sys/bus/pci/devices/*/vendor 2>/dev/null); do - g=$(grep -io "\"devid\":\"$(<${g%vendor}device)\"[^}]*branch\":\"[0-9]*" \ - "${ED}"/usr/share/nvidia/supported-gpus.json 2>/dev/null) - if [[ ${g} ]]; then - g=$((${g##*\"}+1)) - if ver_test -ge ${g}; then - NV_LEGACY_MASK=">=${CATEGORY}/${PN}-${g}" - break - fi - fi - done - rm "${ED}"/usr/share/nvidia/supported-gpus.json || die -} - -pkg_postinst() { - linux-mod-r1_pkg_postinst - - readme.gentoo_print_elog - - if [[ -r /proc/driver/nvidia/version && - $( ${EROOT}/etc/portage/package.mask/${PN}" - else - ewarn " echo '${NV_LEGACY_MASK}' >> ${EROOT}/etc/portage/package.mask" - fi - ewarn "...then downgrade to a legacy[1] branch if possible (not all old versions" - ewarn "are available or fully functional, may need to consider nouveau[2])." - ewarn "[1] https://www.nvidia.com/object/IO_32667.html" - ewarn "[2] https://wiki.gentoo.org/wiki/Nouveau" - fi - - if use kernel-open && [[ ! -v NV_HAD_KERNEL_OPEN ]]; then - ewarn - ewarn "Open source variant of ${PN} was selected, be warned it is experimental" - ewarn "and only for modern GPUs (e.g. GTX 1650+). Try to disable if run into issues." - ewarn "Please also see: ${EROOT}/usr/share/doc/${PF}/html/kernel_open.html" - fi - - if use wayland && use modules && [[ ! -v NV_HAD_WAYLAND ]]; then - elog - elog "With USE=wayland, this version of ${PN} sets nvidia-drm.modeset=1" - elog "in '${EROOT}/etc/modprobe.d/nvidia.conf'. This feature is considered" - elog "experimental but is required for wayland." - elog - elog "If you experience issues, either disable wayland or edit nvidia.conf." - elog "Of note, may possibly cause issues with SLI and Reverse PRIME." - fi -} diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-550.40.71-r1.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-550.40.71-r1.ebuild new file mode 100644 index 000000000000..de02b58759b9 --- /dev/null +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-550.40.71-r1.ebuild @@ -0,0 +1,558 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +MODULES_OPTIONAL_IUSE=+modules +inherit desktop flag-o-matic linux-mod-r1 readme.gentoo-r1 +inherit systemd toolchain-funcs unpacker user-info + +MODULES_KERNEL_MAX=6.10 +NV_PIN=550.107.02 + +DESCRIPTION="NVIDIA Accelerated Graphics Driver" +HOMEPAGE="https://developer.nvidia.com/vulkan-driver" +SRC_URI=" + https://developer.nvidia.com/downloads/vulkan-beta-${PV//.}-linux + -> NVIDIA-Linux-x86_64-${PV}.run + $(printf "https://download.nvidia.com/XFree86/%s/%s-${NV_PIN}.tar.bz2 " \ + nvidia-{installer,modprobe,persistenced,settings,xconfig}{,}) + https://github.com/NVIDIA/open-gpu-kernel-modules/archive/refs/tags/${PV}.tar.gz + -> open-gpu-kernel-modules-${PV}.tar.gz +" +# nvidia-installer is unused but here for GPL-2's "distribute sources" +S=${WORKDIR} + +LICENSE="NVIDIA-r2 Apache-2.0 BSD BSD-2 GPL-2 MIT ZLIB curl openssl" +SLOT="0/vulkan" +KEYWORDS="-* ~amd64" +IUSE="+X abi_x86_32 abi_x86_64 kernel-open persistenced powerd +static-libs +tools wayland" +REQUIRED_USE="kernel-open? ( modules )" + +COMMON_DEPEND=" + acct-group/video + X? ( x11-libs/libpciaccess ) + persistenced? ( + acct-user/nvpd + net-libs/libtirpc:= + ) + tools? ( + >=app-accessibility/at-spi2-core-2.46:2 + dev-libs/glib:2 + dev-libs/jansson:= + media-libs/harfbuzz:= + x11-libs/cairo + x11-libs/gdk-pixbuf:2 + x11-libs/gtk+:3[X] + x11-libs/libX11 + x11-libs/libXext + x11-libs/libXxf86vm + x11-libs/pango + ) +" +RDEPEND=" + ${COMMON_DEPEND} + dev-libs/openssl:0/3 + sys-libs/glibc + X? ( + media-libs/libglvnd[X,abi_x86_32(-)?] + x11-libs/libX11[abi_x86_32(-)?] + x11-libs/libXext[abi_x86_32(-)?] + ) + powerd? ( sys-apps/dbus[abi_x86_32(-)?] ) + wayland? ( + gui-libs/egl-gbm + >=gui-libs/egl-wayland-1.1.10 + ) +" +DEPEND=" + ${COMMON_DEPEND} + static-libs? ( + x11-base/xorg-proto + x11-libs/libX11 + x11-libs/libXext + ) + tools? ( + media-libs/libglvnd + sys-apps/dbus + x11-base/xorg-proto + x11-libs/libXrandr + x11-libs/libXv + x11-libs/libvdpau + ) +" +BDEPEND=" + sys-devel/m4 + virtual/pkgconfig +" + +QA_PREBUILT="lib/firmware/* opt/bin/* usr/lib*" + +PATCHES=( + "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch + "${FILESDIR}"/nvidia-settings-530.30.02-desktop.patch +) + +pkg_setup() { + use modules && [[ ${MERGE_TYPE} != binary ]] || return + + local CONFIG_CHECK=" + PROC_FS + ~DRM_KMS_HELPER + ~SYSVIPC + ~!LOCKDEP + ~!SLUB_DEBUG_ON + !DEBUG_MUTEXES + $(usev powerd '~CPU_FREQ') + " + + local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but needed for Xorg auto-detection + of drivers (no custom config), and for wayland / nvidia-drm.modeset=1. + Cannot be directly selected in the kernel's menuconfig, and may need + selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or + DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in." + + use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764 + + use kernel-open && CONFIG_CHECK+=" MMU_NOTIFIER" #843827 + local ERROR_MMU_NOTIFIER="CONFIG_MMU_NOTIFIER: is not set but needed to build with USE=kernel-open. + Cannot be directly selected in the kernel's menuconfig, and may need + selection of another option that requires it such as CONFIG_KVM." + + linux-mod-r1_pkg_setup +} + +src_prepare() { + # make patches usable across versions + rm nvidia-modprobe && mv nvidia-modprobe{-${NV_PIN},} || die + rm nvidia-persistenced && mv nvidia-persistenced{-${NV_PIN},} || die + rm nvidia-settings && mv nvidia-settings{-${NV_PIN},} || die + rm nvidia-xconfig && mv nvidia-xconfig{-${NV_PIN},} || die + mv open-gpu-kernel-modules-${PV} kernel-module-source || die + + default + + # prevent detection of incomplete kernel DRM support (bug #603818) + sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \ + -i kernel{,-module-source/kernel-open}/conftest.sh || die + + # adjust service files + sed 's/__USER__/nvpd/' \ + nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \ + > "${T}"/nvidia-persistenced.service || die + sed -i "s|/usr|${EPREFIX}/opt|" systemd/system/nvidia-powerd.service || die + + # use alternative vulkan icd option if USE=-X (bug #909181) + use X || sed -i 's/"libGLX/"libEGL/' nvidia_{layers,icd}.json || die + + # enable nvidia-drm.modeset=1 by default with USE=wayland + cp "${FILESDIR}"/nvidia-545.conf "${T}"/nvidia.conf || die + use !wayland || sed -i '/^#.*modeset=1$/s/^#//' "${T}"/nvidia.conf || die + + # makefile attempts to install wayland library even if not built + use wayland || sed -i 's/ WAYLAND_LIB_install$//' \ + nvidia-settings/src/Makefile || die +} + +src_compile() { + tc-export AR CC CXX LD OBJCOPY OBJDUMP PKG_CONFIG + + local xnvflags=-fPIC #840389 + # lto static libraries tend to cause problems without fat objects + tc-is-lto && xnvflags+=" $(test-flags-CC -ffat-lto-objects)" + + NV_ARGS=( + PREFIX="${EPREFIX}"/usr + HOST_CC="$(tc-getBUILD_CC)" + HOST_LD="$(tc-getBUILD_LD)" + BUILD_GTK2LIB= + NV_USE_BUNDLED_LIBJANSSON=0 + NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out + WAYLAND_AVAILABLE=$(usex wayland 1 0) + XNVCTRL_CFLAGS="${xnvflags}" + ) + + if use modules; then + local o_cflags=${CFLAGS} o_cxxflags=${CXXFLAGS} o_ldflags=${LDFLAGS} + + local modlistargs=video:kernel + if use kernel-open; then + modlistargs+=-module-source:kernel-module-source/kernel-open + + # environment flags are normally unused for modules, but nvidia + # uses it for building the "blob" and it is a bit fragile + filter-flags -fno-plt #912949 + filter-lto + CC=${KERNEL_CC} CXX=${KERNEL_CXX} strip-unsupported-flags + fi + + local modlist=( nvidia{,-drm,-modeset,-peermem,-uvm}=${modlistargs} ) + local modargs=( + IGNORE_CC_MISMATCH=yes NV_VERBOSE=1 + SYSOUT="${KV_OUT_DIR}" SYSSRC="${KV_DIR}" + ) + + # temporary workaround for bug #914468 + CPP="${KERNEL_CC} -E" tc-is-clang && addpredict "${KV_OUT_DIR}" + + linux-mod-r1_src_compile + CFLAGS=${o_cflags} CXXFLAGS=${o_cxxflags} LDFLAGS=${o_ldflags} + fi + + emake "${NV_ARGS[@]}" -C nvidia-modprobe + use persistenced && emake "${NV_ARGS[@]}" -C nvidia-persistenced + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig + + if use tools; then + # avoid noisy *very* noisy logs with deprecation warnings + CFLAGS="-Wno-deprecated-declarations ${CFLAGS}" \ + emake "${NV_ARGS[@]}" -C nvidia-settings + elif use static-libs; then + # pretend GTK+3 is available, not actually used (bug #880879) + emake "${NV_ARGS[@]}" BUILD_GTK3LIB=1 \ + -C nvidia-settings/src out/libXNVCtrl.a + fi +} + +src_install() { + local libdir=$(get_libdir) libdir32=$(ABI=x86 get_libdir) + + NV_ARGS+=( DESTDIR="${D}" LIBDIR="${ED}"/usr/${libdir} ) + + local -A paths=( + [APPLICATION_PROFILE]=/usr/share/nvidia + [CUDA_ICD]=/etc/OpenCL/vendors + [EGL_EXTERNAL_PLATFORM_JSON]=/usr/share/egl/egl_external_platform.d + [FIRMWARE]=/lib/firmware/nvidia/${PV} + [GBM_BACKEND_LIB_SYMLINK]=/usr/${libdir}/gbm + [GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d + [OPENGL_DATA]=/usr/share/nvidia + [VULKAN_ICD_JSON]=/usr/share/vulkan + [VULKANSC_ICD_JSON]=/usr/share/vulkansc + [WINE_LIB]=/usr/${libdir}/nvidia/wine + [XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d + + [GLX_MODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules/extensions + [GLX_MODULE_SYMLINK]=/usr/${libdir}/xorg/modules + [XMODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules + ) + + local skip_files=( + $(usev !X "libGLX_nvidia libglxserver_nvidia") + libGLX_indirect # non-glvnd unused fallback + libnvidia-{gtk,wayland-client} nvidia-{settings,xconfig} # from source + libnvidia-egl-gbm 15_nvidia_gbm # gui-libs/egl-gbm + libnvidia-egl-wayland 10_nvidia_wayland # gui-libs/egl-wayland + libnvidia-pkcs11.so # using the openssl3 version instead + ) + local skip_modules=( + $(usev !X "nvfbc vdpau xdriver") + $(usev !modules gsp) + $(usev !powerd powerd) + installer nvpd # handled separately / built from source + ) + local skip_types=( + GLVND_LIB GLVND_SYMLINK EGL_CLIENT.\* GLX_CLIENT.\* # media-libs/libglvnd + OPENCL_WRAPPER.\* # virtual/opencl + DOCUMENTATION DOT_DESKTOP .\*_SRC DKMS_CONF SYSTEMD_UNIT # handled separately / unused + ) + + local DOCS=( + README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json + nvidia-settings/doc/{FRAMELOCK,NV-CONTROL-API}.txt + ) + local HTML_DOCS=( html/. ) + einstalldocs + + local DISABLE_AUTOFORMATTING=yes + local DOC_CONTENTS="\ +Trusted users should be in the 'video' group to use NVIDIA devices. +You can add yourself by using: gpasswd -a my-user video\ +$(usev modules " + +Like all out-of-tree kernel modules, it is necessary to rebuild +${PN} after upgrading or rebuilding the Linux kernel +by for example running \`emerge @module-rebuild\`. Alternatively, +if using a distribution kernel (sys-kernel/gentoo-kernel{,-bin}), +this can be automated by setting USE=dist-kernel globally. + +Loaded kernel modules also must not mismatch with the installed +${PN} version (excluding -r revision), meaning should +ensure \`eselect kernel list\` points to the kernel that will be +booted before building and preferably reboot after upgrading +${PN} (the ebuild will emit a warning if mismatching). + +See '${EPREFIX}/etc/modprobe.d/nvidia.conf' for modules options.")\ +$(use amd64 && usev !abi_x86_32 " + +Note that without USE=abi_x86_32 on ${PN}, 32bit applications +(typically using wine / steam) will not be able to use GPU acceleration.") + +For additional information or for troubleshooting issues, please see +https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own +documentation that is installed alongside this README." + readme.gentoo_create_doc + + if use modules; then + linux-mod-r1_src_install + + insinto /etc/modprobe.d + doins "${T}"/nvidia.conf + + # used for gpu verification with binpkgs (not kept, see pkg_preinst) + insinto /usr/share/nvidia + doins supported-gpus/supported-gpus.json + fi + + emake "${NV_ARGS[@]}" -C nvidia-modprobe install + fowners :video /usr/bin/nvidia-modprobe #505092 + fperms 4710 /usr/bin/nvidia-modprobe + + if use persistenced; then + emake "${NV_ARGS[@]}" -C nvidia-persistenced install + newconfd "${FILESDIR}"/nvidia-persistenced.confd nvidia-persistenced + newinitd "${FILESDIR}"/nvidia-persistenced.initd nvidia-persistenced + systemd_dounit "${T}"/nvidia-persistenced.service + fi + + if use tools; then + emake "${NV_ARGS[@]}" -C nvidia-settings install + + doicon nvidia-settings/doc/nvidia-settings.png + domenu nvidia-settings/doc/nvidia-settings.desktop + + exeinto /etc/X11/xinit/xinitrc.d + newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings + fi + + if use static-libs; then + dolib.a nvidia-settings/src/out/libXNVCtrl.a + + insinto /usr/include/NVCtrl + doins nvidia-settings/src/libXNVCtrl/NVCtrl{Lib,}.h + fi + + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig install + + # mimic nvidia-installer by reading .manifest to install files + # 0:file 1:perms 2:type 3+:subtype/arguments -:module + local m into + while IFS=' ' read -ra m; do + ! [[ ${#m[@]} -ge 2 && ${m[-1]} =~ MODULE: ]] || + [[ " ${m[0]##*/}" =~ ^(\ ${skip_files[*]/%/.*|\\} )$ ]] || + [[ " ${m[2]}" =~ ^(\ ${skip_types[*]/%/|\\} )$ ]] || + has ${m[-1]#MODULE:} "${skip_modules[@]}" && continue + + case ${m[2]} in + MANPAGE) + gzip -dc ${m[0]} | newman - ${m[0]%.gz}; assert + continue + ;; + GBM_BACKEND_LIB_SYMLINK) m[4]=../${m[4]};; # missing ../ + VDPAU_SYMLINK) m[4]=vdpau/; m[5]=${m[5]#vdpau/};; # .so to vdpau/ + esac + + if [[ -v 'paths[${m[2]}]' ]]; then + into=${paths[${m[2]}]} + elif [[ ${m[2]} == EXPLICIT_PATH ]]; then + into=${m[3]} + elif [[ ${m[2]} == *_BINARY ]]; then + into=/opt/bin + elif [[ ${m[3]} == COMPAT32 ]]; then + use abi_x86_32 || continue + into=/usr/${libdir32} + elif [[ ${m[2]} == *_@(LIB|SYMLINK) ]]; then + into=/usr/${libdir} + else + die "No known installation path for ${m[0]}" + fi + [[ ${m[3]: -2} == ?/ ]] && into+=/${m[3]%/} + [[ ${m[4]: -2} == ?/ ]] && into+=/${m[4]%/} + + if [[ ${m[2]} =~ _SYMLINK$ ]]; then + [[ ${m[4]: -1} == / ]] && m[4]=${m[5]} + dosym ${m[4]} ${into}/${m[0]} + continue + fi + [[ ${m[0]} =~ ^libnvidia-ngx.so|^libnvidia-egl-gbm.so ]] && + dosym ${m[0]} ${into}/${m[0]%.so*}.so.1 # soname not in .manifest + + printf -v m[1] %o $((m[1] | 0200)) # 444->644 + insopts -m${m[1]} + insinto ${into} + doins ${m[0]} + done < .manifest || die + insopts -m0644 # reset + + # MODULE:installer non-skipped extras + : "$(systemd_get_sleepdir)" + exeinto "${_#"${EPREFIX}"}" + doexe systemd/system-sleep/nvidia + dobin systemd/nvidia-sleep.sh + systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend}.service + + dobin nvidia-bug-report.sh + + # MODULE:powerd extras + if use powerd; then + newinitd "${FILESDIR}"/nvidia-powerd.initd nvidia-powerd #923117 + systemd_dounit systemd/system/nvidia-powerd.service + + insinto /usr/share/dbus-1/system.d + doins nvidia-dbus.conf + fi + + # enabling is needed for sleep to work properly and little reason not to do + # it unconditionally for a better user experience + : "$(systemd_get_systemunitdir)" + local unitdir=${_#"${EPREFIX}"} + # not using relative symlinks to match systemd's own links + dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-hibernate.service + dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-resume.service + dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-suspend.service + dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-resume.service + # also add a custom elogind hook to do the equivalent of the above + exeinto /usr/lib/elogind/system-sleep + newexe "${FILESDIR}"/system-sleep.elogind nvidia + # /dev/null); do + g=$(grep -io "\"devid\":\"$(<${g%vendor}device)\"[^}]*branch\":\"[0-9]*" \ + "${ED}"/usr/share/nvidia/supported-gpus.json 2>/dev/null) + if [[ ${g} ]]; then + g=$((${g##*\"}+1)) + if ver_test -ge ${g}; then + NV_LEGACY_MASK=">=${CATEGORY}/${PN}-${g}" + break + fi + fi + done + rm "${ED}"/usr/share/nvidia/supported-gpus.json || die +} + +pkg_postinst() { + linux-mod-r1_pkg_postinst + + readme.gentoo_print_elog + + if [[ -r /proc/driver/nvidia/version && + $( ${EROOT}/etc/portage/package.mask/${PN}" + else + ewarn " echo '${NV_LEGACY_MASK}' >> ${EROOT}/etc/portage/package.mask" + fi + ewarn "...then downgrade to a legacy[1] branch if possible (not all old versions" + ewarn "are available or fully functional, may need to consider nouveau[2])." + ewarn "[1] https://www.nvidia.com/object/IO_32667.html" + ewarn "[2] https://wiki.gentoo.org/wiki/Nouveau" + fi + + if use kernel-open && [[ ! -v NV_HAD_KERNEL_OPEN ]]; then + ewarn + ewarn "Open source variant of ${PN} was selected, be warned it is experimental" + ewarn "and only for modern GPUs (e.g. GTX 1650+). Try to disable if run into issues." + ewarn "Please also see: ${EROOT}/usr/share/doc/${PF}/html/kernel_open.html" + fi + + if use wayland && use modules && [[ ! -v NV_HAD_WAYLAND ]]; then + elog + elog "With USE=wayland, this version of ${PN} sets nvidia-drm.modeset=1" + elog "in '${EROOT}/etc/modprobe.d/nvidia.conf'. This feature is considered" + elog "experimental but is required for wayland." + elog + elog "If you experience issues, either disable wayland or edit nvidia.conf." + elog "Of note, may possibly cause issues with SLI and Reverse PRIME." + fi + + # these can be removed after some time, only to help the transition + # given users are unlikely to do further custom solutions if it works + # (see also https://github.com/elogind/elogind/issues/272) + if grep -riq "^[^#]*HandleNvidiaSleep=yes" "${EROOT}"/etc/elogind/sleep.conf.d/ 2>/dev/null + then + ewarn + ewarn "!!! WARNING !!!" + ewarn "Detected HandleNvidiaSleep=yes in ${EROOT}/etc/elogind/sleep.conf.d/." + ewarn "This 'could' cause issues if used in combination with the new hook" + ewarn "installed by the ebuild to handle sleep using the official upstream" + ewarn "script. It is recommended to disable the option." + fi + if [[ $(realpath "${EROOT}"{/etc,{/usr,}/lib*}/elogind/system-sleep | sort | uniq | \ + xargs -d'\n' grep -Ril nvidia 2>/dev/null | wc -l) -gt 2 ]] + then + ewarn + ewarn "!!! WARNING !!!" + ewarn "Detected a custom script at ${EROOT}{/etc,{/usr,}/lib*}/elogind/system-sleep" + ewarn "referencing NVIDIA. This version of ${PN} has installed its own" + ewarn "hook at ${EROOT}/usr/lib/elogind/system-sleep/nvidia and it is recommended" + ewarn "to remove the custom one to avoid potential issues." + ewarn + ewarn "Feel free to ignore this warning if you know the other NVIDIA-related" + ewarn "scripts can be used together. The warning will be removed in the future." + fi + if [[ ${REPLACING_VERSIONS##* } ]] && + ver_test ${REPLACING_VERSIONS##* } -lt 550.40.71-r1 # may get repeated + then + elog + elog "For suspend/sleep, 'NVreg_PreserveVideoMemoryAllocations=1' is now default" + elog "with this version of ${PN}. This is recommended (or required) by" + elog "major DEs especially with wayland but, *if* experience regressions with" + elog "suspend, try reverting to =0 in '${EROOT}/etc/modprobe.d/nvidia.conf'." + elog + elog "May notably be an issue when using neither systemd nor elogind to suspend." + elog + elog "Also, the systemd suspend/hibernate/resume services are now enabled by" + elog "default, and for openrc+elogind a similar hook has been installed." + fi +} diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-550.40.71.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-550.40.71.ebuild deleted file mode 100644 index 0b678cefa151..000000000000 --- a/x11-drivers/nvidia-drivers/nvidia-drivers-550.40.71.ebuild +++ /dev/null @@ -1,502 +0,0 @@ -# Copyright 1999-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -MODULES_OPTIONAL_IUSE=+modules -inherit desktop flag-o-matic linux-mod-r1 readme.gentoo-r1 -inherit systemd toolchain-funcs unpacker user-info - -MODULES_KERNEL_MAX=6.10 -NV_PIN=550.107.02 - -DESCRIPTION="NVIDIA Accelerated Graphics Driver" -HOMEPAGE="https://developer.nvidia.com/vulkan-driver" -SRC_URI=" - https://developer.nvidia.com/downloads/vulkan-beta-${PV//.}-linux - -> NVIDIA-Linux-x86_64-${PV}.run - $(printf "https://download.nvidia.com/XFree86/%s/%s-${NV_PIN}.tar.bz2 " \ - nvidia-{installer,modprobe,persistenced,settings,xconfig}{,}) - https://github.com/NVIDIA/open-gpu-kernel-modules/archive/refs/tags/${PV}.tar.gz - -> open-gpu-kernel-modules-${PV}.tar.gz -" -# nvidia-installer is unused but here for GPL-2's "distribute sources" -S=${WORKDIR} - -LICENSE="NVIDIA-r2 Apache-2.0 BSD BSD-2 GPL-2 MIT ZLIB curl openssl" -SLOT="0/vulkan" -KEYWORDS="-* ~amd64" -IUSE="+X abi_x86_32 abi_x86_64 kernel-open persistenced powerd +static-libs +tools wayland" -REQUIRED_USE="kernel-open? ( modules )" - -COMMON_DEPEND=" - acct-group/video - X? ( x11-libs/libpciaccess ) - persistenced? ( - acct-user/nvpd - net-libs/libtirpc:= - ) - tools? ( - >=app-accessibility/at-spi2-core-2.46:2 - dev-libs/glib:2 - dev-libs/jansson:= - media-libs/harfbuzz:= - x11-libs/cairo - x11-libs/gdk-pixbuf:2 - x11-libs/gtk+:3[X] - x11-libs/libX11 - x11-libs/libXext - x11-libs/libXxf86vm - x11-libs/pango - ) -" -RDEPEND=" - ${COMMON_DEPEND} - dev-libs/openssl:0/3 - sys-libs/glibc - X? ( - media-libs/libglvnd[X,abi_x86_32(-)?] - x11-libs/libX11[abi_x86_32(-)?] - x11-libs/libXext[abi_x86_32(-)?] - ) - powerd? ( sys-apps/dbus[abi_x86_32(-)?] ) - wayland? ( - gui-libs/egl-gbm - >=gui-libs/egl-wayland-1.1.10 - ) -" -DEPEND=" - ${COMMON_DEPEND} - static-libs? ( - x11-base/xorg-proto - x11-libs/libX11 - x11-libs/libXext - ) - tools? ( - media-libs/libglvnd - sys-apps/dbus - x11-base/xorg-proto - x11-libs/libXrandr - x11-libs/libXv - x11-libs/libvdpau - ) -" -BDEPEND=" - sys-devel/m4 - virtual/pkgconfig -" - -QA_PREBUILT="lib/firmware/* opt/bin/* usr/lib*" - -PATCHES=( - "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch - "${FILESDIR}"/nvidia-settings-530.30.02-desktop.patch -) - -pkg_setup() { - use modules && [[ ${MERGE_TYPE} != binary ]] || return - - local CONFIG_CHECK=" - PROC_FS - ~DRM_KMS_HELPER - ~SYSVIPC - ~!LOCKDEP - ~!SLUB_DEBUG_ON - !DEBUG_MUTEXES - $(usev powerd '~CPU_FREQ') - " - - local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but needed for Xorg auto-detection - of drivers (no custom config), and for wayland / nvidia-drm.modeset=1. - Cannot be directly selected in the kernel's menuconfig, and may need - selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or - DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in." - - use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764 - - use kernel-open && CONFIG_CHECK+=" MMU_NOTIFIER" #843827 - local ERROR_MMU_NOTIFIER="CONFIG_MMU_NOTIFIER: is not set but needed to build with USE=kernel-open. - Cannot be directly selected in the kernel's menuconfig, and may need - selection of another option that requires it such as CONFIG_KVM." - - linux-mod-r1_pkg_setup -} - -src_prepare() { - # make patches usable across versions - rm nvidia-modprobe && mv nvidia-modprobe{-${NV_PIN},} || die - rm nvidia-persistenced && mv nvidia-persistenced{-${NV_PIN},} || die - rm nvidia-settings && mv nvidia-settings{-${NV_PIN},} || die - rm nvidia-xconfig && mv nvidia-xconfig{-${NV_PIN},} || die - mv open-gpu-kernel-modules-${PV} kernel-module-source || die - - default - - # prevent detection of incomplete kernel DRM support (bug #603818) - sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \ - -i kernel{,-module-source/kernel-open}/conftest.sh || die - - # adjust service files - sed 's/__USER__/nvpd/' \ - nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \ - > "${T}"/nvidia-persistenced.service || die - sed -i "s|/usr|${EPREFIX}/opt|" systemd/system/nvidia-powerd.service || die - - # use alternative vulkan icd option if USE=-X (bug #909181) - use X || sed -i 's/"libGLX/"libEGL/' nvidia_{layers,icd}.json || die - - # enable nvidia-drm.modeset=1 by default with USE=wayland - cp "${FILESDIR}"/nvidia-545.conf "${T}"/nvidia.conf || die - use !wayland || sed -i '/^#.*modeset=1$/s/^#//' "${T}"/nvidia.conf || die - - # makefile attempts to install wayland library even if not built - use wayland || sed -i 's/ WAYLAND_LIB_install$//' \ - nvidia-settings/src/Makefile || die -} - -src_compile() { - tc-export AR CC CXX LD OBJCOPY OBJDUMP PKG_CONFIG - - local xnvflags=-fPIC #840389 - # lto static libraries tend to cause problems without fat objects - tc-is-lto && xnvflags+=" $(test-flags-CC -ffat-lto-objects)" - - NV_ARGS=( - PREFIX="${EPREFIX}"/usr - HOST_CC="$(tc-getBUILD_CC)" - HOST_LD="$(tc-getBUILD_LD)" - BUILD_GTK2LIB= - NV_USE_BUNDLED_LIBJANSSON=0 - NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out - WAYLAND_AVAILABLE=$(usex wayland 1 0) - XNVCTRL_CFLAGS="${xnvflags}" - ) - - if use modules; then - local o_cflags=${CFLAGS} o_cxxflags=${CXXFLAGS} o_ldflags=${LDFLAGS} - - local modlistargs=video:kernel - if use kernel-open; then - modlistargs+=-module-source:kernel-module-source/kernel-open - - # environment flags are normally unused for modules, but nvidia - # uses it for building the "blob" and it is a bit fragile - filter-flags -fno-plt #912949 - filter-lto - CC=${KERNEL_CC} CXX=${KERNEL_CXX} strip-unsupported-flags - fi - - local modlist=( nvidia{,-drm,-modeset,-peermem,-uvm}=${modlistargs} ) - local modargs=( - IGNORE_CC_MISMATCH=yes NV_VERBOSE=1 - SYSOUT="${KV_OUT_DIR}" SYSSRC="${KV_DIR}" - ) - - # temporary workaround for bug #914468 - CPP="${KERNEL_CC} -E" tc-is-clang && addpredict "${KV_OUT_DIR}" - - linux-mod-r1_src_compile - CFLAGS=${o_cflags} CXXFLAGS=${o_cxxflags} LDFLAGS=${o_ldflags} - fi - - emake "${NV_ARGS[@]}" -C nvidia-modprobe - use persistenced && emake "${NV_ARGS[@]}" -C nvidia-persistenced - use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig - - if use tools; then - # avoid noisy *very* noisy logs with deprecation warnings - CFLAGS="-Wno-deprecated-declarations ${CFLAGS}" \ - emake "${NV_ARGS[@]}" -C nvidia-settings - elif use static-libs; then - # pretend GTK+3 is available, not actually used (bug #880879) - emake "${NV_ARGS[@]}" BUILD_GTK3LIB=1 \ - -C nvidia-settings/src out/libXNVCtrl.a - fi -} - -src_install() { - local libdir=$(get_libdir) libdir32=$(ABI=x86 get_libdir) - - NV_ARGS+=( DESTDIR="${D}" LIBDIR="${ED}"/usr/${libdir} ) - - local -A paths=( - [APPLICATION_PROFILE]=/usr/share/nvidia - [CUDA_ICD]=/etc/OpenCL/vendors - [EGL_EXTERNAL_PLATFORM_JSON]=/usr/share/egl/egl_external_platform.d - [FIRMWARE]=/lib/firmware/nvidia/${PV} - [GBM_BACKEND_LIB_SYMLINK]=/usr/${libdir}/gbm - [GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d - [OPENGL_DATA]=/usr/share/nvidia - [VULKAN_ICD_JSON]=/usr/share/vulkan - [VULKANSC_ICD_JSON]=/usr/share/vulkansc - [WINE_LIB]=/usr/${libdir}/nvidia/wine - [XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d - - [GLX_MODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules/extensions - [GLX_MODULE_SYMLINK]=/usr/${libdir}/xorg/modules - [XMODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules - ) - - local skip_files=( - $(usev !X "libGLX_nvidia libglxserver_nvidia") - libGLX_indirect # non-glvnd unused fallback - libnvidia-{gtk,wayland-client} nvidia-{settings,xconfig} # from source - libnvidia-egl-gbm 15_nvidia_gbm # gui-libs/egl-gbm - libnvidia-egl-wayland 10_nvidia_wayland # gui-libs/egl-wayland - libnvidia-pkcs11.so # using the openssl3 version instead - ) - local skip_modules=( - $(usev !X "nvfbc vdpau xdriver") - $(usev !modules gsp) - $(usev !powerd powerd) - installer nvpd # handled separately / built from source - ) - local skip_types=( - GLVND_LIB GLVND_SYMLINK EGL_CLIENT.\* GLX_CLIENT.\* # media-libs/libglvnd - OPENCL_WRAPPER.\* # virtual/opencl - DOCUMENTATION DOT_DESKTOP .\*_SRC DKMS_CONF SYSTEMD_UNIT # handled separately / unused - ) - - local DOCS=( - README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json - nvidia-settings/doc/{FRAMELOCK,NV-CONTROL-API}.txt - ) - local HTML_DOCS=( html/. ) - einstalldocs - - local DISABLE_AUTOFORMATTING=yes - local DOC_CONTENTS="\ -Trusted users should be in the 'video' group to use NVIDIA devices. -You can add yourself by using: gpasswd -a my-user video\ -$(usev modules " - -Like all out-of-tree kernel modules, it is necessary to rebuild -${PN} after upgrading or rebuilding the Linux kernel -by for example running \`emerge @module-rebuild\`. Alternatively, -if using a distribution kernel (sys-kernel/gentoo-kernel{,-bin}), -this can be automated by setting USE=dist-kernel globally. - -Loaded kernel modules also must not mismatch with the installed -${PN} version (excluding -r revision), meaning should -ensure \`eselect kernel list\` points to the kernel that will be -booted before building and preferably reboot after upgrading -${PN} (the ebuild will emit a warning if mismatching). - -See '${EPREFIX}/etc/modprobe.d/nvidia.conf' for modules options.")\ -$(use amd64 && usev !abi_x86_32 " - -Note that without USE=abi_x86_32 on ${PN}, 32bit applications -(typically using wine / steam) will not be able to use GPU acceleration.") - -For additional information or for troubleshooting issues, please see -https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own -documentation that is installed alongside this README." - readme.gentoo_create_doc - - if use modules; then - linux-mod-r1_src_install - - insinto /etc/modprobe.d - doins "${T}"/nvidia.conf - - # used for gpu verification with binpkgs (not kept, see pkg_preinst) - insinto /usr/share/nvidia - doins supported-gpus/supported-gpus.json - fi - - emake "${NV_ARGS[@]}" -C nvidia-modprobe install - fowners :video /usr/bin/nvidia-modprobe #505092 - fperms 4710 /usr/bin/nvidia-modprobe - - if use persistenced; then - emake "${NV_ARGS[@]}" -C nvidia-persistenced install - newconfd "${FILESDIR}"/nvidia-persistenced.confd nvidia-persistenced - newinitd "${FILESDIR}"/nvidia-persistenced.initd nvidia-persistenced - systemd_dounit "${T}"/nvidia-persistenced.service - fi - - if use tools; then - emake "${NV_ARGS[@]}" -C nvidia-settings install - - doicon nvidia-settings/doc/nvidia-settings.png - domenu nvidia-settings/doc/nvidia-settings.desktop - - exeinto /etc/X11/xinit/xinitrc.d - newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings - fi - - if use static-libs; then - dolib.a nvidia-settings/src/out/libXNVCtrl.a - - insinto /usr/include/NVCtrl - doins nvidia-settings/src/libXNVCtrl/NVCtrl{Lib,}.h - fi - - use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig install - - # mimic nvidia-installer by reading .manifest to install files - # 0:file 1:perms 2:type 3+:subtype/arguments -:module - local m into - while IFS=' ' read -ra m; do - ! [[ ${#m[@]} -ge 2 && ${m[-1]} =~ MODULE: ]] || - [[ " ${m[0]##*/}" =~ ^(\ ${skip_files[*]/%/.*|\\} )$ ]] || - [[ " ${m[2]}" =~ ^(\ ${skip_types[*]/%/|\\} )$ ]] || - has ${m[-1]#MODULE:} "${skip_modules[@]}" && continue - - case ${m[2]} in - MANPAGE) - gzip -dc ${m[0]} | newman - ${m[0]%.gz}; assert - continue - ;; - GBM_BACKEND_LIB_SYMLINK) m[4]=../${m[4]};; # missing ../ - VDPAU_SYMLINK) m[4]=vdpau/; m[5]=${m[5]#vdpau/};; # .so to vdpau/ - esac - - if [[ -v 'paths[${m[2]}]' ]]; then - into=${paths[${m[2]}]} - elif [[ ${m[2]} == EXPLICIT_PATH ]]; then - into=${m[3]} - elif [[ ${m[2]} == *_BINARY ]]; then - into=/opt/bin - elif [[ ${m[3]} == COMPAT32 ]]; then - use abi_x86_32 || continue - into=/usr/${libdir32} - elif [[ ${m[2]} == *_@(LIB|SYMLINK) ]]; then - into=/usr/${libdir} - else - die "No known installation path for ${m[0]}" - fi - [[ ${m[3]: -2} == ?/ ]] && into+=/${m[3]%/} - [[ ${m[4]: -2} == ?/ ]] && into+=/${m[4]%/} - - if [[ ${m[2]} =~ _SYMLINK$ ]]; then - [[ ${m[4]: -1} == / ]] && m[4]=${m[5]} - dosym ${m[4]} ${into}/${m[0]} - continue - fi - [[ ${m[0]} =~ ^libnvidia-ngx.so|^libnvidia-egl-gbm.so ]] && - dosym ${m[0]} ${into}/${m[0]%.so*}.so.1 # soname not in .manifest - - printf -v m[1] %o $((m[1] | 0200)) # 444->644 - insopts -m${m[1]} - insinto ${into} - doins ${m[0]} - done < .manifest || die - insopts -m0644 # reset - - # MODULE:installer non-skipped extras - : "$(systemd_get_sleepdir)" - exeinto "${_#"${EPREFIX}"}" - doexe systemd/system-sleep/nvidia - dobin systemd/nvidia-sleep.sh - systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend}.service - - dobin nvidia-bug-report.sh - - # MODULE:powerd extras - if use powerd; then - newinitd "${FILESDIR}"/nvidia-powerd.initd nvidia-powerd #923117 - systemd_dounit systemd/system/nvidia-powerd.service - - insinto /usr/share/dbus-1/system.d - doins nvidia-dbus.conf - fi - - # symlink non-versioned so nvidia-settings can use it even if misdetected - dosym nvidia-application-profiles-${PV}-key-documentation \ - ${paths[APPLICATION_PROFILE]}/nvidia-application-profiles-key-documentation - - # don't attempt to strip firmware files (silences errors) - dostrip -x ${paths[FIRMWARE]} - - # sandbox issues with /dev/nvidiactl others (bug #904292,#921578) - # are widespread and sometime affect revdeps of packages built with - # USE=opencl/cuda making it hard to manage in ebuilds (minimal set, - # ebuilds should handle manually if need others or addwrite) - insinto /etc/sandbox.d - newins - 20nvidia <<<'SANDBOX_PREDICT="/dev/nvidiactl:/dev/nvidia-caps:/dev/char"' -} - -pkg_preinst() { - has_version "${CATEGORY}/${PN}[kernel-open]" && NV_HAD_KERNEL_OPEN= - has_version "${CATEGORY}/${PN}[wayland]" && NV_HAD_WAYLAND= - - use modules || return - - # set video group id based on live system (bug #491414) - local g=$(egetent group video | cut -d: -f3) - [[ ${g} =~ ^[0-9]+$ ]] || die "Failed to determine video group id (got '${g}')" - sed -i "s/@VIDEOGID@/${g}/" "${ED}"/etc/modprobe.d/nvidia.conf || die - - # try to find driver mismatches using temporary supported-gpus.json - for g in $(grep -l 0x10de /sys/bus/pci/devices/*/vendor 2>/dev/null); do - g=$(grep -io "\"devid\":\"$(<${g%vendor}device)\"[^}]*branch\":\"[0-9]*" \ - "${ED}"/usr/share/nvidia/supported-gpus.json 2>/dev/null) - if [[ ${g} ]]; then - g=$((${g##*\"}+1)) - if ver_test -ge ${g}; then - NV_LEGACY_MASK=">=${CATEGORY}/${PN}-${g}" - break - fi - fi - done - rm "${ED}"/usr/share/nvidia/supported-gpus.json || die -} - -pkg_postinst() { - linux-mod-r1_pkg_postinst - - readme.gentoo_print_elog - - if [[ -r /proc/driver/nvidia/version && - $( ${EROOT}/etc/portage/package.mask/${PN}" - else - ewarn " echo '${NV_LEGACY_MASK}' >> ${EROOT}/etc/portage/package.mask" - fi - ewarn "...then downgrade to a legacy[1] branch if possible (not all old versions" - ewarn "are available or fully functional, may need to consider nouveau[2])." - ewarn "[1] https://www.nvidia.com/object/IO_32667.html" - ewarn "[2] https://wiki.gentoo.org/wiki/Nouveau" - fi - - if use kernel-open && [[ ! -v NV_HAD_KERNEL_OPEN ]]; then - ewarn - ewarn "Open source variant of ${PN} was selected, be warned it is experimental" - ewarn "and only for modern GPUs (e.g. GTX 1650+). Try to disable if run into issues." - ewarn "Please also see: ${EROOT}/usr/share/doc/${PF}/html/kernel_open.html" - fi - - if use wayland && use modules && [[ ! -v NV_HAD_WAYLAND ]]; then - elog - elog "With USE=wayland, this version of ${PN} sets nvidia-drm.modeset=1" - elog "in '${EROOT}/etc/modprobe.d/nvidia.conf'. This feature is considered" - elog "experimental but is required for wayland." - elog - elog "If you experience issues, either disable wayland or edit nvidia.conf." - elog "Of note, may possibly cause issues with SLI and Reverse PRIME." - fi -} diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-560.35.03-r1.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-560.35.03-r1.ebuild new file mode 100644 index 000000000000..31a3eab6d6e2 --- /dev/null +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-560.35.03-r1.ebuild @@ -0,0 +1,571 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +MODULES_OPTIONAL_IUSE=+modules +inherit desktop flag-o-matic linux-mod-r1 readme.gentoo-r1 +inherit systemd toolchain-funcs unpacker user-info + +MODULES_KERNEL_MAX=6.10 +NV_URI="https://download.nvidia.com/XFree86/" + +DESCRIPTION="NVIDIA Accelerated Graphics Driver" +HOMEPAGE="https://www.nvidia.com/download/index.aspx" +SRC_URI=" + amd64? ( ${NV_URI}Linux-x86_64/${PV}/NVIDIA-Linux-x86_64-${PV}.run ) + arm64? ( ${NV_URI}Linux-aarch64/${PV}/NVIDIA-Linux-aarch64-${PV}.run ) + $(printf "${NV_URI}%s/%s-${PV}.tar.bz2 " \ + nvidia-{installer,modprobe,persistenced,settings,xconfig}{,}) + ${NV_URI}NVIDIA-kernel-module-source/NVIDIA-kernel-module-source-${PV}.tar.xz +" +# nvidia-installer is unused but here for GPL-2's "distribute sources" +S=${WORKDIR} + +LICENSE="NVIDIA-r2 Apache-2.0 BSD BSD-2 GPL-2 MIT ZLIB curl openssl" +SLOT="0/${PV%%.*}" +KEYWORDS="-* ~amd64 ~arm64" +# note: kernel-open is an upstream default in >=560 if all GPUs on the system +# support it but, since no automagic here, keeping it off for the wider support +IUSE="+X abi_x86_32 abi_x86_64 kernel-open persistenced powerd +static-libs +tools wayland" +REQUIRED_USE="kernel-open? ( modules )" + +COMMON_DEPEND=" + acct-group/video + X? ( x11-libs/libpciaccess ) + persistenced? ( + acct-user/nvpd + net-libs/libtirpc:= + ) + tools? ( + >=app-accessibility/at-spi2-core-2.46:2 + dev-libs/glib:2 + dev-libs/jansson:= + media-libs/harfbuzz:= + x11-libs/cairo + x11-libs/gdk-pixbuf:2 + x11-libs/gtk+:3[X] + x11-libs/libX11 + x11-libs/libXext + x11-libs/libXxf86vm + x11-libs/pango + ) +" +RDEPEND=" + ${COMMON_DEPEND} + dev-libs/openssl:0/3 + sys-libs/glibc + X? ( + media-libs/libglvnd[X,abi_x86_32(-)?] + x11-libs/libX11[abi_x86_32(-)?] + x11-libs/libXext[abi_x86_32(-)?] + ) + powerd? ( sys-apps/dbus[abi_x86_32(-)?] ) + wayland? ( + >=gui-libs/egl-gbm-1.1.1-r2[abi_x86_32(-)?] + >=gui-libs/egl-wayland-1.1.13.1[abi_x86_32(-)?] + ) +" +DEPEND=" + ${COMMON_DEPEND} + static-libs? ( + x11-base/xorg-proto + x11-libs/libX11 + x11-libs/libXext + ) + tools? ( + dev-util/vulkan-headers + media-libs/libglvnd + sys-apps/dbus + x11-base/xorg-proto + x11-libs/libXrandr + x11-libs/libXv + x11-libs/libvdpau + ) +" +BDEPEND=" + sys-devel/m4 + virtual/pkgconfig +" + +QA_PREBUILT="lib/firmware/* opt/bin/* usr/lib*" + +PATCHES=( + "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch + "${FILESDIR}"/nvidia-settings-530.30.02-desktop.patch +) + +pkg_setup() { + use modules && [[ ${MERGE_TYPE} != binary ]] || return + + local CONFIG_CHECK=" + PROC_FS + ~DRM_KMS_HELPER + ~SYSVIPC + ~!LOCKDEP + ~!SLUB_DEBUG_ON + !DEBUG_MUTEXES + $(usev powerd '~CPU_FREQ') + " + + local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but needed for Xorg auto-detection + of drivers (no custom config), and for wayland / nvidia-drm.modeset=1. + Cannot be directly selected in the kernel's menuconfig, and may need + selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or + DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in." + + use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764 + + use kernel-open && CONFIG_CHECK+=" MMU_NOTIFIER" #843827 + local ERROR_MMU_NOTIFIER="CONFIG_MMU_NOTIFIER: is not set but needed to build with USE=kernel-open. + Cannot be directly selected in the kernel's menuconfig, and may need + selection of another option that requires it such as CONFIG_KVM." + + linux-mod-r1_pkg_setup +} + +src_prepare() { + # make patches usable across versions + rm nvidia-modprobe && mv nvidia-modprobe{-${PV},} || die + rm nvidia-persistenced && mv nvidia-persistenced{-${PV},} || die + rm nvidia-settings && mv nvidia-settings{-${PV},} || die + rm nvidia-xconfig && mv nvidia-xconfig{-${PV},} || die + mv NVIDIA-kernel-module-source-${PV} kernel-module-source || die + + default + + # prevent detection of incomplete kernel DRM support (bug #603818) + sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \ + -i kernel{,-module-source/kernel-open}/conftest.sh || die + + # adjust service files + sed 's/__USER__/nvpd/' \ + nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \ + > "${T}"/nvidia-persistenced.service || die + sed -i "s|/usr|${EPREFIX}/opt|" systemd/system/nvidia-powerd.service || die + + # use alternative vulkan icd option if USE=-X (bug #909181) + use X || sed -i 's/"libGLX/"libEGL/' nvidia_{layers,icd}.json || die + + # enable nvidia-drm.modeset=1 by default with USE=wayland + cp "${FILESDIR}"/nvidia-555.conf "${T}"/nvidia.conf || die + use !wayland || sed -i '/^#.*modeset=1$/s/^#//' "${T}"/nvidia.conf || die + + # makefile attempts to install wayland library even if not built + use wayland || sed -i 's/ WAYLAND_LIB_install$//' \ + nvidia-settings/src/Makefile || die +} + +src_compile() { + tc-export AR CC CXX LD OBJCOPY OBJDUMP PKG_CONFIG + + local xnvflags=-fPIC #840389 + # lto static libraries tend to cause problems without fat objects + tc-is-lto && xnvflags+=" $(test-flags-CC -ffat-lto-objects)" + + NV_ARGS=( + PREFIX="${EPREFIX}"/usr + HOST_CC="$(tc-getBUILD_CC)" + HOST_LD="$(tc-getBUILD_LD)" + BUILD_GTK2LIB= + NV_USE_BUNDLED_LIBJANSSON=0 + NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out + WAYLAND_AVAILABLE=$(usex wayland 1 0) + XNVCTRL_CFLAGS="${xnvflags}" + ) + + if use modules; then + local o_cflags=${CFLAGS} o_cxxflags=${CXXFLAGS} o_ldflags=${LDFLAGS} + + local modlistargs=video:kernel + if use kernel-open; then + modlistargs+=-module-source:kernel-module-source/kernel-open + + # environment flags are normally unused for modules, but nvidia + # uses it for building the "blob" and it is a bit fragile + filter-flags -fno-plt #912949 + filter-lto + CC=${KERNEL_CC} CXX=${KERNEL_CXX} strip-unsupported-flags + fi + + local modlist=( nvidia{,-drm,-modeset,-peermem,-uvm}=${modlistargs} ) + local modargs=( + IGNORE_CC_MISMATCH=yes NV_VERBOSE=1 + SYSOUT="${KV_OUT_DIR}" SYSSRC="${KV_DIR}" + ) + + # temporary workaround for bug #914468 + CPP="${KERNEL_CC} -E" tc-is-clang && addpredict "${KV_OUT_DIR}" + + linux-mod-r1_src_compile + CFLAGS=${o_cflags} CXXFLAGS=${o_cxxflags} LDFLAGS=${o_ldflags} + fi + + emake "${NV_ARGS[@]}" -C nvidia-modprobe + use persistenced && emake "${NV_ARGS[@]}" -C nvidia-persistenced + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig + + if use tools; then + # avoid noisy *very* noisy logs with deprecation warnings + CFLAGS="-Wno-deprecated-declarations ${CFLAGS}" \ + emake "${NV_ARGS[@]}" -C nvidia-settings + elif use static-libs; then + # pretend GTK+3 is available, not actually used (bug #880879) + emake "${NV_ARGS[@]}" BUILD_GTK3LIB=1 \ + -C nvidia-settings/src out/libXNVCtrl.a + fi +} + +src_install() { + local libdir=$(get_libdir) libdir32=$(ABI=x86 get_libdir) + + NV_ARGS+=( DESTDIR="${D}" LIBDIR="${ED}"/usr/${libdir} ) + + local -A paths=( + [APPLICATION_PROFILE]=/usr/share/nvidia + [CUDA_ICD]=/etc/OpenCL/vendors + [EGL_EXTERNAL_PLATFORM_JSON]=/usr/share/egl/egl_external_platform.d + [FIRMWARE]=/lib/firmware/nvidia/${PV} + [GBM_BACKEND_LIB_SYMLINK]=/usr/${libdir}/gbm + [GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d + [OPENGL_DATA]=/usr/share/nvidia + [VULKAN_ICD_JSON]=/usr/share/vulkan + [VULKANSC_ICD_JSON]=/usr/share/vulkansc + [WINE_LIB]=/usr/${libdir}/nvidia/wine + [XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d + + [GLX_MODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules/extensions + [GLX_MODULE_SYMLINK]=/usr/${libdir}/xorg/modules + [XMODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules + ) + + local skip_files=( + $(usev !X "libGLX_nvidia libglxserver_nvidia") + libGLX_indirect # non-glvnd unused fallback + libnvidia-{gtk,wayland-client} nvidia-{settings,xconfig} # from source + libnvidia-egl-gbm 15_nvidia_gbm # gui-libs/egl-gbm + libnvidia-egl-wayland 10_nvidia_wayland # gui-libs/egl-wayland + libnvidia-pkcs11.so # using the openssl3 version instead + ) + local skip_modules=( + $(usev !X "nvfbc vdpau xdriver") + $(usev !modules gsp) + $(usev !powerd powerd) + installer nvpd # handled separately / built from source + ) + local skip_types=( + GLVND_LIB GLVND_SYMLINK EGL_CLIENT.\* GLX_CLIENT.\* # media-libs/libglvnd + OPENCL_WRAPPER.\* # virtual/opencl + DOCUMENTATION DOT_DESKTOP .\*_SRC DKMS_CONF SYSTEMD_UNIT # handled separately / unused + ) + + local DOCS=( + README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json + nvidia-settings/doc/{FRAMELOCK,NV-CONTROL-API}.txt + ) + local HTML_DOCS=( html/. ) + einstalldocs + + local DISABLE_AUTOFORMATTING=yes + local DOC_CONTENTS="\ +Trusted users should be in the 'video' group to use NVIDIA devices. +You can add yourself by using: gpasswd -a my-user video\ +$(usev modules " + +Like all out-of-tree kernel modules, it is necessary to rebuild +${PN} after upgrading or rebuilding the Linux kernel +by for example running \`emerge @module-rebuild\`. Alternatively, +if using a distribution kernel (sys-kernel/gentoo-kernel{,-bin}), +this can be automated by setting USE=dist-kernel globally. + +Loaded kernel modules also must not mismatch with the installed +${PN} version (excluding -r revision), meaning should +ensure \`eselect kernel list\` points to the kernel that will be +booted before building and preferably reboot after upgrading +${PN} (the ebuild will emit a warning if mismatching). + +See '${EPREFIX}/etc/modprobe.d/nvidia.conf' for modules options.")\ +$(use amd64 && usev !abi_x86_32 " + +Note that without USE=abi_x86_32 on ${PN}, 32bit applications +(typically using wine / steam) will not be able to use GPU acceleration.") + +For additional information or for troubleshooting issues, please see +https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own +documentation that is installed alongside this README." + readme.gentoo_create_doc + + if use modules; then + linux-mod-r1_src_install + + insinto /etc/modprobe.d + doins "${T}"/nvidia.conf + + # used for gpu verification with binpkgs (not kept, see pkg_preinst) + insinto /usr/share/nvidia + doins supported-gpus/supported-gpus.json + fi + + emake "${NV_ARGS[@]}" -C nvidia-modprobe install + fowners :video /usr/bin/nvidia-modprobe #505092 + fperms 4710 /usr/bin/nvidia-modprobe + + if use persistenced; then + emake "${NV_ARGS[@]}" -C nvidia-persistenced install + newconfd "${FILESDIR}"/nvidia-persistenced.confd nvidia-persistenced + newinitd "${FILESDIR}"/nvidia-persistenced.initd nvidia-persistenced + systemd_dounit "${T}"/nvidia-persistenced.service + fi + + if use tools; then + emake "${NV_ARGS[@]}" -C nvidia-settings install + + doicon nvidia-settings/doc/nvidia-settings.png + domenu nvidia-settings/doc/nvidia-settings.desktop + + exeinto /etc/X11/xinit/xinitrc.d + newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings + fi + + if use static-libs; then + dolib.a nvidia-settings/src/out/libXNVCtrl.a + + insinto /usr/include/NVCtrl + doins nvidia-settings/src/libXNVCtrl/NVCtrl{Lib,}.h + fi + + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig install + + # mimic nvidia-installer by reading .manifest to install files + # 0:file 1:perms 2:type 3+:subtype/arguments -:module + local m into + while IFS=' ' read -ra m; do + ! [[ ${#m[@]} -ge 2 && ${m[-1]} =~ MODULE: ]] || + [[ " ${m[0]##*/}" =~ ^(\ ${skip_files[*]/%/.*|\\} )$ ]] || + [[ " ${m[2]}" =~ ^(\ ${skip_types[*]/%/|\\} )$ ]] || + has ${m[-1]#MODULE:} "${skip_modules[@]}" && continue + + case ${m[2]} in + MANPAGE) + gzip -dc ${m[0]} | newman - ${m[0]%.gz}; assert + continue + ;; + GBM_BACKEND_LIB_SYMLINK) m[4]=../${m[4]};; # missing ../ + VDPAU_SYMLINK) m[4]=vdpau/; m[5]=${m[5]#vdpau/};; # .so to vdpau/ + esac + + if [[ -v 'paths[${m[2]}]' ]]; then + into=${paths[${m[2]}]} + elif [[ ${m[2]} == EXPLICIT_PATH ]]; then + into=${m[3]} + elif [[ ${m[2]} == *_BINARY ]]; then + into=/opt/bin + elif [[ ${m[3]} == COMPAT32 ]]; then + use abi_x86_32 || continue + into=/usr/${libdir32} + elif [[ ${m[2]} == *_@(LIB|SYMLINK) ]]; then + into=/usr/${libdir} + else + die "No known installation path for ${m[0]}" + fi + [[ ${m[3]: -2} == ?/ ]] && into+=/${m[3]%/} + [[ ${m[4]: -2} == ?/ ]] && into+=/${m[4]%/} + + if [[ ${m[2]} =~ _SYMLINK$ ]]; then + [[ ${m[4]: -1} == / ]] && m[4]=${m[5]} + dosym ${m[4]} ${into}/${m[0]} + continue + fi + # avoid portage warning due to missing soname links in manifest + [[ ${m[0]} =~ .*((libnvidia-ngx.so|libnvidia-egl-gbm.so).*) ]] && + dosym ${BASH_REMATCH[1]} ${into}/${BASH_REMATCH[2]}.1 + + printf -v m[1] %o $((m[1] | 0200)) # 444->644 + insopts -m${m[1]} + insinto ${into} + doins ${m[0]} + done < .manifest || die + insopts -m0644 # reset + + # MODULE:installer non-skipped extras + : "$(systemd_get_sleepdir)" + exeinto "${_#"${EPREFIX}"}" + doexe systemd/system-sleep/nvidia + dobin systemd/nvidia-sleep.sh + systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend}.service + + dobin nvidia-bug-report.sh + + # MODULE:powerd extras + if use powerd; then + newinitd "${FILESDIR}"/nvidia-powerd.initd nvidia-powerd #923117 + systemd_dounit systemd/system/nvidia-powerd.service + + insinto /usr/share/dbus-1/system.d + doins nvidia-dbus.conf + fi + + # enabling is needed for sleep to work properly and little reason not to do + # it unconditionally for a better user experience + : "$(systemd_get_systemunitdir)" + local unitdir=${_#"${EPREFIX}"} + # not using relative symlinks to match systemd's own links + dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-hibernate.service + dosym {"${unitdir}",/etc/systemd/system/systemd-hibernate.service.wants}/nvidia-resume.service + dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-suspend.service + dosym {"${unitdir}",/etc/systemd/system/systemd-suspend.service.wants}/nvidia-resume.service + # also add a custom elogind hook to do the equivalent of the above + exeinto /usr/lib/elogind/system-sleep + newexe "${FILESDIR}"/system-sleep.elogind nvidia + # /dev/null); do + g=$(grep -io "\"devid\":\"$(<${g%vendor}device)\"[^}]*branch\":\"[0-9]*" \ + "${ED}"/usr/share/nvidia/supported-gpus.json 2>/dev/null) + if [[ ${g} ]]; then + g=$((${g##*\"}+1)) + if ver_test -ge ${g}; then + NV_LEGACY_MASK=">=${CATEGORY}/${PN}-${g}" + break + fi + fi + done + rm "${ED}"/usr/share/nvidia/supported-gpus.json || die +} + +pkg_postinst() { + linux-mod-r1_pkg_postinst + + readme.gentoo_print_elog + + if [[ -r /proc/driver/nvidia/version && + $( ${EROOT}/etc/portage/package.mask/${PN}" + else + ewarn " echo '${NV_LEGACY_MASK}' >> ${EROOT}/etc/portage/package.mask" + fi + ewarn "...then downgrade to a legacy[1] branch if possible (not all old versions" + ewarn "are available or fully functional, may need to consider nouveau[2])." + ewarn "[1] https://www.nvidia.com/object/IO_32667.html" + ewarn "[2] https://wiki.gentoo.org/wiki/Nouveau" + fi + + if use kernel-open && [[ ! -v NV_HAD_KERNEL_OPEN ]]; then + ewarn + ewarn "Open source variant of ${PN} was selected, note that it requires" + ewarn "Turing/Ampere+ GPUs (aka GTX 1650+). Try disabling if run into issues." + ewarn "Also see: ${EROOT}/usr/share/doc/${PF}/html/kernel_open.html" + fi + + if use wayland && use modules && [[ ! -v NV_HAD_WAYLAND ]]; then + elog + elog "With USE=wayland, this version of ${PN} sets nvidia-drm.modeset=1" + elog "in '${EROOT}/etc/modprobe.d/nvidia.conf'. This feature is considered" + elog "experimental but is required for wayland." + elog + elog "If you experience issues, either disable wayland or edit nvidia.conf." + elog "Of note, may possibly cause issues with SLI and Reverse PRIME." + fi + + if use !kernel-open && [[ ${REPLACING_VERSIONS##* } ]] && + ver_test ${REPLACING_VERSIONS##* } -lt 555 + then + elog + elog "If using a Turing/Ampere+ GPU (aka GTX 1650+), note that >=nvidia-drivers-555" + elog "enables the use of the GSP firmware by default. *If* experience regressions," + elog "please see '${EROOT}/etc/modprobe.d/nvidia.conf' to optionally disable." + fi + + # these can be removed after some time, only to help the transition + # given users are unlikely to do further custom solutions if it works + # (see also https://github.com/elogind/elogind/issues/272) + if grep -riq "^[^#]*HandleNvidiaSleep=yes" "${EROOT}"/etc/elogind/sleep.conf.d/ 2>/dev/null + then + ewarn + ewarn "!!! WARNING !!!" + ewarn "Detected HandleNvidiaSleep=yes in ${EROOT}/etc/elogind/sleep.conf.d/." + ewarn "This 'could' cause issues if used in combination with the new hook" + ewarn "installed by the ebuild to handle sleep using the official upstream" + ewarn "script. It is recommended to disable the option." + fi + if [[ $(realpath "${EROOT}"{/etc,{/usr,}/lib*}/elogind/system-sleep | sort | uniq | \ + xargs -d'\n' grep -Ril nvidia 2>/dev/null | wc -l) -gt 2 ]] + then + ewarn + ewarn "!!! WARNING !!!" + ewarn "Detected a custom script at ${EROOT}{/etc,{/usr,}/lib*}/elogind/system-sleep" + ewarn "referencing NVIDIA. This version of ${PN} has installed its own" + ewarn "hook at ${EROOT}/usr/lib/elogind/system-sleep/nvidia and it is recommended" + ewarn "to remove the custom one to avoid potential issues." + ewarn + ewarn "Feel free to ignore this warning if you know the other NVIDIA-related" + ewarn "scripts can be used together. The warning will be removed in the future." + fi + if [[ ${REPLACING_VERSIONS##* } ]] && + ver_test ${REPLACING_VERSIONS##* } -lt 560.35.03-r1 # may get repeated + then + elog + elog "For suspend/sleep, 'NVreg_PreserveVideoMemoryAllocations=1' is now default" + elog "with this version of ${PN}. This is recommended (or required) by" + elog "major DEs especially with wayland but, *if* experience regressions with" + elog "suspend, try reverting to =0 in '${EROOT}/etc/modprobe.d/nvidia.conf'." + elog + elog "May notably be an issue when using neither systemd nor elogind to suspend." + elog + elog "Also, the systemd suspend/hibernate/resume services are now enabled by" + elog "default, and for openrc+elogind a similar hook has been installed." + fi +} diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-560.35.03.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-560.35.03.ebuild deleted file mode 100644 index 7201283bfb9f..000000000000 --- a/x11-drivers/nvidia-drivers/nvidia-drivers-560.35.03.ebuild +++ /dev/null @@ -1,515 +0,0 @@ -# Copyright 1999-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -MODULES_OPTIONAL_IUSE=+modules -inherit desktop flag-o-matic linux-mod-r1 readme.gentoo-r1 -inherit systemd toolchain-funcs unpacker user-info - -MODULES_KERNEL_MAX=6.10 -NV_URI="https://download.nvidia.com/XFree86/" - -DESCRIPTION="NVIDIA Accelerated Graphics Driver" -HOMEPAGE="https://www.nvidia.com/download/index.aspx" -SRC_URI=" - amd64? ( ${NV_URI}Linux-x86_64/${PV}/NVIDIA-Linux-x86_64-${PV}.run ) - arm64? ( ${NV_URI}Linux-aarch64/${PV}/NVIDIA-Linux-aarch64-${PV}.run ) - $(printf "${NV_URI}%s/%s-${PV}.tar.bz2 " \ - nvidia-{installer,modprobe,persistenced,settings,xconfig}{,}) - ${NV_URI}NVIDIA-kernel-module-source/NVIDIA-kernel-module-source-${PV}.tar.xz -" -# nvidia-installer is unused but here for GPL-2's "distribute sources" -S=${WORKDIR} - -LICENSE="NVIDIA-r2 Apache-2.0 BSD BSD-2 GPL-2 MIT ZLIB curl openssl" -SLOT="0/${PV%%.*}" -KEYWORDS="-* ~amd64 ~arm64" -# note: kernel-open is an upstream default in >=560 if all GPUs on the system -# support it but, since no automagic here, keeping it off for the wider support -IUSE="+X abi_x86_32 abi_x86_64 kernel-open persistenced powerd +static-libs +tools wayland" -REQUIRED_USE="kernel-open? ( modules )" - -COMMON_DEPEND=" - acct-group/video - X? ( x11-libs/libpciaccess ) - persistenced? ( - acct-user/nvpd - net-libs/libtirpc:= - ) - tools? ( - >=app-accessibility/at-spi2-core-2.46:2 - dev-libs/glib:2 - dev-libs/jansson:= - media-libs/harfbuzz:= - x11-libs/cairo - x11-libs/gdk-pixbuf:2 - x11-libs/gtk+:3[X] - x11-libs/libX11 - x11-libs/libXext - x11-libs/libXxf86vm - x11-libs/pango - ) -" -RDEPEND=" - ${COMMON_DEPEND} - dev-libs/openssl:0/3 - sys-libs/glibc - X? ( - media-libs/libglvnd[X,abi_x86_32(-)?] - x11-libs/libX11[abi_x86_32(-)?] - x11-libs/libXext[abi_x86_32(-)?] - ) - powerd? ( sys-apps/dbus[abi_x86_32(-)?] ) - wayland? ( - >=gui-libs/egl-gbm-1.1.1-r2[abi_x86_32(-)?] - >=gui-libs/egl-wayland-1.1.13.1[abi_x86_32(-)?] - ) -" -DEPEND=" - ${COMMON_DEPEND} - static-libs? ( - x11-base/xorg-proto - x11-libs/libX11 - x11-libs/libXext - ) - tools? ( - dev-util/vulkan-headers - media-libs/libglvnd - sys-apps/dbus - x11-base/xorg-proto - x11-libs/libXrandr - x11-libs/libXv - x11-libs/libvdpau - ) -" -BDEPEND=" - sys-devel/m4 - virtual/pkgconfig -" - -QA_PREBUILT="lib/firmware/* opt/bin/* usr/lib*" - -PATCHES=( - "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch - "${FILESDIR}"/nvidia-settings-530.30.02-desktop.patch -) - -pkg_setup() { - use modules && [[ ${MERGE_TYPE} != binary ]] || return - - local CONFIG_CHECK=" - PROC_FS - ~DRM_KMS_HELPER - ~SYSVIPC - ~!LOCKDEP - ~!SLUB_DEBUG_ON - !DEBUG_MUTEXES - $(usev powerd '~CPU_FREQ') - " - - local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but needed for Xorg auto-detection - of drivers (no custom config), and for wayland / nvidia-drm.modeset=1. - Cannot be directly selected in the kernel's menuconfig, and may need - selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or - DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in." - - use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764 - - use kernel-open && CONFIG_CHECK+=" MMU_NOTIFIER" #843827 - local ERROR_MMU_NOTIFIER="CONFIG_MMU_NOTIFIER: is not set but needed to build with USE=kernel-open. - Cannot be directly selected in the kernel's menuconfig, and may need - selection of another option that requires it such as CONFIG_KVM." - - linux-mod-r1_pkg_setup -} - -src_prepare() { - # make patches usable across versions - rm nvidia-modprobe && mv nvidia-modprobe{-${PV},} || die - rm nvidia-persistenced && mv nvidia-persistenced{-${PV},} || die - rm nvidia-settings && mv nvidia-settings{-${PV},} || die - rm nvidia-xconfig && mv nvidia-xconfig{-${PV},} || die - mv NVIDIA-kernel-module-source-${PV} kernel-module-source || die - - default - - # prevent detection of incomplete kernel DRM support (bug #603818) - sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \ - -i kernel{,-module-source/kernel-open}/conftest.sh || die - - # adjust service files - sed 's/__USER__/nvpd/' \ - nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \ - > "${T}"/nvidia-persistenced.service || die - sed -i "s|/usr|${EPREFIX}/opt|" systemd/system/nvidia-powerd.service || die - - # use alternative vulkan icd option if USE=-X (bug #909181) - use X || sed -i 's/"libGLX/"libEGL/' nvidia_{layers,icd}.json || die - - # enable nvidia-drm.modeset=1 by default with USE=wayland - cp "${FILESDIR}"/nvidia-555.conf "${T}"/nvidia.conf || die - use !wayland || sed -i '/^#.*modeset=1$/s/^#//' "${T}"/nvidia.conf || die - - # makefile attempts to install wayland library even if not built - use wayland || sed -i 's/ WAYLAND_LIB_install$//' \ - nvidia-settings/src/Makefile || die -} - -src_compile() { - tc-export AR CC CXX LD OBJCOPY OBJDUMP PKG_CONFIG - - local xnvflags=-fPIC #840389 - # lto static libraries tend to cause problems without fat objects - tc-is-lto && xnvflags+=" $(test-flags-CC -ffat-lto-objects)" - - NV_ARGS=( - PREFIX="${EPREFIX}"/usr - HOST_CC="$(tc-getBUILD_CC)" - HOST_LD="$(tc-getBUILD_LD)" - BUILD_GTK2LIB= - NV_USE_BUNDLED_LIBJANSSON=0 - NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out - WAYLAND_AVAILABLE=$(usex wayland 1 0) - XNVCTRL_CFLAGS="${xnvflags}" - ) - - if use modules; then - local o_cflags=${CFLAGS} o_cxxflags=${CXXFLAGS} o_ldflags=${LDFLAGS} - - local modlistargs=video:kernel - if use kernel-open; then - modlistargs+=-module-source:kernel-module-source/kernel-open - - # environment flags are normally unused for modules, but nvidia - # uses it for building the "blob" and it is a bit fragile - filter-flags -fno-plt #912949 - filter-lto - CC=${KERNEL_CC} CXX=${KERNEL_CXX} strip-unsupported-flags - fi - - local modlist=( nvidia{,-drm,-modeset,-peermem,-uvm}=${modlistargs} ) - local modargs=( - IGNORE_CC_MISMATCH=yes NV_VERBOSE=1 - SYSOUT="${KV_OUT_DIR}" SYSSRC="${KV_DIR}" - ) - - # temporary workaround for bug #914468 - CPP="${KERNEL_CC} -E" tc-is-clang && addpredict "${KV_OUT_DIR}" - - linux-mod-r1_src_compile - CFLAGS=${o_cflags} CXXFLAGS=${o_cxxflags} LDFLAGS=${o_ldflags} - fi - - emake "${NV_ARGS[@]}" -C nvidia-modprobe - use persistenced && emake "${NV_ARGS[@]}" -C nvidia-persistenced - use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig - - if use tools; then - # avoid noisy *very* noisy logs with deprecation warnings - CFLAGS="-Wno-deprecated-declarations ${CFLAGS}" \ - emake "${NV_ARGS[@]}" -C nvidia-settings - elif use static-libs; then - # pretend GTK+3 is available, not actually used (bug #880879) - emake "${NV_ARGS[@]}" BUILD_GTK3LIB=1 \ - -C nvidia-settings/src out/libXNVCtrl.a - fi -} - -src_install() { - local libdir=$(get_libdir) libdir32=$(ABI=x86 get_libdir) - - NV_ARGS+=( DESTDIR="${D}" LIBDIR="${ED}"/usr/${libdir} ) - - local -A paths=( - [APPLICATION_PROFILE]=/usr/share/nvidia - [CUDA_ICD]=/etc/OpenCL/vendors - [EGL_EXTERNAL_PLATFORM_JSON]=/usr/share/egl/egl_external_platform.d - [FIRMWARE]=/lib/firmware/nvidia/${PV} - [GBM_BACKEND_LIB_SYMLINK]=/usr/${libdir}/gbm - [GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d - [OPENGL_DATA]=/usr/share/nvidia - [VULKAN_ICD_JSON]=/usr/share/vulkan - [VULKANSC_ICD_JSON]=/usr/share/vulkansc - [WINE_LIB]=/usr/${libdir}/nvidia/wine - [XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d - - [GLX_MODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules/extensions - [GLX_MODULE_SYMLINK]=/usr/${libdir}/xorg/modules - [XMODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules - ) - - local skip_files=( - $(usev !X "libGLX_nvidia libglxserver_nvidia") - libGLX_indirect # non-glvnd unused fallback - libnvidia-{gtk,wayland-client} nvidia-{settings,xconfig} # from source - libnvidia-egl-gbm 15_nvidia_gbm # gui-libs/egl-gbm - libnvidia-egl-wayland 10_nvidia_wayland # gui-libs/egl-wayland - libnvidia-pkcs11.so # using the openssl3 version instead - ) - local skip_modules=( - $(usev !X "nvfbc vdpau xdriver") - $(usev !modules gsp) - $(usev !powerd powerd) - installer nvpd # handled separately / built from source - ) - local skip_types=( - GLVND_LIB GLVND_SYMLINK EGL_CLIENT.\* GLX_CLIENT.\* # media-libs/libglvnd - OPENCL_WRAPPER.\* # virtual/opencl - DOCUMENTATION DOT_DESKTOP .\*_SRC DKMS_CONF SYSTEMD_UNIT # handled separately / unused - ) - - local DOCS=( - README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json - nvidia-settings/doc/{FRAMELOCK,NV-CONTROL-API}.txt - ) - local HTML_DOCS=( html/. ) - einstalldocs - - local DISABLE_AUTOFORMATTING=yes - local DOC_CONTENTS="\ -Trusted users should be in the 'video' group to use NVIDIA devices. -You can add yourself by using: gpasswd -a my-user video\ -$(usev modules " - -Like all out-of-tree kernel modules, it is necessary to rebuild -${PN} after upgrading or rebuilding the Linux kernel -by for example running \`emerge @module-rebuild\`. Alternatively, -if using a distribution kernel (sys-kernel/gentoo-kernel{,-bin}), -this can be automated by setting USE=dist-kernel globally. - -Loaded kernel modules also must not mismatch with the installed -${PN} version (excluding -r revision), meaning should -ensure \`eselect kernel list\` points to the kernel that will be -booted before building and preferably reboot after upgrading -${PN} (the ebuild will emit a warning if mismatching). - -See '${EPREFIX}/etc/modprobe.d/nvidia.conf' for modules options.")\ -$(use amd64 && usev !abi_x86_32 " - -Note that without USE=abi_x86_32 on ${PN}, 32bit applications -(typically using wine / steam) will not be able to use GPU acceleration.") - -For additional information or for troubleshooting issues, please see -https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers and NVIDIA's own -documentation that is installed alongside this README." - readme.gentoo_create_doc - - if use modules; then - linux-mod-r1_src_install - - insinto /etc/modprobe.d - doins "${T}"/nvidia.conf - - # used for gpu verification with binpkgs (not kept, see pkg_preinst) - insinto /usr/share/nvidia - doins supported-gpus/supported-gpus.json - fi - - emake "${NV_ARGS[@]}" -C nvidia-modprobe install - fowners :video /usr/bin/nvidia-modprobe #505092 - fperms 4710 /usr/bin/nvidia-modprobe - - if use persistenced; then - emake "${NV_ARGS[@]}" -C nvidia-persistenced install - newconfd "${FILESDIR}"/nvidia-persistenced.confd nvidia-persistenced - newinitd "${FILESDIR}"/nvidia-persistenced.initd nvidia-persistenced - systemd_dounit "${T}"/nvidia-persistenced.service - fi - - if use tools; then - emake "${NV_ARGS[@]}" -C nvidia-settings install - - doicon nvidia-settings/doc/nvidia-settings.png - domenu nvidia-settings/doc/nvidia-settings.desktop - - exeinto /etc/X11/xinit/xinitrc.d - newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings - fi - - if use static-libs; then - dolib.a nvidia-settings/src/out/libXNVCtrl.a - - insinto /usr/include/NVCtrl - doins nvidia-settings/src/libXNVCtrl/NVCtrl{Lib,}.h - fi - - use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig install - - # mimic nvidia-installer by reading .manifest to install files - # 0:file 1:perms 2:type 3+:subtype/arguments -:module - local m into - while IFS=' ' read -ra m; do - ! [[ ${#m[@]} -ge 2 && ${m[-1]} =~ MODULE: ]] || - [[ " ${m[0]##*/}" =~ ^(\ ${skip_files[*]/%/.*|\\} )$ ]] || - [[ " ${m[2]}" =~ ^(\ ${skip_types[*]/%/|\\} )$ ]] || - has ${m[-1]#MODULE:} "${skip_modules[@]}" && continue - - case ${m[2]} in - MANPAGE) - gzip -dc ${m[0]} | newman - ${m[0]%.gz}; assert - continue - ;; - GBM_BACKEND_LIB_SYMLINK) m[4]=../${m[4]};; # missing ../ - VDPAU_SYMLINK) m[4]=vdpau/; m[5]=${m[5]#vdpau/};; # .so to vdpau/ - esac - - if [[ -v 'paths[${m[2]}]' ]]; then - into=${paths[${m[2]}]} - elif [[ ${m[2]} == EXPLICIT_PATH ]]; then - into=${m[3]} - elif [[ ${m[2]} == *_BINARY ]]; then - into=/opt/bin - elif [[ ${m[3]} == COMPAT32 ]]; then - use abi_x86_32 || continue - into=/usr/${libdir32} - elif [[ ${m[2]} == *_@(LIB|SYMLINK) ]]; then - into=/usr/${libdir} - else - die "No known installation path for ${m[0]}" - fi - [[ ${m[3]: -2} == ?/ ]] && into+=/${m[3]%/} - [[ ${m[4]: -2} == ?/ ]] && into+=/${m[4]%/} - - if [[ ${m[2]} =~ _SYMLINK$ ]]; then - [[ ${m[4]: -1} == / ]] && m[4]=${m[5]} - dosym ${m[4]} ${into}/${m[0]} - continue - fi - # avoid portage warning due to missing soname links in manifest - [[ ${m[0]} =~ .*((libnvidia-ngx.so|libnvidia-egl-gbm.so).*) ]] && - dosym ${BASH_REMATCH[1]} ${into}/${BASH_REMATCH[2]}.1 - - printf -v m[1] %o $((m[1] | 0200)) # 444->644 - insopts -m${m[1]} - insinto ${into} - doins ${m[0]} - done < .manifest || die - insopts -m0644 # reset - - # MODULE:installer non-skipped extras - : "$(systemd_get_sleepdir)" - exeinto "${_#"${EPREFIX}"}" - doexe systemd/system-sleep/nvidia - dobin systemd/nvidia-sleep.sh - systemd_dounit systemd/system/nvidia-{hibernate,resume,suspend}.service - - dobin nvidia-bug-report.sh - - # MODULE:powerd extras - if use powerd; then - newinitd "${FILESDIR}"/nvidia-powerd.initd nvidia-powerd #923117 - systemd_dounit systemd/system/nvidia-powerd.service - - insinto /usr/share/dbus-1/system.d - doins nvidia-dbus.conf - fi - - # symlink non-versioned so nvidia-settings can use it even if misdetected - dosym nvidia-application-profiles-${PV}-key-documentation \ - ${paths[APPLICATION_PROFILE]}/nvidia-application-profiles-key-documentation - - # don't attempt to strip firmware files (silences errors) - dostrip -x ${paths[FIRMWARE]} - - # sandbox issues with /dev/nvidiactl others (bug #904292,#921578) - # are widespread and sometime affect revdeps of packages built with - # USE=opencl/cuda making it hard to manage in ebuilds (minimal set, - # ebuilds should handle manually if need others or addwrite) - insinto /etc/sandbox.d - newins - 20nvidia <<<'SANDBOX_PREDICT="/dev/nvidiactl:/dev/nvidia-caps:/dev/char"' -} - -pkg_preinst() { - has_version "${CATEGORY}/${PN}[kernel-open]" && NV_HAD_KERNEL_OPEN= - has_version "${CATEGORY}/${PN}[wayland]" && NV_HAD_WAYLAND= - - use modules || return - - # set video group id based on live system (bug #491414) - local g=$(egetent group video | cut -d: -f3) - [[ ${g} =~ ^[0-9]+$ ]] || die "Failed to determine video group id (got '${g}')" - sed -i "s/@VIDEOGID@/${g}/" "${ED}"/etc/modprobe.d/nvidia.conf || die - - # try to find driver mismatches using temporary supported-gpus.json - # TODO?: automatically check "kernelopen" bit for USE=kernel-open compat - for g in $(grep -l 0x10de /sys/bus/pci/devices/*/vendor 2>/dev/null); do - g=$(grep -io "\"devid\":\"$(<${g%vendor}device)\"[^}]*branch\":\"[0-9]*" \ - "${ED}"/usr/share/nvidia/supported-gpus.json 2>/dev/null) - if [[ ${g} ]]; then - g=$((${g##*\"}+1)) - if ver_test -ge ${g}; then - NV_LEGACY_MASK=">=${CATEGORY}/${PN}-${g}" - break - fi - fi - done - rm "${ED}"/usr/share/nvidia/supported-gpus.json || die -} - -pkg_postinst() { - linux-mod-r1_pkg_postinst - - readme.gentoo_print_elog - - if [[ -r /proc/driver/nvidia/version && - $( ${EROOT}/etc/portage/package.mask/${PN}" - else - ewarn " echo '${NV_LEGACY_MASK}' >> ${EROOT}/etc/portage/package.mask" - fi - ewarn "...then downgrade to a legacy[1] branch if possible (not all old versions" - ewarn "are available or fully functional, may need to consider nouveau[2])." - ewarn "[1] https://www.nvidia.com/object/IO_32667.html" - ewarn "[2] https://wiki.gentoo.org/wiki/Nouveau" - fi - - if use kernel-open && [[ ! -v NV_HAD_KERNEL_OPEN ]]; then - ewarn - ewarn "Open source variant of ${PN} was selected, note that it requires" - ewarn "Turing/Ampere+ GPUs (aka GTX 1650+). Try disabling if run into issues." - ewarn "Also see: ${EROOT}/usr/share/doc/${PF}/html/kernel_open.html" - fi - - if use wayland && use modules && [[ ! -v NV_HAD_WAYLAND ]]; then - elog - elog "With USE=wayland, this version of ${PN} sets nvidia-drm.modeset=1" - elog "in '${EROOT}/etc/modprobe.d/nvidia.conf'. This feature is considered" - elog "experimental but is required for wayland." - elog - elog "If you experience issues, either disable wayland or edit nvidia.conf." - elog "Of note, may possibly cause issues with SLI and Reverse PRIME." - fi - - if use !kernel-open && [[ ${REPLACING_VERSIONS##* } ]] && - ver_test ${REPLACING_VERSIONS##* } -lt 555 - then - elog - elog "If using a Turing/Ampere+ GPU (aka GTX 1650+), note that >=nvidia-drivers-555" - elog "enables the use of the GSP firmware by default. *If* experience regressions," - elog "please see '${EROOT}/etc/modprobe.d/nvidia.conf' to optionally disable." - fi -} -- cgit v1.2.3