biome: 1.9.2 -> 1.9.3
[NixPkgs.git] / pkgs / tools / games / steamtinkerlaunch / default.nix
blob0d7551ca30a2d14b99024b2cd6572d1ec2b2a7fa
1 { bash
2 , fetchFromGitHub
3 , gawk
4 , git
5 , lib
6 , procps
7 , stdenvNoCC
8 , unixtools
9 , unzip
10 , wget
11 , xdotool
12 , xorg
13 , yad
14 , writeShellApplication
17 stdenvNoCC.mkDerivation {
18   pname = "steamtinkerlaunch";
19   version = "12.12-unstable-2024-05-03";
21   src = fetchFromGitHub {
22     owner = "sonic2kk";
23     repo = "steamtinkerlaunch";
24     rev = "59b421b2f3686120a076909a4a158824cd4ef05e";
25     hash = "sha256-CGtSGAm+52t2zFsPJEsm76w+FEHhbOd9NYuerGa31tc=";
26   };
28   outputs = [ "out" "steamcompattool" ];
30   installFlags = [ "PREFIX=\${out}" ];
32   nativeBuildInputs = let
33     # We need a `steam` command in order to install the compat tool
34     fakeSteam = writeShellApplication {
35       name = "steam";
36       text = "exit 0";
37     };
38   in [
39     fakeSteam
40   ];
42   postInstall =
43     let
44       # We (ab)use writeShellApplication to produce a header for a shell script
45       # here in order to add the runtimePath to the original script. We cannot
46       # wrap here as that always corrupts $0 in bash scripts which STL uses to
47       # install its compat tool.
48       header = writeShellApplication {
49         runtimeInputs = [
50           bash
51           gawk
52           git
53           procps
54           unixtools.xxd
55           unzip
56           wget
57           xdotool
58           xorg.xprop
59           xorg.xrandr
60           xorg.xwininfo
61           yad
62         ];
63         name = "stl-head";
64         text = "";
65         bashOptions = [ ];
66       };
67       fakeYad = writeShellApplication {
68         name = "yad";
69         text = "echo ${yad.version} FAKE";
70       };
71     in
72     ''
73       cp $out/bin/steamtinkerlaunch $TMPDIR/steamtinkerlaunch
74       install ${lib.getExe header} -T $out/bin/steamtinkerlaunch
75       tail -n +2 $TMPDIR/steamtinkerlaunch >> $out/bin/steamtinkerlaunch
77       # Create a fake steam dir, it checks this and reads a few values
78       steamdir=$TMPDIR/.local/share/Steam/
79       mkdir -p $steamdir/config/
80       echo \"path\" \"$steamdir\" > $steamdir/config/config.vdf
81       mkdir $TMPDIR/.steam/
82       ln -s $steamdir $TMPDIR/.steam/steam
84       cp -a $out/bin/steamtinkerlaunch $TMPDIR/steamtinkerlaunch
85       # yad cannot print its version without a graphical session https://github.com/v1cont/yad/issues/277
86       substituteInPlace $TMPDIR/steamtinkerlaunch --replace ${yad} ${fakeYad}
87       HOME=$TMPDIR $TMPDIR/steamtinkerlaunch compat add
89       cp -a $steamdir/compatibilitytools.d/SteamTinkerLaunch $steamcompattool
90       # It creates this symlink but it points to $TMPDIR
91       ln -sfn $out/bin/steamtinkerlaunch $steamcompattool/
92     '';
94   meta = with lib; {
95     description = "Linux wrapper tool for use with the Steam client for custom launch options and 3rd party programs";
96     mainProgram = "steamtinkerlaunch";
97     homepage = "https://github.com/sonic2kk/steamtinkerlaunch";
98     license = licenses.gpl3;
99     maintainers = with maintainers; [ urandom surfaceflinger ];
100     platforms = lib.platforms.linux;
101   };