···22, testers, buck2 # for passthru.tests
33}:
4455-let
66- # NOTE (aseipp): buck2 uses a precompiled binary build for good reason — the
77- # upstream codebase extensively uses unstable `rustc` nightly features, and as
88- # a result can't be built upstream in any sane manner. it is only ever tested
99- # and integrated against a single version of the compiler, which produces all
1010- # usable binaries. you shouldn't try to workaround this or get clever and
1111- # think you can patch it to work; just accept it for now. it is extremely
1212- # unlikely buck2 will build with a stable compiler anytime soon; see related
1313- # upstream issues:
1414- #
1515- # - NixOS/nixpkgs#226677
1616- # - NixOS/nixpkgs#232471
1717- # - facebook/buck2#265
1818- # - facebook/buck2#322
1919- #
2020- # worth noting: it *is* possible to build buck2 from source using
2121- # buildRustPackage, and it works fine, but only if you are using flakes and
2222- # can import `rust-overlay` from somewhere else to vendor your compiler. See
2323- # nixos/nixpkgs#226677 for more information about that.
55+# NOTE (aseipp): buck2 uses a precompiled binary build for good reason — the
66+# upstream codebase extensively uses unstable `rustc` nightly features, and as a
77+# result can't be built upstream in any sane manner. it is only ever tested and
88+# integrated against a single version of the compiler, which produces all usable
99+# binaries. you shouldn't try to workaround this or get clever and think you can
1010+# patch it to work; just accept it for now. it is extremely unlikely buck2 will
1111+# build with a stable compiler anytime soon; see related upstream issues:
1212+#
1313+# - NixOS/nixpkgs#226677
1414+# - NixOS/nixpkgs#232471
1515+# - facebook/buck2#265
1616+# - facebook/buck2#322
1717+#
1818+# worth noting: it *is* possible to build buck2 from source using
1919+# buildRustPackage, and it works fine, but only if you are using flakes and can
2020+# import `rust-overlay` from somewhere else to vendor your compiler. See
2121+# nixos/nixpkgs#226677 for more information about that.
24222525- # map our platform name to the rust toolchain suffix
2626- suffix = {
2727- x86_64-darwin = "x86_64-apple-darwin";
2828- aarch64-darwin = "aarch64-apple-darwin";
2929- x86_64-linux = "x86_64-unknown-linux-musl";
3030- aarch64-linux = "aarch64-unknown-linux-musl";
3131- }."${stdenv.hostPlatform.system}" or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
2323+# NOTE (aseipp): this expression is mostly automated, and you are STRONGLY
2424+# RECOMMENDED to use to nix-update for updating this expression when new
2525+# releases come out, which runs the sibling `update.sh` script.
2626+#
2727+# from the root of the nixpkgs git repository, run:
2828+#
2929+# nix-shell maintainers/scripts/update.nix \
3030+# --argstr commit true \
3131+# --argstr package buck2
32323333- allHashes = builtins.fromJSON (builtins.readFile ./hashes.json);
3333+let
3434+3535+ # build hashes, which correspond to the hashes of the precompiled binaries
3636+ # procued by GitHub Actions. this also includes the hash for a download of a
3737+ # compatible buck2-prelude
3838+ buildHashes = builtins.fromJSON (builtins.readFile ./hashes.json);
34393540 # our version of buck2; this should be a git tag
3636- buck2-version = "2023-08-15";
4141+ version = "2023-08-15";
4242+4343+ # the platform-specific, statically linked binary — which is also
4444+ # zstd-compressed
3745 src =
3846 let
3939- name = "buck2-${buck2-version}-${suffix}.zst";
4040- hash = allHashes."${stdenv.hostPlatform.system}";
4141- url = "https://github.com/facebook/buck2/releases/download/${buck2-version}/buck2-${suffix}.zst";
4747+ suffix = {
4848+ # map our platform name to the rust toolchain suffix
4949+ # NOTE (aseipp): must be synchronized with update.sh!
5050+ x86_64-darwin = "x86_64-apple-darwin";
5151+ aarch64-darwin = "aarch64-apple-darwin";
5252+ x86_64-linux = "x86_64-unknown-linux-musl";
5353+ aarch64-linux = "aarch64-unknown-linux-musl";
5454+ }."${stdenv.hostPlatform.system}" or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
5555+5656+ name = "buck2-${version}-${suffix}.zst";
5757+ hash = buildHashes."${stdenv.hostPlatform.system}";
5858+ url = "https://github.com/facebook/buck2/releases/download/${version}/buck2-${suffix}.zst";
4259 in fetchurl { inherit name url hash; };
43604444- # compatible version of buck2 prelude; a git revision in the buck2-prelude repository
4545- buck2-prelude = "40d6fffd01f224d25a62d982f4a3f00b275a5677";
6161+ # compatible version of buck2 prelude; this is exported via passthru.prelude
6262+ # for downstream consumers to use when they need to automate any kind of
6363+ # tooling
4664 prelude-src =
4765 let
4848- name = "buck2-prelude-${buck2-version}.tar.gz";
4949- hash = allHashes."_prelude";
5050- url = "https://github.com/facebook/buck2-prelude/archive/${buck2-prelude}.tar.gz";
6666+ prelude-hash = "40d6fffd01f224d25a62d982f4a3f00b275a5677";
6767+ name = "buck2-prelude-${version}.tar.gz";
6868+ hash = buildHashes."_prelude";
6969+ url = "https://github.com/facebook/buck2-prelude/archive/${prelude-hash}.tar.gz";
5170 in fetchurl { inherit name url hash; };
52715353-in
5454-stdenv.mkDerivation rec {
7272+in stdenv.mkDerivation {
5573 pname = "buck2";
5656- version = "unstable-${buck2-version}"; # TODO (aseipp): kill 'unstable' once a non-prerelease is made
7474+ version = "unstable-${version}"; # TODO (aseipp): kill 'unstable' once a non-prerelease is made
5775 inherit src;
58765977 nativeBuildInputs = [ zstd ];
···90108 meta = with lib; {
91109 description = "Fast, hermetic, multi-language build system";
92110 homepage = "https://buck2.build";
9393- changelog = "https://github.com/facebook/buck2/releases/tag/${buck2-version}";
111111+ changelog = "https://github.com/facebook/buck2/releases/tag/${version}";
94112 license = with licenses; [ asl20 /* or */ mit ];
9595- mainProgram = pname;
113113+ mainProgram = "buck2";
96114 maintainers = with maintainers; [ thoughtpolice ];
97115 platforms = [
98116 "x86_64-linux" "aarch64-linux"