tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
buck2: Use nushell for the updateScript
Ross Smyth
4 months ago
a9022a9c
1d76dbd9
+75
-63
4 changed files
expand all
collapse all
unified
split
pkgs
by-name
bu
buck2
hashes.json
package.nix
update.nu
update.sh
+18
-11
pkgs/by-name/bu/buck2/hashes.json
···
1
1
{
2
2
-
"rust-project-aarch64-linux": "sha256-Pm5lEIu0hzI5BuA/LuTKjBP8S63jiz1oSB0g9tSETGU=",
3
3
-
"buck2-aarch64-linux": "sha256-Gn/Q2P0Fs93SbOawhzv8Z9DgbrIUlQ+9E3PyCNsV1pk=",
4
4
-
"buck2-aarch64-darwin": "sha256-XtGs7g64s76AYhpFDbqSuSlblRauxJM0PaAk1MNNgxA=",
5
5
-
"buck2-x86_64-linux": "sha256-gVOho7p25okvAV8OqXppdtwOOEzqH7VWcJBT4l5CT2U=",
6
6
-
"rust-project-x86_64-darwin": "sha256-ePawMIfltPRK3mJJxI1BvGs6b2vIcgWzW2XTJykUsdI=",
2
2
+
"x86_64-linux": {
3
3
+
"buck2": "sha256-gVOho7p25okvAV8OqXppdtwOOEzqH7VWcJBT4l5CT2U=",
4
4
+
"rust-project": "sha256-HKctvCiXyGFzfHfB3Qj6qR2p46i5vaaZgPg2J827ou4="
5
5
+
},
6
6
+
"x86_64-darwin": {
7
7
+
"buck2": "sha256-wHk/tJJbupMsrcmXXNVXurfLY2TOSssMnuTZ7LNjASY=",
8
8
+
"rust-project": "sha256-ePawMIfltPRK3mJJxI1BvGs6b2vIcgWzW2XTJykUsdI="
9
9
+
},
10
10
+
"aarch64-linux": {
11
11
+
"buck2": "sha256-Gn/Q2P0Fs93SbOawhzv8Z9DgbrIUlQ+9E3PyCNsV1pk=",
12
12
+
"rust-project": "sha256-Pm5lEIu0hzI5BuA/LuTKjBP8S63jiz1oSB0g9tSETGU="
13
13
+
},
14
14
+
"aarch64-darwin": {
15
15
+
"buck2": "sha256-XtGs7g64s76AYhpFDbqSuSlblRauxJM0PaAk1MNNgxA=",
16
16
+
"rust-project": "sha256-CkyLLv41iJTKHVB0e355ZO2MV7NzQeiF1gtWEGF5oAY="
17
17
+
},
7
18
"version": "2025-08-15",
8
8
-
"rust-project-x86_64-linux": "sha256-HKctvCiXyGFzfHfB3Qj6qR2p46i5vaaZgPg2J827ou4=",
9
9
-
"buck2-x86_64-darwin": "sha256-wHk/tJJbupMsrcmXXNVXurfLY2TOSssMnuTZ7LNjASY=",
10
10
-
"rust-project-aarch64-darwin": "sha256-CkyLLv41iJTKHVB0e355ZO2MV7NzQeiF1gtWEGF5oAY=",
11
11
-
"prelude_fod": "sha256-cyuOMi8x8q9gd6p1obnYYDVPxyONZ+y41AFXvSbUjC0=",
12
12
-
"_comment": "Generated by buck2 update.sh",
13
13
-
"prelude_git": "892cb85f5fc3258c7e4f89a836821ec4b8c7ee44"
19
19
+
"preludeGit": "892cb85f5fc3258c7e4f89a836821ec4b8c7ee44",
20
20
+
"preludeFod": "sha256-cyuOMi8x8q9gd6p1obnYYDVPxyONZ+y41AFXvSbUjC0="
14
21
}
+8
-7
pkgs/by-name/bu/buck2/package.nix
···
43
43
# procued by GitHub Actions. this also includes the hash for a download of a
44
44
# compatible buck2-prelude
45
45
buildHashes = builtins.fromJSON (builtins.readFile ./hashes.json);
46
46
+
archHashes = buildHashes.${stdenv.hostPlatform.system};
46
47
47
48
# map our platform name to the rust toolchain suffix
48
48
-
# NOTE (aseipp): must be synchronized with update.sh!
49
49
+
# NOTE (aseipp): must be synchronized with update.nu!
49
50
platform-suffix =
50
51
{
51
52
x86_64-darwin = "x86_64-apple-darwin";
···
53
54
x86_64-linux = "x86_64-unknown-linux-gnu";
54
55
aarch64-linux = "aarch64-unknown-linux-gnu";
55
56
}
56
56
-
."${stdenv.hostPlatform.system}";
57
57
+
.${stdenv.hostPlatform.system};
57
58
in
58
59
stdenv.mkDerivation (finalAttrs: {
59
60
pname = "buck2";
···
64
65
# zstd-compressed
65
66
(fetchurl {
66
67
url = "https://github.com/facebook/buck2/releases/download/${lib.removePrefix "unstable-" finalAttrs.version}/buck2-${platform-suffix}.zst";
67
67
-
hash = buildHashes."buck2-${stdenv.hostPlatform.system}";
68
68
+
hash = archHashes.buck2;
68
69
})
69
70
# rust-project, which is used to provide IDE integration Buck2 Rust projects,
70
71
# is part of the official distribution
71
72
(fetchurl {
72
73
url = "https://github.com/facebook/buck2/releases/download/${lib.removePrefix "unstable-" finalAttrs.version}/rust-project-${platform-suffix}.zst";
73
73
-
hash = buildHashes."rust-project-${stdenv.hostPlatform.system}";
74
74
+
hash = archHashes.rust-project;
74
75
})
75
76
];
76
77
···
124
125
# for downstream consumers to use when they need to automate any kind of
125
126
# tooling
126
127
prelude = fetchurl {
127
127
-
url = "https://github.com/facebook/buck2-prelude/archive/${buildHashes.prelude-git}.tar.gz";
128
128
-
hash = buildHashes.prelude-fod;
128
128
+
url = "https://github.com/facebook/buck2-prelude/archive/${buildHashes.preludeGit}.tar.gz";
129
129
+
hash = buildHashes.preludeFod;
129
130
};
130
131
131
131
-
updateScript = ./update.sh;
132
132
+
updateScript = ./update.nu;
132
133
};
133
134
134
135
meta = {
+49
pkgs/by-name/bu/buck2/update.nu
···
1
1
+
#!/usr/bin/env nix-shell
2
2
+
#! nix-shell -I ./.
3
3
+
#! nix-shell -i nu
4
4
+
#! nix-shell -p nushell nix
5
5
+
6
6
+
const ARCHES = [
7
7
+
{ name: "x86_64-linux", target: "x86_64-unknown-linux-gnu" },
8
8
+
{ name: "x86_64-darwin", target: "x86_64-apple-darwin" },
9
9
+
{ name: "aarch64-linux", target: "aarch64-unknown-linux-gnu" },
10
10
+
{ name: "aarch64-darwin", target: "aarch64-apple-darwin" },
11
11
+
];
12
12
+
13
13
+
const MANIFEST = "pkgs/by-name/bu/buck2/hashes.json"
14
14
+
15
15
+
def main [] {
16
16
+
let version = http get "https://api.github.com/repos/facebook/buck2/releases"
17
17
+
| sort-by -r created_at
18
18
+
| where prerelease == true and name != "latest"
19
19
+
| first
20
20
+
| get name
21
21
+
22
22
+
let preludeHash = http get $"https://github.com/facebook/buck2/releases/download/($version)/prelude_hash" | decode | str trim
23
23
+
let preludeFod = run-external "nix" "--extra-experimental-features" "nix-command" "store" "prefetch-file" "--json" $"https://github.com/facebook/buck2-prelude/archive/($preludeHash).tar.gz" | from json | get hash
24
24
+
25
25
+
print $"Newest version: ($version)"
26
26
+
print $"Newest prelude hash: ($preludeHash)"
27
27
+
28
28
+
let hashes = $ARCHES | par-each {
29
29
+
|arch|
30
30
+
31
31
+
{
32
32
+
$arch.name: {
33
33
+
"buck2": (run-external "nix" "--extra-experimental-features" "nix-command" "store" "prefetch-file" "--json" $"https://github.com/facebook/buck2/releases/download/($version)/buck2-($arch.target).zst" | from json | get hash),
34
34
+
"rust-project": (run-external "nix" "--extra-experimental-features" "nix-command" "store" "prefetch-file" "--json" $"https://github.com/facebook/buck2/releases/download/($version)/rust-project-($arch.target).zst" | from json | get hash),
35
35
+
}
36
36
+
}
37
37
+
} | reduce { |val, accum| $accum | merge $val }
38
38
+
39
39
+
let new_manifest = $hashes
40
40
+
| insert "version" $version
41
41
+
| insert "preludeGit" $preludeHash
42
42
+
| insert "preludeFod" $preludeFod
43
43
+
44
44
+
$new_manifest
45
45
+
| to json
46
46
+
| append "\n"
47
47
+
| str join
48
48
+
| save -f $MANIFEST
49
49
+
}
-45
pkgs/by-name/bu/buck2/update.sh
···
1
1
-
#!/usr/bin/env nix-shell
2
2
-
#! nix-shell -I nixpkgs=./.
3
3
-
#! nix-shell -i bash
4
4
-
#! nix-shell -p curl jq common-updater-scripts nix coreutils
5
5
-
# shellcheck shell=bash
6
6
-
set -euo pipefail
7
7
-
8
8
-
VERSION=$(curl -s https://api.github.com/repos/facebook/buck2/releases \
9
9
-
| jq -r 'sort_by(.created_at) | reverse |
10
10
-
(map
11
11
-
(select ((.prerelease == true) and (.name != "latest"))) |
12
12
-
first
13
13
-
) | .name')
14
14
-
PRELUDE_HASH=$(curl -sLo - "https://github.com/facebook/buck2/releases/download/${VERSION}/prelude_hash")
15
15
-
PRELUDE_DL_URL="https://github.com/facebook/buck2-prelude/archive/${PRELUDE_HASH}.tar.gz"
16
16
-
17
17
-
echo "Latest buck2 prerelease: $VERSION"
18
18
-
echo "Compatible buck2-prelude hash: $PRELUDE_HASH"
19
19
-
20
20
-
ARCHS=(
21
21
-
"x86_64-linux:x86_64-unknown-linux-gnu"
22
22
-
"x86_64-darwin:x86_64-apple-darwin"
23
23
-
"aarch64-linux:aarch64-unknown-linux-gnu"
24
24
-
"aarch64-darwin:aarch64-apple-darwin"
25
25
-
)
26
26
-
27
27
-
NFILE=pkgs/by-name/bu/buck2/package.nix
28
28
-
HFILE=pkgs/by-name/bu/buck2/hashes.json
29
29
-
30
30
-
declare -A outputJson=()
31
31
-
outputJson["version"]="$VERSION"
32
32
-
outputJson["prelude_git"]="$PRELUDE_HASH"
33
33
-
outputJson["prelude_fod"]="$(nix --extra-experimental-features nix-command store prefetch-file --json "$PRELUDE_DL_URL" | jq -r .hash)"
34
34
-
35
35
-
for arch in "${ARCHS[@]}"; do
36
36
-
IFS=: read -r arch_name arch_target <<< "$arch"
37
37
-
outputJson["buck2-$arch_name"]="$(nix --extra-experimental-features nix-command store prefetch-file --json "https://github.com/facebook/buck2/releases/download/${VERSION}/buck2-${arch_target}.zst" | jq -r .hash)"
38
38
-
39
39
-
outputJson["rust-project-$arch_name"]="$(nix --extra-experimental-features nix-command store prefetch-file --json "https://github.com/facebook/buck2/releases/download/${VERSION}/rust-project-${arch_target}.zst" | jq -r .hash)"
40
40
-
done
41
41
-
42
42
-
outputJson["_comment"]="Generated by buck2 update.sh"
43
43
-
jq -n 'def _nwise($n): def nw: if length <= $n then . else .[0:$n] , (.[$n:] | nw) end; nw; [$ARGS.positional | _nwise(2) | {(.[0]): .[1]}] | add' --args "${outputJson[@]@k}" > "$HFILE"
44
44
-
45
45
-
echo "Done; wrote $HFILE and updated version in $NFILE."