Skyler Grey | 1909a0b | 2023-05-03 20:33:53 +0000 | [diff] [blame] | 1 | { stdenv, p7zip, zip, python3, qt5 }: |
| 2 | let |
Skyler Grey | 77d1fbf | 2023-01-26 00:43:49 +0000 | [diff] [blame] | 3 | preExec = '' |
Skyler Grey | 1909a0b | 2023-05-03 20:33:53 +0000 | [diff] [blame] | 4 | import os |
| 5 | sfs_select_dir = os.path.expanduser('~/.local/share/Steam/sfs-select/runtime') |
| 6 | os.makedirs(sfs_select_dir, exist_ok=True) |
| 7 | os.chdir(sfs_select_dir) |
Skyler Grey | 77d1fbf | 2023-01-26 00:43:49 +0000 | [diff] [blame] | 8 | |
| 9 | |
| 10 | ''; |
Skyler Grey | 1909a0b | 2023-05-03 20:33:53 +0000 | [diff] [blame] | 11 | preExecBash = builtins.replaceStrings [ "\n" ] [ "\\n" ] preExec; |
| 12 | in |
| 13 | stdenv.mkDerivation { |
Skyler Grey | f4c2e67 | 2022-10-31 00:29:45 +0000 | [diff] [blame] | 14 | pname = "sfs-select"; |
| 15 | version = "0.5.0"; |
| 16 | |
| 17 | src = builtins.fetchurl { |
| 18 | url = "https://www.unix-ag.uni-kl.de/~t_schmid/sfs-select/sfs-select-0.5.0-full.7z"; |
| 19 | sha256 = "sha256:130ks9vc33r9aycbbz3i8agcy7gjijmfvv94pd4ndxmwl2ndmrh2"; |
| 20 | }; |
| 21 | unpackPhase = '' |
| 22 | runHook preUnpack |
| 23 | |
| 24 | ${p7zip}/bin/7z x $src -o. -y |
| 25 | |
| 26 | runHook postUnpack |
| 27 | ''; |
| 28 | |
| 29 | buildPhase = '' |
| 30 | runHook preBuild |
| 31 | |
Skyler Grey | 77d1fbf | 2023-01-26 00:43:49 +0000 | [diff] [blame] | 32 | mv ./sfs-select/python/sfs-select.py ./sfs-select/python/__main__.py |
| 33 | |
| 34 | |
| 35 | sed -i "1i${preExecBash}" ./sfs-select/python/__main__.py |
Skyler Grey | f4c2e67 | 2022-10-31 00:29:45 +0000 | [diff] [blame] | 36 | ${zip}/bin/zip -rj sfs-select.zip ./sfs-select/python/* |
| 37 | |
| 38 | runHook postBuild |
| 39 | ''; |
| 40 | |
| 41 | installPhase = '' |
| 42 | runHook preBuild |
| 43 | |
| 44 | mkdir -p $out/bin |
| 45 | |
| 46 | echo '#!/usr/bin/env python' | cat - sfs-select.zip > $out/bin/sfs-select |
| 47 | |
| 48 | chmod +x $out/bin/sfs-select |
| 49 | |
Skyler Grey | 7873141 | 2023-05-02 13:20:14 +0000 | [diff] [blame] | 50 | wrapQtApp $out/bin/sfs-select |
Skyler Grey | f4c2e67 | 2022-10-31 00:29:45 +0000 | [diff] [blame] | 51 | |
| 52 | runHook postBuild |
| 53 | ''; |
| 54 | |
| 55 | nativeBuildInputs = [ p7zip zip qt5.wrapQtAppsHook ]; |
| 56 | buildInputs = [ |
| 57 | (python3.withPackages (pythonPackages: with pythonPackages; [ |
| 58 | psutil |
| 59 | pyqt5 |
| 60 | ])) |
| 61 | ]; |
| 62 | dontWrapQtApps = true; |
| 63 | } |