diff --git a/pkgs/by-name/du/duckstation/package.nix b/pkgs/by-name/du/duckstation/package.nix index 37d2d01534b1..453d272458e2 100644 --- a/pkgs/by-name/du/duckstation/package.nix +++ b/pkgs/by-name/du/duckstation/package.nix @@ -1,6 +1,5 @@ { lib , stdenv -, fetchFromGitHub , SDL2 , callPackage , cmake @@ -14,13 +13,12 @@ , ninja , pkg-config , qt6 -, substituteAll , vulkan-loader , wayland }: let - shaderc-patched = callPackage ./shaderc-patched.nix { }; + sources = callPackage ./sources.nix { }; inherit (qt6) qtbase qtsvg @@ -30,32 +28,17 @@ let ; in stdenv.mkDerivation (finalAttrs: { - pname = "duckstation"; - version = "0.1-6658"; - - src = fetchFromGitHub { - owner = "stenzek"; - repo = "duckstation"; - rev = "4e0c417add264226b3db065c1466791f0591a1b5"; - hash = "sha256-fN0bcjqjMmK3qVLlrYmR2VgjK0BjdK4nUj8vNYdFC3I="; - }; + inherit (sources.duckstation) pname version src; patches = [ # Tests are not built by default ./001-fix-test-inclusion.diff - # Patching yet another script that fills data based on git commands... - (substituteAll { - src = ./002-hardcode-vars.diff; - gitHash = finalAttrs.src.rev; - gitBranch = "master"; - gitTag = "${finalAttrs.version}-g4e0c417a"; - gitDate = "2024-04-16T12:49:54+10:00"; - }) + # Patching yet another script that fills data based on git commands . . . + ./002-hardcode-vars.diff ]; nativeBuildInputs = [ cmake - extra-cmake-modules ninja pkg-config qttools @@ -65,25 +48,34 @@ stdenv.mkDerivation (finalAttrs: { buildInputs = [ SDL2 curl + extra-cmake-modules libXrandr libbacktrace libwebp qtbase qtsvg qtwayland - shaderc-patched + sources.shaderc-patched wayland ] ++ cubeb.passthru.backendLibs; - strictDeps = true; - cmakeFlags = [ (lib.cmakeBool "BUILD_TESTS" true) ]; + strictDeps = true; + doInstallCheck = true; + postPatch = '' + gitHash=$(cat .nixpkgs-auxfiles/git_hash) \ + gitBranch=$(cat .nixpkgs-auxfiles/git_branch) \ + gitTag=$(cat .nixpkgs-auxfiles/git_tag) \ + gitDate=$(cat .nixpkgs-auxfiles/git_date) \ + substituteAllInPlace src/scmversion/gen_scmversion.sh + ''; + installCheckPhase = '' runHook preCheck diff --git a/pkgs/by-name/du/duckstation/shaderc-patched.nix b/pkgs/by-name/du/duckstation/shaderc-patched.nix deleted file mode 100644 index 72aa4b17ca08..000000000000 --- a/pkgs/by-name/du/duckstation/shaderc-patched.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ - lib, - fetchpatch, - duckstation, - shaderc, -}: - -shaderc.overrideAttrs (old: { - pname = "shaderc-patched-for-duckstation"; - patches = (old.patches or [ ]) ++ [ - (fetchpatch { - url = "file://${duckstation.src}/scripts/shaderc-changes.patch"; - hash = "sha256-Ps/D+CdSbjVWg3ZGOEcgbpQbCNkI5Nuizm4E5qiM9Wo="; - excludes = [ - "CHANGES" - "CMakeLists.txt" - "libshaderc/CMakeLists.txt" - ]; - }) - ]; -}) diff --git a/pkgs/by-name/du/duckstation/sources.nix b/pkgs/by-name/du/duckstation/sources.nix new file mode 100644 index 000000000000..34478629f93d --- /dev/null +++ b/pkgs/by-name/du/duckstation/sources.nix @@ -0,0 +1,70 @@ +{ + lib, + duckstation, + fetchFromGitHub, + fetchpatch, + shaderc, +}: + +{ + duckstation = let + self = { + pname = "duckstation"; + version = "0.1-6759"; + src = fetchFromGitHub { + owner = "stenzek"; + repo = "duckstation"; + rev = "refs/tags/v${self.version}"; + # + # Some files are filled by using Git commands; it requires deepClone. + # More info at `checkout_ref` function in nix-prefetch-git. + # However, `.git` is a bit nondeterministic (and Git itself makes no + # guarrantees whatsoever). + # Then, in order to enhance reproducibility, what we will do here is: + # + # - Execute the desired Git commands; + # - Save the obtained info into files; + # - Remove `.git` afterwards. + # + deepClone = true; + postFetch = '' + cd $out + mkdir -p .nixpkgs-auxfiles/ + git rev-parse HEAD > .nixpkgs-auxfiles/git_hash + git rev-parse --abbrev-ref HEAD | tr -d '\r\n' > .nixpkgs-auxfiles/git_branch + git describe --dirty | tr -d '\r\n' > .nixpkgs-auxfiles/git_tag + git log -1 --date=iso8601-strict --format=%cd > .nixpkgs-auxfiles/git_date + find $out -name .git -print0 | xargs -0 rm -fr + ''; + hash = "sha256-HETo7mChBASnr5prPUWcOhS4TIESFdrs1haEXQpnuzs="; + }; + }; + in + self; + + shaderc-patched = shaderc.overrideAttrs (old: let + version = "2024.0"; + src = fetchFromGitHub { + owner = "google"; + repo = "shaderc"; + rev = "v${version}"; + hash = "sha256-Cwp7WbaKWw/wL9m70wfYu47xoUGQW+QGeoYhbyyzstQ="; + }; + in + { + pname = "shaderc-patched-for-duckstation"; + inherit version src; + patches = (old.patches or [ ]) ++ [ + (fetchpatch { + url = "file://${duckstation.src}/scripts/shaderc-changes.patch"; + hash = "sha256-Ps/D+CdSbjVWg3ZGOEcgbpQbCNkI5Nuizm4E5qiM9Wo="; + excludes = [ + "CHANGES" + "CMakeLists.txt" + "libshaderc/CMakeLists.txt" + ]; + }) + ]; + } + ); +}