diff --git a/README.md b/README.md index fa76d76..5bc0d3d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # lsfg-vk-flake WIP! Nix flake to build the library for using Lossless Scaling's frame generation on Linux + +initially broken due to various challenges with the LLVM tools in NixOS diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..a45ac11 --- /dev/null +++ b/default.nix @@ -0,0 +1,85 @@ +{ lib +, fetchFromGitHub +, replaceVars +, srcOnly +, cmake +, meson +, ninja +, SDL2 +, glslang +#, glfw +, dxvk_2 +, vulkan-headers +, vulkan-loader +, pkg-config +, llvmPackages +#, overrideCC # lto +}: let + + peparse-git = fetchFromGitHub { + owner = "trailofbits"; + repo = "pe-parse"; + rev = "v2.1.1"; + hash = "sha256-WuG/OmzrXoH5O7+sSIdUVZP0aS63nuJwHgQfn12Q5xk="; + fetchSubmodules = true; + }; + + dxvk-git = srcOnly (dxvk_2.overrideAttrs (old: { + src = fetchFromGitHub { + owner = "doitsujin"; + repo = "dxvk"; + rev = "v2.6.2"; + hash = "sha256-nZEi9WYhpI0WaeguoZMV4nt+nfaErvgz5RNDyyZYCJA="; + fetchSubmodules = true; + }; + })); + + # stdenv_lto = overrideCC llvmPackages.stdenv (llvmPackages.stdenv.cc.override { + # inherit (llvmPackages) bintools; + # }); + # this causes problems with dxvk-git which does not like llvm's ar... + +in llvmPackages.stdenv.mkDerivation { + pname = "lsfg-vk"; + version = "0.0.31"; + + src = ./.; + + # we need to unvendor dxvk and pe-parse which would normally be downloaded from git during buildtime in the cmakefiles + patches = [ + (replaceVars ./no-download.patch { + dxvk-git = dxvk-git; + peparse-git = peparse-git; + }) + ]; + + #cmakeFlags = [ + #"-DCMAKE_BUILD_TYPE=Release" + #"-DCMAKE_INSTALL_PREFIX=${placeholder "out"}" + #"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON" # LTO + #]; + + nativeBuildInputs = [ + #llvmPackages.clang-tools # https://github.com/NixOS/nixpkgs/issues/273875 + #llvmPackages.libcxxClang # LTO: "ar: error: the 'o' modifier is only applicable to the 'x' operation" + #llvmPackages.bintools # LTO: "RANLIB-NOTFOUND, AR-NOTFOUND" + cmake + meson + ninja + pkg-config + ]; + + buildInputs = [ + dxvk-git + SDL2 + glslang + vulkan-headers + vulkan-loader + ]; + + meta = with lib; { + homepage = "https://github.com/PancakeTAS/lsfg-vk/"; + license = licenses.mit; + platforms = platforms.linux; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a63de06 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1751792365, + "narHash": "sha256-J1kI6oAj25IG4EdVlg2hQz8NZTBNYvIS0l4wpr9KcUo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1fd8bada0b6117e6c7eb54aad5813023eed37ccb", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..7e14bb7 --- /dev/null +++ b/flake.nix @@ -0,0 +1,10 @@ +{ + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + outputs = { nixpkgs, ... }: let + system = "x86_64-linux"; + pkgs = import nixpkgs { inherit system; }; + in { + packages.${system}.default = pkgs.callPackage ./default.nix {}; + }; +} diff --git a/no-download.patch b/no-download.patch new file mode 100644 index 0000000..5e5b7ac --- /dev/null +++ b/no-download.patch @@ -0,0 +1,28 @@ +diff --git a/cmake/FetchDXVK.cmake b/cmake/FetchDXVK.cmake +index f84de82..bbe9f73 100644 +--- a/cmake/FetchDXVK.cmake ++++ b/cmake/FetchDXVK.cmake +@@ -9,8 +9,7 @@ else() + endif() + + ExternalProject_Add(dxvk_git +- GIT_REPOSITORY "https://github.com/doitsujin/dxvk" +- GIT_TAG "v2.6.2" ++ URL file://@dxvk-git@ + UPDATE_DISCONNECTED true + USES_TERMINAL_CONFIGURE true + USES_TERMINAL_BUILD true +diff --git a/cmake/FetchPeParse.cmake b/cmake/FetchPeParse.cmake +index df7879b..31a4b87 100644 +--- a/cmake/FetchPeParse.cmake ++++ b/cmake/FetchPeParse.cmake +@@ -1,8 +1,7 @@ + include(ExternalProject) + + ExternalProject_Add(peparse_git +- GIT_REPOSITORY "https://github.com/trailofbits/pe-parse" +- GIT_TAG "v2.1.1" ++ URL file://@peparse-git@ + UPDATE_DISCONNECTED true + USES_TERMINAL_CONFIGURE true + USES_TERMINAL_BUILD true