diff --git a/pkgs/by-name/du/duckstation/package.nix b/pkgs/by-name/du/duckstation/package.nix index 37d2d01534b1..f6347e427b36 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,12 +13,12 @@ , ninja , pkg-config , qt6 -, substituteAll , vulkan-loader , wayland }: let + sources = callPackage ./sources.nix { }; shaderc-patched = callPackage ./shaderc-patched.nix { }; inherit (qt6) qtbase @@ -30,27 +29,13 @@ 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 = [ @@ -82,6 +67,14 @@ stdenv.mkDerivation (finalAttrs: { (lib.cmakeBool "BUILD_TESTS" 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 + ''; + doInstallCheck = true; installCheckPhase = '' diff --git a/pkgs/by-name/du/duckstation/sources.nix b/pkgs/by-name/du/duckstation/sources.nix new file mode 100644 index 000000000000..d72364c4e97c --- /dev/null +++ b/pkgs/by-name/du/duckstation/sources.nix @@ -0,0 +1,40 @@ +{ + fetchFromGitHub, +}: + +{ + duckstation = let + self = { + pname = "duckstation"; + version = "0.1-6658"; + 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-ZP9WYaz9e6x3x4UpuW2ep5sc+nUT2O+b0048bmkW0ac="; + }; + }; + in + self; +}