|
1 |
| -{ stdenv, pythonPackages }: |
| 1 | +{ stdenv, pythonPackages, runCommand, curl }: |
2 | 2 |
|
3 | 3 | with stdenv.lib;
|
4 | 4 | with pythonPackages;
|
|
22 | 22 | maintainers = with maintainers; [ copumpkin ];
|
23 | 23 | };
|
24 | 24 | };
|
| 25 | + |
| 26 | + pants13-version = "1.3.0rc2"; |
| 27 | + |
| 28 | + # TODO: compile the rust native engine ourselves so we don't need to do this shit. We don't use |
| 29 | + # fetchurl because we don't know the URL ahead of time, even though it's deterministic. So we have |
| 30 | + # this downloader figure out the URL on the fly and then produce the deterministic result, so we |
| 31 | + # can still be a fixed-output derivation. |
| 32 | + pants13-native-engine-prefix = { |
| 33 | + "x86_64-darwin" = "mac/10.11"; |
| 34 | + "x86_64-linux" = "linux/x86_64"; |
| 35 | + "i686-linux" = "linux/i386"; |
| 36 | + }.${stdenv.system} or (throw "Unsupported system ${stdenv.system}!"); |
| 37 | + |
| 38 | + pants13-native-engine = runCommand "pants-native-${pants13-version}" { |
| 39 | + buildInputs = [ curl ]; |
| 40 | + outputHashMode = "recursive"; |
| 41 | + outputHashAlgo = "sha256"; |
| 42 | + outputHash = "0n8z7rg0yfpxplvcw88lwv733zkhbzhc4w4zd4aznbcmfqdiz5br"; |
| 43 | + } '' |
| 44 | + native_version=$(curl -k -L https://raw.githubusercontent.com/pantsbuild/pants/release_${pants13-version}/src/python/pants/engine/subsystem/native_engine_version) |
| 45 | + curl -kLO "https://dl.bintray.com/pantsbuild/bin/build-support/bin/native-engine/${pants13-native-engine-prefix}/$native_version/native_engine.so" |
| 46 | +
|
| 47 | + # Ugh it tries to "download" from this prefix so let's just replicate their directory structure for now... |
| 48 | + mkdir -p $out/bin/native-engine/${pants13-native-engine-prefix}/$native_version/ |
| 49 | +
|
| 50 | + # These should behave the same way in Nix land and we try not to differentiate between OS revisions... |
| 51 | + ln -s 10.11 $out/bin/native-engine/mac/10.10 |
| 52 | + ln -s 10.11 $out/bin/native-engine/mac/10.12 |
| 53 | +
|
| 54 | + cp native_engine.so $out/bin/native-engine/${pants13-native-engine-prefix}/$native_version/ |
| 55 | + ''; |
25 | 56 | in {
|
26 | 57 | pants =
|
27 | 58 | pythonPackages.buildPythonPackage rec {
|
|
61 | 92 |
|
62 | 93 | pants13-pre = buildPythonApplication rec {
|
63 | 94 | pname = "pantsbuild.pants";
|
64 |
| - version = "1.3.0rc2"; |
| 95 | + version = pants13-version; |
65 | 96 | name = "${pname}-${version}";
|
66 | 97 |
|
67 | 98 | src = fetchPypi {
|
|
71 | 102 |
|
72 | 103 | prePatch = ''
|
73 | 104 | sed -E -i "s/'([[:alnum:].-]+)[=><][[:digit:]=><.,]*'/'\\1'/g" setup.py
|
| 105 | +
|
| 106 | + substituteInPlace src/pants/option/global_options.py \ |
| 107 | + --replace "'/etc/pantsrc'" "'$out/etc/pantsrc', '/etc/pantsrc'" |
74 | 108 | '';
|
75 | 109 |
|
76 | 110 | # Unnecessary, and causes some really weird behavior around .class files, which
|
|
84 | 118 | fasteners coverage pywatchman futures cffi
|
85 | 119 | ];
|
86 | 120 |
|
| 121 | + # Teach pants about where its native engine lives. |
| 122 | + # TODO: there's probably a better way to teach it this without having it "download" |
| 123 | + # from a local file: URL to its cache, but I don't know how and this seems to work. |
| 124 | + postFixup = '' |
| 125 | + mkdir -p $out/etc |
| 126 | + cat >$out/etc/pantsrc <<EOF |
| 127 | + [binaries] |
| 128 | + baseurls: [ 'file://${pants13-native-engine}' ] |
| 129 | + EOF |
| 130 | + ''; |
| 131 | + |
87 | 132 | meta = {
|
88 | 133 | description = "A build system for software projects in a variety of languages";
|
89 | 134 | homepage = "http://www.pantsbuild.org/";
|
|
0 commit comments