···2, testers, buck2 # for passthru.tests
3}:
45-let
6- # NOTE (aseipp): buck2 uses a precompiled binary build for good reason — the
7- # upstream codebase extensively uses unstable `rustc` nightly features, and as
8- # a result can't be built upstream in any sane manner. it is only ever tested
9- # and integrated against a single version of the compiler, which produces all
10- # usable binaries. you shouldn't try to workaround this or get clever and
11- # think you can patch it to work; just accept it for now. it is extremely
12- # unlikely buck2 will build with a stable compiler anytime soon; see related
13- # upstream issues:
14- #
15- # - NixOS/nixpkgs#226677
16- # - NixOS/nixpkgs#232471
17- # - facebook/buck2#265
18- # - facebook/buck2#322
19- #
20- # worth noting: it *is* possible to build buck2 from source using
21- # buildRustPackage, and it works fine, but only if you are using flakes and
22- # can import `rust-overlay` from somewhere else to vendor your compiler. See
23- # nixos/nixpkgs#226677 for more information about that.
2425- # map our platform name to the rust toolchain suffix
26- suffix = {
27- x86_64-darwin = "x86_64-apple-darwin";
28- aarch64-darwin = "aarch64-apple-darwin";
29- x86_64-linux = "x86_64-unknown-linux-musl";
30- aarch64-linux = "aarch64-unknown-linux-musl";
31- }."${stdenv.hostPlatform.system}" or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
003233- allHashes = builtins.fromJSON (builtins.readFile ./hashes.json);
000003435 # our version of buck2; this should be a git tag
36- buck2-version = "2023-08-15";
00037 src =
38 let
39- name = "buck2-${buck2-version}-${suffix}.zst";
40- hash = allHashes."${stdenv.hostPlatform.system}";
41- url = "https://github.com/facebook/buck2/releases/download/${buck2-version}/buck2-${suffix}.zst";
00000000042 in fetchurl { inherit name url hash; };
4344- # compatible version of buck2 prelude; a git revision in the buck2-prelude repository
45- buck2-prelude = "40d6fffd01f224d25a62d982f4a3f00b275a5677";
046 prelude-src =
47 let
48- name = "buck2-prelude-${buck2-version}.tar.gz";
49- hash = allHashes."_prelude";
50- url = "https://github.com/facebook/buck2-prelude/archive/${buck2-prelude}.tar.gz";
051 in fetchurl { inherit name url hash; };
5253-in
54-stdenv.mkDerivation rec {
55 pname = "buck2";
56- version = "unstable-${buck2-version}"; # TODO (aseipp): kill 'unstable' once a non-prerelease is made
57 inherit src;
5859 nativeBuildInputs = [ zstd ];
···90 meta = with lib; {
91 description = "Fast, hermetic, multi-language build system";
92 homepage = "https://buck2.build";
93- changelog = "https://github.com/facebook/buck2/releases/tag/${buck2-version}";
94 license = with licenses; [ asl20 /* or */ mit ];
95- mainProgram = pname;
96 maintainers = with maintainers; [ thoughtpolice ];
97 platforms = [
98 "x86_64-linux" "aarch64-linux"
···2, testers, buck2 # for passthru.tests
3}:
45+# NOTE (aseipp): buck2 uses a precompiled binary build for good reason — the
6+# upstream codebase extensively uses unstable `rustc` nightly features, and as a
7+# result can't be built upstream in any sane manner. it is only ever tested and
8+# integrated against a single version of the compiler, which produces all usable
9+# binaries. you shouldn't try to workaround this or get clever and think you can
10+# patch it to work; just accept it for now. it is extremely unlikely buck2 will
11+# build with a stable compiler anytime soon; see related upstream issues:
12+#
13+# - NixOS/nixpkgs#226677
14+# - NixOS/nixpkgs#232471
15+# - facebook/buck2#265
16+# - facebook/buck2#322
17+#
18+# worth noting: it *is* possible to build buck2 from source using
19+# buildRustPackage, and it works fine, but only if you are using flakes and can
20+# import `rust-overlay` from somewhere else to vendor your compiler. See
21+# nixos/nixpkgs#226677 for more information about that.
002223+# NOTE (aseipp): this expression is mostly automated, and you are STRONGLY
24+# RECOMMENDED to use to nix-update for updating this expression when new
25+# releases come out, which runs the sibling `update.sh` script.
26+#
27+# from the root of the nixpkgs git repository, run:
28+#
29+# nix-shell maintainers/scripts/update.nix \
30+# --argstr commit true \
31+# --argstr package buck2
3233+let
34+35+ # build hashes, which correspond to the hashes of the precompiled binaries
36+ # procued by GitHub Actions. this also includes the hash for a download of a
37+ # compatible buck2-prelude
38+ buildHashes = builtins.fromJSON (builtins.readFile ./hashes.json);
3940 # our version of buck2; this should be a git tag
41+ version = "2023-08-15";
42+43+ # the platform-specific, statically linked binary — which is also
44+ # zstd-compressed
45 src =
46 let
47+ suffix = {
48+ # map our platform name to the rust toolchain suffix
49+ # NOTE (aseipp): must be synchronized with update.sh!
50+ x86_64-darwin = "x86_64-apple-darwin";
51+ aarch64-darwin = "aarch64-apple-darwin";
52+ x86_64-linux = "x86_64-unknown-linux-musl";
53+ aarch64-linux = "aarch64-unknown-linux-musl";
54+ }."${stdenv.hostPlatform.system}" or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
55+56+ name = "buck2-${version}-${suffix}.zst";
57+ hash = buildHashes."${stdenv.hostPlatform.system}";
58+ url = "https://github.com/facebook/buck2/releases/download/${version}/buck2-${suffix}.zst";
59 in fetchurl { inherit name url hash; };
6061+ # compatible version of buck2 prelude; this is exported via passthru.prelude
62+ # for downstream consumers to use when they need to automate any kind of
63+ # tooling
64 prelude-src =
65 let
66+ prelude-hash = "40d6fffd01f224d25a62d982f4a3f00b275a5677";
67+ name = "buck2-prelude-${version}.tar.gz";
68+ hash = buildHashes."_prelude";
69+ url = "https://github.com/facebook/buck2-prelude/archive/${prelude-hash}.tar.gz";
70 in fetchurl { inherit name url hash; };
7172+in stdenv.mkDerivation {
073 pname = "buck2";
74+ version = "unstable-${version}"; # TODO (aseipp): kill 'unstable' once a non-prerelease is made
75 inherit src;
7677 nativeBuildInputs = [ zstd ];
···108 meta = with lib; {
109 description = "Fast, hermetic, multi-language build system";
110 homepage = "https://buck2.build";
111+ changelog = "https://github.com/facebook/buck2/releases/tag/${version}";
112 license = with licenses; [ asl20 /* or */ mit ];
113+ mainProgram = "buck2";
114 maintainers = with maintainers; [ thoughtpolice ];
115 platforms = [
116 "x86_64-linux" "aarch64-linux"