Skip to content

Commit 4cdc981

Browse files
sigmaclaude
andcommitted
feat: add bun and bun-baseline packages
Add bun (v1.3.6, v1.3.8, v1.3.11) for all platforms and bun-baseline (same versions) for x86_64-linux and x86_64-darwin. Update flake to gracefully handle packages with platform-restricted version sets. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7835c23 commit 4cdc981

5 files changed

Lines changed: 191 additions & 3 deletions

File tree

flake.nix

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,18 @@
8585
in
8686
builtins.mapAttrs (
8787
name: entry:
88+
let
89+
hasVersions = entry.versions != {};
90+
in
8891
builtins.listToAttrs (
8992
map (ver: {
9093
name = versionToAttr ver;
9194
value = entry.versions.${ver};
9295
}) (builtins.attrNames entry.versions)
9396
)
94-
// {
97+
// (if hasVersions then {
9598
default = entry.versions.${entry.default};
96-
}
99+
} else {})
97100
) reg
98101
);
99102

@@ -102,11 +105,13 @@
102105
system:
103106
let
104107
reg = self.registry.${system};
108+
lib = nixpkgs.lib;
105109
in
106110
builtins.foldl' (
107111
acc: name:
108112
let
109113
entry = reg.${name};
114+
hasVersions = entry.versions != {};
110115
in
111116
acc
112117
// builtins.listToAttrs (
@@ -115,7 +120,7 @@
115120
value = entry.versions.${ver};
116121
}) (builtins.attrNames entry.versions)
117122
)
118-
// {
123+
// lib.optionalAttrs hasVersions {
119124
# Bare package name points to the default version
120125
${name} = entry.versions.${entry.default};
121126
# Deprecated: use bare package name instead (e.g., .#go not .#go-default)

packages/bun-baseline/data.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"_meta": { "default": "1.3.11", "releases": "https://github.com/oven-sh/bun/releases" },
3+
"1.3.6": {
4+
"x86_64-linux": { "sha256": "sha256-GVSr7giQDeYQqLRpL1//psaxXYr959HeTT+Iz8YOfV8=" },
5+
"x86_64-darwin": { "sha256": "sha256-stiZTUz3BkE2bWm4dCC4BdHZhPTqfhajUt8VaUlHT6U=" }
6+
},
7+
"1.3.8": {
8+
"x86_64-linux": { "sha256": "sha256-u+RjKsA9dJUXfVQuzvqPIfmEknMQZSX2uxMXLsjkqyw=" },
9+
"x86_64-darwin": { "sha256": "sha256-mBLl9sf4GO+cSR4Fp3SBqy56ShWAs3hSbhYRwQL+fKM=" }
10+
},
11+
"1.3.11": {
12+
"x86_64-linux": { "sha256": "sha256-q+NG9jQUVHzfazW3pkmkkMcouT0AYiYVaSORioTA5Zs=" },
13+
"x86_64-darwin": { "sha256": "sha256-+2c5sIv1RVDtqnyCTNWy3KRbagav70CEQwh6YxBfb40=" }
14+
}
15+
}

packages/bun-baseline/default.nix

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{ pkgs, lib, toolbox, toolboxLib }:
2+
3+
let
4+
inherit (toolboxLib.readData ./data.json) meta versions;
5+
6+
system = pkgs.stdenv.hostPlatform.system;
7+
8+
supportedPlatforms = {
9+
"x86_64-linux" = "linux-x64-baseline";
10+
"x86_64-darwin" = "darwin-x64-baseline";
11+
};
12+
13+
platformKey = supportedPlatforms.${system} or null;
14+
15+
# Only include versions that have binaries for the current platform
16+
filteredVersions = lib.filterAttrs (_: versionData: versionData ? ${system}) versions;
17+
18+
builders = {
19+
default = version: versionData:
20+
let
21+
platformData = versionData.${system};
22+
in
23+
pkgs.stdenv.mkDerivation {
24+
pname = "bun-baseline";
25+
inherit version;
26+
27+
src = pkgs.fetchurl {
28+
url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-${platformKey}.zip";
29+
hash = platformData.sha256;
30+
};
31+
32+
sourceRoot = "bun-${platformKey}";
33+
34+
nativeBuildInputs = [
35+
pkgs.unzip
36+
] ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [
37+
pkgs.autoPatchelfHook
38+
];
39+
40+
buildInputs = lib.optionals pkgs.stdenv.hostPlatform.isLinux [
41+
pkgs.stdenv.cc.cc.lib
42+
];
43+
44+
dontConfigure = true;
45+
dontBuild = true;
46+
dontStrip = true;
47+
48+
installPhase = ''
49+
runHook preInstall
50+
51+
mkdir -p $out/bin
52+
install -m 755 bun $out/bin/bun
53+
ln -s $out/bin/bun $out/bin/bunx
54+
55+
runHook postInstall
56+
'';
57+
58+
meta = {
59+
description = "Bun JavaScript runtime (baseline build, no AVX2 requirement)";
60+
homepage = "https://bun.sh";
61+
license = lib.licenses.mit;
62+
platforms = builtins.attrNames supportedPlatforms;
63+
};
64+
};
65+
};
66+
in
67+
# On unsupported platforms, expose no versions so the flake skips this package gracefully
68+
if filteredVersions == {} then {
69+
versions = {};
70+
default = meta.default;
71+
} else {
72+
versions = toolboxLib.buildVersions "bun-baseline" builders filteredVersions;
73+
default = meta.default;
74+
}

packages/bun/data.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"_meta": { "default": "1.3.11", "releases": "https://github.com/oven-sh/bun/releases" },
3+
"1.3.6": {
4+
"x86_64-linux": { "sha256": "sha256-m6mNITRVDWaQh1sjpPXEjnS3yyZ+jMG49SYFkhxsEe8=" },
5+
"aarch64-linux": { "sha256": "sha256-Wv0Ss2a6LYKXJFzCnAOUFjNN2HIVLB2wLlyKqMZulrE=" },
6+
"x86_64-darwin": { "sha256": "sha256-g++EwqnSXf72ugsxvj2KCZUu8xHHH+ykSIpijpbCZwY=" },
7+
"aarch64-darwin": { "sha256": "sha256-KvHshDd1mrBbOw6kIf6eIubHBctMsHUcMmmCZC2s6Po=" }
8+
},
9+
"1.3.8": {
10+
"x86_64-linux": { "sha256": "sha256-AyKxfwci2namQpiq1JgiWu3L9t8QCKHe5F4W7LImo/E=" },
11+
"aarch64-linux": { "sha256": "sha256-Tp3raBSn7H9ocl3dl9DXtAZbzamoUPadSXVn6ZWn+jM=" },
12+
"x86_64-darwin": { "sha256": "sha256-Sg7NcDs31mq69R5bwk/RJJ6Nw5LBfuYjVxDPUaCYi4U=" },
13+
"aarch64-darwin": { "sha256": "sha256-ZyoKmnt0TQhaHSIZypB+Pib1V5/Knng6lRCk+Yo2IS8=" }
14+
},
15+
"1.3.11": {
16+
"x86_64-linux": { "sha256": "sha256-hhG6k1r4hvBabzh0ChUWAybBXl1dB63vlmEwtEk2B+0=" },
17+
"aarch64-linux": { "sha256": "sha256-0TlE2hKlPsx0v2pyC9HQTEVVwDjf5CI2U1anvkdpH98=" },
18+
"x86_64-darwin": { "sha256": "sha256-xP4rkkchiwKV8k6JWq7I/uYudEUmeakCa2fqy9YRooY=" },
19+
"aarch64-darwin": { "sha256": "sha256-b1o0Z+2crsR5W/eM1HZQfZ+HDH1XuGyUX8szgSZ3L/w=" }
20+
}
21+
}

packages/bun/default.nix

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{ pkgs, lib, toolbox, toolboxLib }:
2+
3+
let
4+
inherit (toolboxLib.readData ./data.json) meta versions;
5+
6+
platformKey = {
7+
"x86_64-linux" = "linux-x64";
8+
"aarch64-linux" = "linux-aarch64";
9+
"x86_64-darwin" = "darwin-x64";
10+
"aarch64-darwin" = "darwin-aarch64";
11+
}.${pkgs.stdenv.hostPlatform.system}
12+
or (throw "Unsupported system: ${pkgs.stdenv.hostPlatform.system}");
13+
14+
builders = {
15+
default = version: versionData:
16+
let
17+
system = pkgs.stdenv.hostPlatform.system;
18+
platformData = versionData.${system}
19+
or (throw "bun ${version} has no binary for ${system}");
20+
in
21+
pkgs.stdenv.mkDerivation {
22+
pname = "bun";
23+
inherit version;
24+
25+
src = pkgs.fetchurl {
26+
url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-${platformKey}.zip";
27+
hash = platformData.sha256;
28+
};
29+
30+
sourceRoot = "bun-${platformKey}";
31+
32+
nativeBuildInputs = [
33+
pkgs.unzip
34+
] ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [
35+
pkgs.autoPatchelfHook
36+
];
37+
38+
buildInputs = lib.optionals pkgs.stdenv.hostPlatform.isLinux [
39+
pkgs.stdenv.cc.cc.lib
40+
];
41+
42+
dontConfigure = true;
43+
dontBuild = true;
44+
dontStrip = true;
45+
46+
installPhase = ''
47+
runHook preInstall
48+
49+
mkdir -p $out/bin
50+
install -m 755 bun $out/bin/bun
51+
ln -s $out/bin/bun $out/bin/bunx
52+
53+
runHook postInstall
54+
'';
55+
56+
meta = {
57+
description = "Incredibly fast JavaScript runtime, bundler, test runner, and package manager";
58+
homepage = "https://bun.sh";
59+
license = lib.licenses.mit;
60+
platforms = [
61+
"x86_64-linux"
62+
"aarch64-linux"
63+
"x86_64-darwin"
64+
"aarch64-darwin"
65+
];
66+
};
67+
};
68+
};
69+
in
70+
{
71+
versions = toolboxLib.buildVersions "bun" builders versions;
72+
default = meta.default;
73+
}

0 commit comments

Comments
 (0)