34 stdenv.mkDerivation rec {
38 src = fetchFromGitHub {
39 owner = "just-buildsystem";
41 rev = "refs/tags/v${version}";
42 hash = "sha256-N9K1n2ttxhD0q2BXprt/nQdQseUtpaFmEZUcxRJV5C8=";
46 url = "https://github.com/bazelbuild/remote-apis/archive/e1fe21be4c9ae76269a5a63215bb3c72ed9ab3f0.tar.gz";
47 hash = "sha256-dCGr1TUsz5J8IFBFOk2/ofexxxcOw+hwK2/i05uIBf4=";
50 googleapi = fetchurl {
51 url = "https://github.com/googleapis/googleapis/archive/2f9af297c84c55c8b871ba4495e01ade42476c92.tar.gz";
52 hash = "sha256-W7awJTzPZLU9bHJJYlp+P2w7xkAqvVLTd4v6SCWHA6A=";
56 # Tools for the bootstrap process
64 # Dependencies of just
66 # Using fmt 10 because this is the same version upstream currently
67 # uses for bundled builds
68 # For future updates: The currently used version can be found in the file
69 # etc/repos.json: https://github.com/just-buildsystem/justbuild/blob/master/etc/repos.json
70 # under the key .repositories.fmt
75 # Dependencies of the compiled just-mr
90 sed -ie 's|\./bin/just-mr.py|${python3}/bin/python3 ./bin/just-mr.py|' bin/bootstrap.py
91 sed -ie 's|#!/usr/bin/env python3|#!${python3}/bin/python3|' bin/parallel-bootstrap-traverser.py
92 jq '.repositories.protobuf.pkg_bootstrap.local_path = "${protobuf}"' etc/repos.json > etc/repos.json.patched
93 mv etc/repos.json.patched etc/repos.json
94 jq '.repositories.com_github_grpc_grpc.pkg_bootstrap.local_path = "${grpc}"' etc/repos.json > etc/repos.json.patched
95 mv etc/repos.json.patched etc/repos.json
96 jq '.unknown.PATH = []' etc/toolchain/CC/TARGETS > etc/toolchain/CC/TARGETS.patched
97 mv etc/toolchain/CC/TARGETS.patched etc/toolchain/CC/TARGETS
99 + lib.optionalString stdenv.hostPlatform.isDarwin ''
100 sed -ie 's|-Wl,-z,stack-size=8388608|-Wl,-stack_size,0x800000|' bin/bootstrap.py
104 The build phase follows the bootstrap procedure that is explained in
105 https://github.com/just-buildsystem/justbuild/blob/master/INSTALL.md
107 The bootstrap of the just binary depends on two proto libraries, which are
108 supplied as external distfiles.
110 The microsoft-gsl library does not provide a pkg-config file, so one is
111 created here. In case also the GNU Scientific Library would be used (which
112 has also the pkg-config name gsl) this would cause a conflict. However, it
113 is very unlikely that a build tool will ever depend on a GPL math library.
115 The extra build flags (ADD_CFLAGS and ADD_CXXFLAGS) are only needed in the
116 current version of just, the next release will contain a fix from upstream.
117 https://github.com/just-buildsystem/justbuild/commit/5abcd4140a91236c7bda1c21ce69e76a28da7c8a
124 ln -s ${bazelapi} .distfiles/e1fe21be4c9ae76269a5a63215bb3c72ed9ab3f0.tar.gz
125 ln -s ${googleapi} .distfiles/2f9af297c84c55c8b871ba4495e01ade42476c92.tar.gz
128 cat << __EOF__ > .pkgconfig/gsl.pc
133 Cflags: -I${microsoft-gsl}/include
135 export PKG_CONFIG_PATH=`pwd`/.pkgconfig''${PKG_CONFIG_PATH:+:}$PKG_CONFIG_PATH
139 export NON_LOCAL_DEPS='[ "google_apis", "bazel_remote_apis" ]'
140 export JUST_BUILD_CONF=`echo $PATH | jq -R '{ ENV: { PATH: . }, "ADD_CXXFLAGS": ["-D__unix__", "-DFMT_HEADER_ONLY"], "ARCH": "'$(uname -m)'" }'`
143 python3 ./bin/bootstrap.py `pwd` ../build "`pwd`/.distfiles"
145 # Build compiled just-mr
146 ../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
148 # convert man pages from Markdown to man
149 find "./share/man" -name "*.md" -exec sh -c '${pandoc}/bin/pandoc --standalone --to man -o "''${0%.md}" "''${0}"' {} \;
159 install -m 755 -Dt "$out/bin" "../build/out/bin/just"
160 install -m 755 -Dt "$out/bin" "../build/out/bin/just-mr"
161 install -m 755 -DT "bin/just-import-git.py" "$out/bin/just-import-git"
162 install -m 755 -DT "bin/just-deduplicate-repos.py" "$out/bin/just-deduplicate-repos"
164 mkdir -p "$out/share/bash-completion/completions"
165 install -m 0644 ./share/just_complete.bash "$out/share/bash-completion/completions/just"
167 mkdir -p "$out/share/man/"{man1,man5}
168 install -m 0644 -t "$out/share/man/man1" ./share/man/*.1
169 install -m 0644 -t "$out/share/man/man5" ./share/man/*.5
175 updateScript = nix-update-script { };
176 tests.version = testers.testVersion {
178 command = "just version";
179 version = builtins.replaceStrings [ "." ] [ "," ] version;
184 broken = stdenv.hostPlatform.isDarwin;
185 description = "Generic build tool";
186 homepage = "https://github.com/just-buildsystem/justbuild";
187 changelog = "https://github.com/just-buildsystem/justbuild/releases/tag/v${version}";
188 mainProgram = "just";
189 license = lib.licenses.asl20;
190 maintainers = with lib.maintainers; [ clkamp ];