From 19b42ca7b3f799408ea78fccd7d5ca893a31d878 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sun, 23 Jun 2024 23:47:46 -0300 Subject: [PATCH 1/5] duckstation: detach sources acquisition to sources.nix The build scripts used by upstream require Git commands. Because of this, a `deepClone` is required by fetchFromGitHub. However, keeping `.git` directory around is detrimental to determinism. Because of this, we need to run the Git commands "manually", save their outputs and finally remove `.git`. In order to not pollute the `package.nix`, this peculiar source acquisition is detached to its own file and `callPackage`d. Before this Jesuitic hack, the aforementioned data were obtained and filled by human hands... --- pkgs/by-name/du/duckstation/package.nix | 31 ++++++++----------- pkgs/by-name/du/duckstation/sources.nix | 40 +++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 pkgs/by-name/du/duckstation/sources.nix diff --git a/pkgs/by-name/du/duckstation/package.nix b/pkgs/by-name/du/duckstation/package.nix index 37d2d01534b1a..f6347e427b360 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 0000000000000..d72364c4e97cf --- /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; +} From 1954fef0d99e7d3bbfa3cd304b7c40f26dfc9043 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Mon, 24 Jun 2024 00:31:12 -0300 Subject: [PATCH 2/5] duckstation: pin shaderc-patched Since new versions arrived, we should pin that old piece. --- .../du/duckstation/shaderc-patched.nix | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/pkgs/by-name/du/duckstation/shaderc-patched.nix b/pkgs/by-name/du/duckstation/shaderc-patched.nix index 72aa4b17ca087..9cedb99ebeebb 100644 --- a/pkgs/by-name/du/duckstation/shaderc-patched.nix +++ b/pkgs/by-name/du/duckstation/shaderc-patched.nix @@ -1,21 +1,33 @@ { lib, - fetchpatch, duckstation, + fetchFromGitHub, + fetchpatch, 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" - ]; - }) - ]; -}) +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" + ]; + }) + ]; + } +) From 94d4a294ef35e82b4d188b262a27d8713f5bbb91 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sun, 21 Jul 2024 23:05:20 -0300 Subject: [PATCH 3/5] duckstation: migrate shaderc-patched to sources.nix --- pkgs/by-name/du/duckstation/package.nix | 3 +- .../du/duckstation/shaderc-patched.nix | 33 ------------------- pkgs/by-name/du/duckstation/sources.nix | 30 +++++++++++++++++ 3 files changed, 31 insertions(+), 35 deletions(-) delete mode 100644 pkgs/by-name/du/duckstation/shaderc-patched.nix diff --git a/pkgs/by-name/du/duckstation/package.nix b/pkgs/by-name/du/duckstation/package.nix index f6347e427b360..1f0eac6130fd7 100644 --- a/pkgs/by-name/du/duckstation/package.nix +++ b/pkgs/by-name/du/duckstation/package.nix @@ -19,7 +19,6 @@ let sources = callPackage ./sources.nix { }; - shaderc-patched = callPackage ./shaderc-patched.nix { }; inherit (qt6) qtbase qtsvg @@ -56,7 +55,7 @@ stdenv.mkDerivation (finalAttrs: { qtbase qtsvg qtwayland - shaderc-patched + sources.shaderc-patched wayland ] ++ cubeb.passthru.backendLibs; 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 9cedb99ebeebb..0000000000000 --- a/pkgs/by-name/du/duckstation/shaderc-patched.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ - lib, - duckstation, - fetchFromGitHub, - fetchpatch, - shaderc, -}: - -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" - ]; - }) - ]; - } -) diff --git a/pkgs/by-name/du/duckstation/sources.nix b/pkgs/by-name/du/duckstation/sources.nix index d72364c4e97cf..b52b87d45eb3b 100644 --- a/pkgs/by-name/du/duckstation/sources.nix +++ b/pkgs/by-name/du/duckstation/sources.nix @@ -1,5 +1,9 @@ { + lib, + duckstation, fetchFromGitHub, + fetchpatch, + shaderc, }: { @@ -37,4 +41,30 @@ }; 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" + ]; + }) + ]; + } + ); } From cbde8688f73f430ad86a5a72d646f80c16108739 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Mon, 24 Jun 2024 00:08:57 -0300 Subject: [PATCH 4/5] duckstation: cosmetic hammering --- pkgs/by-name/du/duckstation/package.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/by-name/du/duckstation/package.nix b/pkgs/by-name/du/duckstation/package.nix index 1f0eac6130fd7..c11df329700e4 100644 --- a/pkgs/by-name/du/duckstation/package.nix +++ b/pkgs/by-name/du/duckstation/package.nix @@ -60,12 +60,14 @@ stdenv.mkDerivation (finalAttrs: { ] ++ 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) \ @@ -74,8 +76,6 @@ stdenv.mkDerivation (finalAttrs: { substituteAllInPlace src/scmversion/gen_scmversion.sh ''; - doInstallCheck = true; - installCheckPhase = '' runHook preCheck From 2a2f7c6572df0ec164fc214710af1a2177088357 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Mon, 24 Jun 2024 00:18:22 -0300 Subject: [PATCH 5/5] duckstation: 0.1.6658 -> 0.1.6759 --- pkgs/by-name/du/duckstation/package.nix | 2 +- pkgs/by-name/du/duckstation/sources.nix | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/du/duckstation/package.nix b/pkgs/by-name/du/duckstation/package.nix index c11df329700e4..453d272458e2a 100644 --- a/pkgs/by-name/du/duckstation/package.nix +++ b/pkgs/by-name/du/duckstation/package.nix @@ -39,7 +39,6 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ cmake - extra-cmake-modules ninja pkg-config qttools @@ -49,6 +48,7 @@ stdenv.mkDerivation (finalAttrs: { buildInputs = [ SDL2 curl + extra-cmake-modules libXrandr libbacktrace libwebp diff --git a/pkgs/by-name/du/duckstation/sources.nix b/pkgs/by-name/du/duckstation/sources.nix index b52b87d45eb3b..34478629f93d3 100644 --- a/pkgs/by-name/du/duckstation/sources.nix +++ b/pkgs/by-name/du/duckstation/sources.nix @@ -10,7 +10,7 @@ duckstation = let self = { pname = "duckstation"; - version = "0.1-6658"; + version = "0.1-6759"; src = fetchFromGitHub { owner = "stenzek"; repo = "duckstation"; @@ -36,7 +36,7 @@ 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="; + hash = "sha256-HETo7mChBASnr5prPUWcOhS4TIESFdrs1haEXQpnuzs="; }; }; in