summaryrefslogtreecommitdiffstats
path: root/pkgs/common-updater/scripts.nix
blob: c84eced0a007a36e792350f6014fd2d783d19b1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{
  lib,
  stdenv,
  makeWrapper,
  coreutils,
  diffutils,
  git,
  gnugrep,
  gnused,
  jq,
  nix,
  python3Packages,
}:

stdenv.mkDerivation {
  name = "common-updater-scripts";

  nativeBuildInputs = [
    makeWrapper
    python3Packages.wrapPython
  ];

  pythonPath = [
    python3Packages.beautifulsoup4
    python3Packages.requests
  ];

  dontUnpack = true;

  installPhase = ''
    mkdir -p $out/bin
    cp ${./scripts}/* $out/bin

    # wrap non python scripts
    for f in $out/bin/*; do
      if ! (head -n1 "$f" | grep -q '#!.*/env.*\(python\|pypy\)'); then
        wrapProgram $f --prefix PATH : ${
          lib.makeBinPath [
            coreutils
            diffutils
            git
            gnugrep
            gnused
            jq
            nix
          ]
        }
      fi
    done

    # wrap python scripts
    makeWrapperArgs+=( --prefix PATH : "${lib.makeBinPath [ nix ]}" )
    wrapPythonPrograms
  '';
}