27 let stdenv = gccStdenv;
29 stdenv.mkDerivation rec {
33 src = fetchFromGitHub {
34 owner = "just-buildsystem";
37 hash = "sha256-kv7HpDEYZml5uk06s8Cxt5rEpxaJBz9s+or6Od1q4Io=";
41 url = "https://github.com/bazelbuild/remote-apis/archive/e1fe21be4c9ae76269a5a63215bb3c72ed9ab3f0.tar.gz";
42 hash = "sha256-dCGr1TUsz5J8IFBFOk2/ofexxxcOw+hwK2/i05uIBf4=";
45 googleapi = fetchurl {
46 url = "https://github.com/googleapis/googleapis/archive/2f9af297c84c55c8b871ba4495e01ade42476c92.tar.gz";
47 hash = "sha256-W7awJTzPZLU9bHJJYlp+P2w7xkAqvVLTd4v6SCWHA6A=";
52 # Tools for the bootstrap process
60 # Dependencies of just
62 # Using fmt 10 because this is the same version upstream currently
63 # uses for bundled builds
64 # For future updates: The currently used version can be found in the file
65 # etc/repos.json: https://github.com/just-buildsystem/justbuild/blob/master/etc/repos.json
66 # under the key .repositories.fmt
71 # Dependencies of the compiled just-mr
85 sed -ie 's|\./bin/just-mr.py|${python3}/bin/python3 ./bin/just-mr.py|' bin/bootstrap.py
86 sed -ie 's|#!/usr/bin/env python3|#!${python3}/bin/python3|' bin/parallel-bootstrap-traverser.py
87 jq '.repositories.protobuf.pkg_bootstrap.local_path = "${protobuf_25}"' etc/repos.json > etc/repos.json.patched
88 mv etc/repos.json.patched etc/repos.json
89 jq '.repositories.com_github_grpc_grpc.pkg_bootstrap.local_path = "${grpc}"' etc/repos.json > etc/repos.json.patched
90 mv etc/repos.json.patched etc/repos.json
91 jq '.unknown.PATH = []' etc/toolchain/CC/TARGETS > etc/toolchain/CC/TARGETS.patched
92 mv etc/toolchain/CC/TARGETS.patched etc/toolchain/CC/TARGETS
93 '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
94 sed -ie 's|-Wl,-z,stack-size=8388608|-Wl,-stack_size,0x800000|' bin/bootstrap.py
97 /* The build phase follows the bootstrap procedure that is explained in
98 https://github.com/just-buildsystem/justbuild/blob/master/INSTALL.md
100 The bootstrap of the just binary depends on two proto libraries, which are
101 supplied as external distfiles.
103 The microsoft-gsl library does not provide a pkg-config file, so one is
104 created here. In case also the GNU Scientific Library would be used (which
105 has also the pkg-config name gsl) this would cause a conflict. However, it
106 is very unlikely that a build tool will ever depend on a GPL math library.
108 The extra build flags (ADD_CFLAGS and ADD_CXXFLAGS) are only needed in the
109 current version of just, the next release will contain a fix from upstream.
110 https://github.com/just-buildsystem/justbuild/commit/5abcd4140a91236c7bda1c21ce69e76a28da7c8a
118 ln -s ${bazelapi} .distfiles/e1fe21be4c9ae76269a5a63215bb3c72ed9ab3f0.tar.gz
119 ln -s ${googleapi} .distfiles/2f9af297c84c55c8b871ba4495e01ade42476c92.tar.gz
122 cat << __EOF__ > .pkgconfig/gsl.pc
127 Cflags: -I${microsoft-gsl}/include
129 export PKG_CONFIG_PATH=`pwd`/.pkgconfig''${PKG_CONFIG_PATH:+:}$PKG_CONFIG_PATH
133 export NON_LOCAL_DEPS='[ "google_apis", "bazel_remote_apis" ]'
134 export JUST_BUILD_CONF=`echo $PATH | jq -R '{ ENV: { PATH: . }, "ADD_CXXFLAGS": ["-D__unix__", "-DFMT_HEADER_ONLY"], "ARCH": "'$(uname -m)'" }'`
137 python3 ./bin/bootstrap.py `pwd` ../build "`pwd`/.distfiles"
139 # Build compiled just-mr
140 ../build/out/bin/just install 'installed just-mr' -c ../build/build-conf.json -C ../build/repo-conf.json --output-dir ../build/out --local-build-root ../build/.just
142 # convert man pages from Markdown to man
143 find "./share/man" -name "*.md" -exec sh -c '${pandoc}/bin/pandoc --standalone --to man -o "''${0%.md}" "''${0}"' {} \;
153 install -m 755 -Dt "$out/bin" "../build/out/bin/just"
154 install -m 755 -Dt "$out/bin" "../build/out/bin/just-mr"
155 install -m 755 -DT "bin/just-import-git.py" "$out/bin/just-import-git"
156 install -m 755 -DT "bin/just-deduplicate-repos.py" "$out/bin/just-deduplicate-repos"
158 mkdir -p "$out/share/bash-completion/completions"
159 install -m 0644 ./share/just_complete.bash "$out/share/bash-completion/completions/just"
161 mkdir -p "$out/share/man/"{man1,man5}
162 install -m 0644 -t "$out/share/man/man1" ./share/man/*.1
163 install -m 0644 -t "$out/share/man/man5" ./share/man/*.5
169 broken = stdenv.hostPlatform.isDarwin;
170 description = "Generic build tool";
171 homepage = "https://github.com/just-buildsystem/justbuild";
172 license = licenses.asl20;
173 maintainers = with maintainers; [clkamp];