1{ lib
2, callPackage
3, python27Packages
4, installShellFiles
5, fetchFromGitHub
6, file
7, findutils
8, gettext
9, bats
10, bash
11, doCheck ? true
12}:
13let
14 version = "0.5.1";
15 rSrc = fetchFromGitHub {
16 owner = "abathur";
17 repo = "resholve";
18 rev = "v${version}";
19 hash = "sha256-+9MjvO1H+A3Ol2to5tWqdpNR7osQsYcbkX9avAqyrKw=";
20 };
21 deps = callPackage ./deps.nix {
22 /*
23 resholve needs to patch Oil, but trying to avoid adding
24 them all *to* nixpkgs, since they aren't specific to
25 nix/nixpkgs.
26 */
27 oilPatches = [
28 "${rSrc}/0001-add_setup_py.patch"
29 "${rSrc}/0002-add_MANIFEST_in.patch"
30 "${rSrc}/0003-fix_codegen_shebang.patch"
31 "${rSrc}/0004-disable-internal-py-yajl-for-nix-built.patch"
32 "${rSrc}/0005_revert_libc_locale.patch"
33 "${rSrc}/0006_disable_failing_libc_tests.patch"
34 "${rSrc}/0007_restore_root_init_py.patch"
35 ];
36 };
37in
38python27Packages.buildPythonApplication {
39 pname = "resholve";
40 inherit version;
41 src = rSrc;
42 format = "other";
43
44 nativeBuildInputs = [ installShellFiles ];
45
46 propagatedBuildInputs = [ deps.oildev python27Packages.ConfigArgParse ];
47
48 patchPhase = ''
49 for file in resholve; do
50 substituteInPlace $file --subst-var-by version ${version}
51 done
52 '';
53
54 installPhase = ''
55 install -Dm755 resholve $out/bin/resholve
56 installManPage resholve.1
57 '';
58
59 inherit doCheck;
60 checkInputs = [ bats ];
61 RESHOLVE_PATH = "${lib.makeBinPath [ file findutils gettext ]}";
62
63 checkPhase = ''
64 # explicit interpreter for test suite
65 export INTERP="${bash}/bin/bash" PATH="$out/bin:$PATH"
66 patchShebangs .
67 ./test.sh
68 '';
69
70 # Do not propagate Python; may be obsoleted by nixos/nixpkgs#102613
71 # for context on why, see abathur/resholve#20
72 postFixup = ''
73 rm $out/nix-support/propagated-build-inputs
74 '';
75
76 meta = with lib; {
77 description = "Resolve external shell-script dependencies";
78 homepage = "https://github.com/abathur/resholve";
79 license = with licenses; [ mit ];
80 maintainers = with maintainers; [ abathur ];
81 platforms = platforms.all;
82 };
83}