mirror of
https://github.com/elwrcl/copnix.git
synced 2026-10-31 06:18:03 +03:00
local drivers
This commit is contained in:
1 parent
7e965fe195
commit
a71d522e5a
76 files changed
+37344
-18
No files matched your search
@@ -0,0 +1,28 @@
|
||||
{ ... }:
|
||||
{
|
||||
flake.homeModules.home-mpv-intel-hard =
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
inputs,
|
||||
osConfig,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = osConfig.programs.intel-hard;
|
||||
vk = (import "${inputs.intel-hard}/graphics").${cfg.vulkan.driver};
|
||||
icd = "${cfg.buildRoot}/${vk.icd}";
|
||||
runtimeLibPath = lib.makeLibraryPath (import "${inputs.intel-hard}/lib/runtime-libs.nix" pkgs);
|
||||
in
|
||||
{
|
||||
elars.mpv.wrapperRun = lib.mkIf cfg.enable ''
|
||||
if [ -f "${icd}" ]; then
|
||||
export VK_DRIVER_FILES="${icd}"
|
||||
export VK_ICD_FILENAMES="${icd}"
|
||||
export MESA_VK_DEVICE_SELECT="${cfg.pciId}"
|
||||
export LD_LIBRARY_PATH="${runtimeLibPath}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
|
||||
unset MESA_GL_VERSION_OVERRIDE
|
||||
fi
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
{ ... }:
|
||||
{
|
||||
flake.homeModules.home-mpv-svp =
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
# Only the free SVPflow plugins are taken from the SVP 4 bundle;
|
||||
# the paid SVP Manager is not used.
|
||||
svpflow = pkgs.stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "svpflow";
|
||||
version = "4.7.305";
|
||||
src = pkgs.fetchurl {
|
||||
url = "https://www.svp-team.com/files/svp4-linux.${finalAttrs.version}.tar.bz2";
|
||||
hash = "sha256-PWAcm/hIA4JH2QtJPP+gSJdJLRdfdbZXIVdWELazbxQ=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkgs.p7zip
|
||||
pkgs.autoPatchelfHook
|
||||
];
|
||||
buildInputs = [ (pkgs.lib.getLib pkgs.stdenv.cc.cc) ];
|
||||
|
||||
unpackPhase = ''
|
||||
tar xf $src
|
||||
'';
|
||||
|
||||
# The .run installer is a stack of 7z archives; extract them all.
|
||||
buildPhase = ''
|
||||
mkdir installer extracted
|
||||
LANG=C grep --only-matching --byte-offset --binary --text $'7z\xBC\xAF\x27\x1C' svp4-linux.run |
|
||||
cut -f1 -d: |
|
||||
while read ofs; do
|
||||
dd if=svp4-linux.run bs=1M iflag=skip_bytes status=none skip=$ofs of="installer/bin-$ofs.7z"
|
||||
done
|
||||
for f in installer/*.7z; do
|
||||
7z -bd -bb0 -y x -oextracted "$f" || true
|
||||
done
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
install -Dm755 -t $out/lib extracted/plugins/libsvpflow1.so extracted/plugins/libsvpflow2.so
|
||||
'';
|
||||
|
||||
meta.license = pkgs.lib.licenses.unfree;
|
||||
});
|
||||
|
||||
script = pkgs.writeText "svp.vpy" ''
|
||||
import vapoursynth as vs
|
||||
|
||||
core = vs.core
|
||||
core.std.LoadPlugin("${svpflow}/lib/libsvpflow1.so")
|
||||
core.std.LoadPlugin("${svpflow}/lib/libsvpflow2.so")
|
||||
|
||||
clip = video_in
|
||||
src_fps = container_fps if container_fps > 0.1 else 23.976
|
||||
|
||||
if clip.format.id != vs.YUV420P8:
|
||||
clip = clip.resize.Point(format=vs.YUV420P8, dither_type="ordered")
|
||||
|
||||
if clip.height > 720:
|
||||
clip = clip.resize.Bilinear(round(clip.width * 720 / clip.height / 2) * 2, 720)
|
||||
|
||||
sup = core.svp1.Super(clip, "{pel:1,gpu:1}")
|
||||
vec = core.svp1.Analyse(
|
||||
sup["clip"], sup["data"], clip,
|
||||
"{block:{w:32,h:32,overlap:0},main:{search:{coarse:{distance:0}}},refine:[{thsad:200}]}",
|
||||
)
|
||||
smooth = core.svp2.SmoothFps(
|
||||
clip, sup["clip"], sup["data"], vec["clip"], vec["data"],
|
||||
"{rate:{num:60,den:1,abs:true},algo:13,scene:{}}", src=clip, fps=src_fps,
|
||||
)
|
||||
smooth.set_output()
|
||||
'';
|
||||
in
|
||||
{
|
||||
elars.mpv.vapoursynth = true;
|
||||
|
||||
programs.mpv = {
|
||||
profiles.svp = {
|
||||
profile-cond = ''get("user-data/svp", "yes") == "yes" and get("container-fps", 0) < 40'';
|
||||
profile-restore = "copy";
|
||||
hwdec = "vaapi";
|
||||
scale = "bicubic";
|
||||
deinterlace = "auto";
|
||||
vf-add = "lavfi=[scale_vaapi=w=-2:h='min(720,ih)':format=nv12,hwdownload,format=nv12],vapoursynth=${script}:buffered-frames=4:concurrent-frames=4";
|
||||
};
|
||||
};
|
||||
|
||||
xdg.configFile."mpv/scripts/svp-toggle.lua".text = ''
|
||||
mp.set_property_native("user-data/svp", "yes")
|
||||
mp.add_key_binding("alt+s", "svp-toggle", function()
|
||||
local on = mp.get_property_native("user-data/svp") ~= "yes"
|
||||
mp.set_property_native("user-data/svp", on and "yes" or "no")
|
||||
mp.osd_message("SVP: " .. (on and "on" or "off"))
|
||||
end)
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
{ ... }:
|
||||
{
|
||||
flake.homeModules.home-mpv =
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.elars.mpv;
|
||||
withScripts = pkgs.mpv.override {
|
||||
mpv-unwrapped =
|
||||
if cfg.vapoursynth then
|
||||
pkgs.mpv-unwrapped.override { vapoursynthSupport = true; }
|
||||
else
|
||||
pkgs.mpv-unwrapped;
|
||||
scripts = with pkgs.mpvScripts; [
|
||||
uosc
|
||||
thumbfast
|
||||
autoload
|
||||
mpris
|
||||
memo
|
||||
quality-menu
|
||||
sponsorblock-minimal
|
||||
reload
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
options.elars.mpv.wrapperRun = lib.mkOption {
|
||||
type = lib.types.lines;
|
||||
default = "";
|
||||
description = "Shell snippet run by the mpv wrapper before exec.";
|
||||
};
|
||||
|
||||
options.elars.mpv.vapoursynth = lib.mkEnableOption "VapourSynth filter support in mpv";
|
||||
|
||||
config.programs.mpv = {
|
||||
enable = true;
|
||||
|
||||
package =
|
||||
if cfg.wrapperRun == "" then
|
||||
withScripts
|
||||
else
|
||||
pkgs.symlinkJoin {
|
||||
name = "mpv-wrapped";
|
||||
paths = [ withScripts ];
|
||||
nativeBuildInputs = [ pkgs.makeShellWrapper ];
|
||||
postBuild = ''
|
||||
wrapProgramShell $out/bin/mpv --run ${lib.escapeShellArg cfg.wrapperRun}
|
||||
'';
|
||||
};
|
||||
|
||||
config = {
|
||||
hwdec = "vulkan,vaapi";
|
||||
hwdec-codecs = "all";
|
||||
osc = "no";
|
||||
osd-bar = "no";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{ ... }:
|
||||
{
|
||||
commonModules.common-git =
|
||||
{ pkgs, lib, ... }:
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
base = ''
|
||||
[user]
|
||||
@@ -19,7 +19,14 @@
|
||||
helper = osxkeychain
|
||||
'';
|
||||
|
||||
gitconfig = pkgs.writeText "gitconfig" (base + lib.optionalString pkgs.stdenv.isDarwin darwinExtra);
|
||||
linuxExtra = ''
|
||||
[credential]
|
||||
helper = ${pkgs.gitFull}/bin/git-credential-libsecret
|
||||
'';
|
||||
|
||||
gitconfig = pkgs.writeText "gitconfig" (
|
||||
base + (if pkgs.stdenv.isDarwin then darwinExtra else linuxExtra)
|
||||
);
|
||||
in
|
||||
{
|
||||
environment.variables.GIT_CONFIG_SYSTEM = "${gitconfig}";
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"pipe-operators"
|
||||
];
|
||||
max-jobs = 2;
|
||||
cores = 2;
|
||||
cores = 0;
|
||||
|
||||
min-free = 5368709120; # 5 GiB
|
||||
max-free = 21474836480; # 20 GiB
|
||||
@@ -46,12 +46,6 @@
|
||||
persistent = true;
|
||||
randomizedDelaySec = "45min";
|
||||
};
|
||||
nix.optimise = {
|
||||
automatic = true;
|
||||
dates = [ "monthly" ];
|
||||
persistent = true;
|
||||
randomizedDelaySec = "45min";
|
||||
};
|
||||
|
||||
documentation = {
|
||||
man.enable = true;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
onlyoffice-desktopeditors
|
||||
kdePackages.kdenlive
|
||||
whatsapp-electron
|
||||
qbittorrent
|
||||
telegram-desktop
|
||||
prismlauncher
|
||||
gparted-full
|
||||
@@ -178,7 +179,6 @@
|
||||
ffmpeg
|
||||
yt-dlp
|
||||
cava
|
||||
mpv
|
||||
|
||||
inputs.agenix.packages.${system}.default
|
||||
inputs.nix-alien.packages.${system}.nix-alien
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
"x-scheme-handler/about" = "helium.desktop";
|
||||
"x-scheme-handler/unknown" = "helium.desktop";
|
||||
"x-scheme-handler/steam" = "steam.desktop";
|
||||
"x-scheme-handler/magnet" = "org.qbittorrent.qBittorrent.desktop";
|
||||
"application/x-bittorrent" = "org.qbittorrent.qBittorrent.desktop";
|
||||
|
||||
# media
|
||||
"image/png" = "org.gnome.Loupe.desktop";
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
extraPackages = [
|
||||
wayland-intel-vaapi-driver
|
||||
pkgs.libvdpau-va-gl
|
||||
pkgs.pocl
|
||||
# OpenCL (GPU + CPU): pocl-gen7 in hw-ivb-drivers
|
||||
];
|
||||
extraPackages32 = [
|
||||
wayland-intel-vaapi-driver-32
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
{ ... }:
|
||||
{
|
||||
flake.nixosModules.hw-ivb-drivers =
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
drivers =
|
||||
p: arch:
|
||||
p.stdenv.mkDerivation {
|
||||
pname = "ivb-drivers";
|
||||
version = "fork";
|
||||
src = ../../../drivers/ivb + "/${arch}";
|
||||
|
||||
nativeBuildInputs = [ p.autoPatchelfHook ];
|
||||
buildInputs = with p; [
|
||||
libdrm
|
||||
zstd
|
||||
expat
|
||||
libxcb
|
||||
libx11
|
||||
libxshmfence
|
||||
xcbutilkeysyms
|
||||
wayland
|
||||
llvmPackages_21.llvm.lib
|
||||
llvmPackages_21.libclang.lib
|
||||
spirv-llvm-translator
|
||||
stdenv.cc.cc.lib
|
||||
];
|
||||
dontStrip = true; # stripped by meson install
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p $out/lib/d3d $out/share/vulkan/icd.d
|
||||
install -m 0755 libvulkan_intel_hasvk13.so $out/lib/
|
||||
install -m 0755 d3dadapter9.so.1 $out/lib/d3d/
|
||||
ln -s d3dadapter9.so.1 $out/lib/d3d/d3dadapter9.so
|
||||
|
||||
cat > $out/share/vulkan/icd.d/intel_hasvk_ivb_icd.${arch}.json <<EOF
|
||||
{
|
||||
"ICD": {
|
||||
"api_version": "1.3.352",
|
||||
"library_arch": "${if arch == "x86_64" then "64" else "32"}",
|
||||
"library_path": "$out/lib/libvulkan_intel_hasvk13.so"
|
||||
},
|
||||
"file_format_version": "1.0.1"
|
||||
}
|
||||
EOF
|
||||
|
||||
if [ -f libRusticlOpenCL.so.1 ]; then
|
||||
install -m 0755 libRusticlOpenCL.so.1 $out/lib/
|
||||
mkdir -p $out/etc/OpenCL/vendors
|
||||
echo $out/lib/libRusticlOpenCL.so.1 > $out/etc/OpenCL/vendors/rusticl-ivb.icd
|
||||
fi
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
||||
withoutHasvk =
|
||||
mesa:
|
||||
pkgs.symlinkJoin {
|
||||
name = "${mesa.name}-without-hasvk";
|
||||
paths = [ mesa ];
|
||||
postBuild = ''
|
||||
rm -f $out/share/vulkan/icd.d/intel_hasvk_icd.*.json
|
||||
'';
|
||||
};
|
||||
|
||||
# pocl with the gen7 device (OpenCL on the HD 4000) and the host CPU
|
||||
# device, from Drivers/pocl-gen7/release.sh. The gen7 device finds
|
||||
# libgbe and beignet's library in lib/beignet next to itself.
|
||||
pocl-gen7 = pkgs.stdenv.mkDerivation {
|
||||
pname = "pocl-gen7";
|
||||
version = "release";
|
||||
src = ../../../drivers/pocl-gen7;
|
||||
|
||||
nativeBuildInputs = [ pkgs.autoPatchelfHook ];
|
||||
buildInputs = with pkgs; [
|
||||
libdrm
|
||||
hwloc
|
||||
zlib
|
||||
zstd
|
||||
libxml2
|
||||
llvmPackages_21.llvm.lib
|
||||
llvmPackages_21.clang-unwrapped.lib # libgbe: libclang-cpp
|
||||
stdenv.cc.cc.lib
|
||||
];
|
||||
dontStrip = true; # stripped by release.sh
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p $out/etc/OpenCL/vendors
|
||||
cp -a lib share $out/
|
||||
echo $out/lib/libpocl.so.2 > $out/etc/OpenCL/vendors/pocl-gen7.icd
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
hardware.graphics = {
|
||||
package = withoutHasvk pkgs.mesa;
|
||||
package32 = withoutHasvk pkgs.pkgsi686Linux.mesa;
|
||||
extraPackages = [
|
||||
(drivers pkgs "x86_64")
|
||||
pocl-gen7
|
||||
];
|
||||
extraPackages32 = [ (drivers pkgs.pkgsi686Linux "i686") ];
|
||||
};
|
||||
# sessionVariables: set through PAM for the whole session, so every
|
||||
# shell (nushell too) and every program started from it sees them
|
||||
environment.sessionVariables = {
|
||||
RUSTICL_ENABLE = "crocus";
|
||||
# pocl builds basic and pthread (both the CPU); the GPU comes first
|
||||
POCL_DEVICES = "gen7 pthread";
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user