diff --git a/common.nix b/common.nix index 0511a90..564c0e7 100644 --- a/common.nix +++ b/common.nix @@ -59,6 +59,7 @@ boot.kernelPackages = pkgs.linuxPackages_latest; networking.networkmanager.enable = true; + networking.networkmanager.dns = "none"; networking.nameservers = [ "1.1.1.1" "8.8.8.8" @@ -66,6 +67,7 @@ # Enable bluetooth hardware.bluetooth.enable = true; + hardware.xpadneo.enable = true; # Set your time zone. time.timeZone = "Europe/London"; @@ -200,6 +202,7 @@ programs.steam.enable = true; programs.walker.enable = true; programs.dconf.enable = true; + programs.xfconf.enable = true; # User Services services.gvfs.enable = true; diff --git a/configuration-pc.nix b/configuration-pc.nix index 7f58d72..3941610 100644 --- a/configuration-pc.nix +++ b/configuration-pc.nix @@ -54,6 +54,7 @@ delfin docker jellyfin-tui + unstable.bambu-studio ]; }; diff --git a/davinci.nix b/davinci.nix new file mode 100644 index 0000000..7741200 --- /dev/null +++ b/davinci.nix @@ -0,0 +1,195 @@ +# Tested on Davinci 20.0.1. It works for loading videos and exporting in H264/5 & AV1 +# This module doesn't seems to crack Davinci 20.2.1 +# Even if following this guide https://www.reddit.com/r/LinuxCrackSupport/comments/1nfqhld/davinci_resolve_studio_202_fix_linux_crack_guide/ +# nixpkgs rev used for this tests: 59e69648d345d6e8fef86158c555730fa12af9de + +{ lib, pkgs, ... }: +let + ffmpeg-encoder-plugin = pkgs.stdenv.mkDerivation (finalAttrs: { + pname = "ffmpeg-encoder-plugin"; + version = "1.1.0"; + + src = pkgs.fetchFromGitHub { + owner = "EdvinNilsson"; + repo = "ffmpeg_encoder_plugin"; + tag = "v${finalAttrs.version}"; + hash = "sha256-orghLIzz9rUnUwka9C71Z2nj+qxHuggrKNlYjLKswQw="; + }; + + nativeBuildInputs = with pkgs; [ + cmake + ffmpeg-full + ]; + + buildInputs = with pkgs; [ ffmpeg ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out + cp ffmpeg_encoder_plugin.dvcp $out/ + + runHook postInstall + ''; + }); + + davinci-resolve-studio-cracked = + let + davinci-patched = pkgs.davinci-resolve-studio.davinci.overrideAttrs (old: { + # script based on https://www.reddit.com/r/LinuxCrackSupport/comments/1nfqhld/davinci_resolve_studio_202_fix_linux_crack_guide/ + # + # Additionally, it will install ffmpeg_encoder_plugin to enable H264/5 & AV1 exports: + # https://github.com/EdvinNilsson/ffmpeg_encoder_plugin + # + # Note: $out IS /opt/resolve + postInstall = '' + ${old.postInstall or ""} + ${lib.getExe pkgs.perl} -pi -e 's/\x74\x11\xe8\x21\x23\x00\x00/\xeb\x11\xe8\x21\x23\x00\x00/g' $out/bin/resolve + ${lib.getExe pkgs.perl} -pi -e 's/\x03\x00\x89\x45\xFC\x83\x7D\xFC\x00\x74\x11\x48\x8B\x45\xC8\x8B/\x03\x00\x89\x45\xFC\x83\x7D\xFC\x00\xEB\x11\x48\x8B\x45\xC8\x8B/' $out/bin/resolve + ${lib.getExe pkgs.perl} -pi -e 's/\x74\x11\x48\x8B\x45\xC8\x8B\x55\xFC\x89\x50\x58\xB8\x00\x00\x00/\xEB\x11\x48\x8B\x45\xC8\x8B\x55\xFC\x89\x50\x58\xB8\x00\x00\x00/' $out/bin/resolve + ${lib.getExe pkgs.perl} -pi -e 's/\x41\xb6\x01\x84\xc0\x0f\x84\xb0\x00\x00\x00\x48\x85\xdb\x74\x08\x45\x31\xf6\xe9\xa3\x00\x00\x00/\x41\xb6\x00\x84\xc0\x0f\x84\xb0\x00\x00\x00\x48\x85\xdb\x74\x08\x45\x31\xf6\xe9\xa3\x00\x00\x00/' $out/bin/resolve + mkdir $out/license + touch $out/license/blackmagic.lic + echo -e "LICENSE blackmagic davinciresolvestudio 999999 permanent uncounted\n hostid=ANY issuer=CGP customer=CGP issued=28-dec-2023\n akey=0000-0000-0000-0000 _ck=00 sig=\"00\"" > $out/license/blackmagic.lic + + mkdir -p $out/IOPlugins/ffmpeg_encoder_plugin.dvcp.bundle/Contents/Linux-x86-64/ + cp ${ffmpeg-encoder-plugin}/ffmpeg_encoder_plugin.dvcp $out/IOPlugins/ffmpeg_encoder_plugin.dvcp.bundle/Contents/Linux-x86-64/ + ''; + }); + in + + # the following was copied from davinci's derivation from nixpkgs. + # if davinci updates, this should be updated too + # but remember to replace "davinci" with "davinci-patched" + pkgs.buildFHSEnv { + inherit (davinci-patched) pname version; + + targetPkgs = + pkgs: + with pkgs; + [ + alsa-lib + aprutil + bzip2 + dbus + expat + fontconfig + freetype + glib + libGL + libGLU + libarchive + libcap + librsvg + libtool + libuuid + libxcrypt # provides libcrypt.so.1 + libxkbcommon + nspr + ocl-icd + opencl-headers + python3 + python3.pkgs.numpy + udev + xdg-utils # xdg-open needed to open URLs + xorg.libICE + xorg.libSM + xorg.libX11 + xorg.libXcomposite + xorg.libXcursor + xorg.libXdamage + xorg.libXext + xorg.libXfixes + xorg.libXi + xorg.libXinerama + xorg.libXrandr + xorg.libXrender + xorg.libXt + xorg.libXtst + xorg.libXxf86vm + xorg.libxcb + xorg.xcbutil + xorg.xcbutilimage + xorg.xcbutilkeysyms + xorg.xcbutilrenderutil + xorg.xcbutilwm + xorg.xkeyboardconfig + zlib + ] + ++ [ davinci-patched ]; + + extraPreBwrapCmds = '' + mkdir -p ~/.local/share/DaVinciResolve/license || exit 1 + mkdir -p ~/.local/share/DaVinciResolve/Extras || exit 1 + ''; + + extraBwrapArgs = [ + ''--bind "$HOME"/.local/share/DaVinciResolve/license ${davinci-patched}/.license'' + ''--bind "$HOME"/.local/share/DaVinciResolve/Extras ${davinci-patched}/Extras'' + ]; + + runScript = "${lib.getExe pkgs.bash} ${pkgs.writeText "davinci-wrapper" '' + export QT_XKB_CONFIG_ROOT="${pkgs.xkeyboard_config}/share/X11/xkb" + export QT_PLUGIN_PATH="${davinci-patched}/libs/plugins:$QT_PLUGIN_PATH" + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/usr/lib32:${davinci-patched}/libs + ${davinci-patched}/bin/resolve + ''}"; + + extraInstallCommands = '' + mkdir -p $out/share/applications $out/share/icons/hicolor/128x128/apps + ln -s ${davinci-patched}/share/applications/*.desktop $out/share/applications/ + ln -s ${davinci-patched}/graphics/DV_Resolve.png $out/share/icons/hicolor/128x128/apps/davinci-resolve-studio.png + ''; + + passthru = { + inherit davinci-patched; + updateScript = lib.getExe ( + pkgs.writeShellApplication { + name = "update-davinci-resolve"; + runtimeInputs = [ + pkgs.curl + pkgs.jq + pkgs.common-updater-scripts + ]; + text = '' + set -o errexit + drv=pkgs/by-name/da/davinci-resolve/package.nix + currentVersion=${lib.escapeShellArg davinci-patched.version} + downloadsJSON="$(curl --fail --silent https://www.blackmagicdesign.com/api/support/us/downloads.json)" + + latestLinuxVersion="$(echo "$downloadsJSON" | jq '[.downloads[] | select(.urls.Linux) | .urls.Linux[] | select(.downloadTitle | test("DaVinci Resolve")) | .downloadTitle]' | grep -oP 'DaVinci Resolve \K\d+\.\d+(\.\d+)?' | sort | tail -n 1)" + update-source-version davinci-resolve "$latestLinuxVersion" --source-key=davinci.src + + # Since the standard and studio both use the same version we need to reset it before updating studio + sed -i -e "s/""$latestLinuxVersion""/""$currentVersion""/" "$drv" + + latestStudioLinuxVersion="$(echo "$downloadsJSON" | jq '[.downloads[] | select(.urls.Linux) | .urls.Linux[] | select(.downloadTitle | test("DaVinci Resolve")) | .downloadTitle]' | grep -oP 'DaVinci Resolve Studio \K\d+\.\d+(\.\d+)?' | sort | tail -n 1)" + update-source-version davinci-resolve-studio "$latestStudioLinuxVersion" --source-key=davinci.src + ''; + } + ); + }; + }; +in +{ + environment.systemPackages = [ davinci-resolve-studio-cracked ]; + + # following configuration was taken from + # https://wiki.nixos.org/wiki/DaVinci_Resolve#AMD + # + # Tested and working with AMD cards. + # I don't know any configurations for Nvidia cards! + environment.variables = { + RUSTICL_ENABLE = "radeonsi"; + }; + hardware = { + # this option sets hardware.graphics.enable to true + # and installs rocmPackages.clr/.icd + amdgpu.opencl.enable = true; + graphics.extraPackages = with pkgs; [ + # Enables Rusticl (OpenCL) support + # Without this, videos won't load in davinci + mesa.opencl + ]; + }; +} diff --git a/flake.nix b/flake.nix index 20dcade..f57471c 100644 --- a/flake.nix +++ b/flake.nix @@ -50,6 +50,7 @@ modules = [ ./configuration-pc.nix ./common.nix + ./davinci.nix hardwareConfig { nixpkgs.config.allowUnfree = true;