Skip to content

Commit

Permalink
Merge pull request #322093 from atorres1985-contrib/duckstation
Browse files Browse the repository at this point in the history
duckstation: 0.1.6658 -> 0.1.6759
  • Loading branch information
thiagokokada authored Jul 22, 2024
2 parents 4742394 + 2a2f7c6 commit dd2fd2d
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 45 deletions.
40 changes: 16 additions & 24 deletions pkgs/by-name/du/duckstation/package.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{ lib
, stdenv
, fetchFromGitHub
, SDL2
, callPackage
, cmake
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
21 changes: 0 additions & 21 deletions pkgs/by-name/du/duckstation/shaderc-patched.nix

This file was deleted.

70 changes: 70 additions & 0 deletions pkgs/by-name/du/duckstation/sources.nix
Original file line number Diff line number Diff line change
@@ -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"
];
})
];
}
);
}

0 comments on commit dd2fd2d

Please sign in to comment.