btrbk: add mainProgram
[NixPkgs.git] / pkgs / by-name / du / duckstation / sources.nix
blob34478629f93d32767fa475532d1cb330464cc90a
2   lib,
3   duckstation,
4   fetchFromGitHub,
5   fetchpatch,
6   shaderc,
7 }:
10   duckstation = let
11     self = {
12       pname = "duckstation";
13       version = "0.1-6759";
14       src = fetchFromGitHub {
15         owner = "stenzek";
16         repo = "duckstation";
17         rev = "refs/tags/v${self.version}";
18         #
19         # Some files are filled by using Git commands; it requires deepClone.
20         # More info at `checkout_ref` function in nix-prefetch-git.
21         # However, `.git` is a bit nondeterministic (and Git itself makes no
22         # guarrantees whatsoever).
23         # Then, in order to enhance reproducibility, what we will do here is:
24         #
25         # - Execute the desired Git commands;
26         # - Save the obtained info into files;
27         # - Remove `.git` afterwards.
28         #
29         deepClone = true;
30         postFetch = ''
31           cd $out
32           mkdir -p .nixpkgs-auxfiles/
33           git rev-parse HEAD > .nixpkgs-auxfiles/git_hash
34           git rev-parse --abbrev-ref HEAD | tr -d '\r\n' > .nixpkgs-auxfiles/git_branch
35           git describe --dirty | tr -d '\r\n' > .nixpkgs-auxfiles/git_tag
36           git log -1 --date=iso8601-strict --format=%cd > .nixpkgs-auxfiles/git_date
37           find $out -name .git -print0 | xargs -0 rm -fr
38         '';
39         hash = "sha256-HETo7mChBASnr5prPUWcOhS4TIESFdrs1haEXQpnuzs=";
40       };
41     };
42   in
43     self;
45   shaderc-patched = shaderc.overrideAttrs (old: let
46     version = "2024.0";
47     src = fetchFromGitHub {
48       owner = "google";
49       repo = "shaderc";
50       rev = "v${version}";
51       hash = "sha256-Cwp7WbaKWw/wL9m70wfYu47xoUGQW+QGeoYhbyyzstQ=";
52     };
53   in
54     {
55       pname = "shaderc-patched-for-duckstation";
56       inherit version src;
57       patches = (old.patches or [ ]) ++ [
58         (fetchpatch {
59           url = "file://${duckstation.src}/scripts/shaderc-changes.patch";
60           hash = "sha256-Ps/D+CdSbjVWg3ZGOEcgbpQbCNkI5Nuizm4E5qiM9Wo=";
61           excludes = [
62             "CHANGES"
63             "CMakeLists.txt"
64             "libshaderc/CMakeLists.txt"
65           ];
66         })
67       ];
68     }
69   );