Skip to content

Commit 26e8587

Browse files
authored
chore: update rusty_v8 hashes in nix flake (denoland#32471)
1 parent 699f6c9 commit 26e8587

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

flake.nix

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
outputs = { self, nixpkgs, flake-utils, rust-overlay, ... }:
1515
flake-utils.lib.eachDefaultSystem (system:
1616
let
17+
inherit (nixpkgs.lib) mapAttrsToList concatStringsSep;
18+
1719
pkgs = import nixpkgs {
1820
inherit system;
1921
overlays = [ rust-overlay.overlays.default ];
@@ -26,19 +28,20 @@
2628

2729
cargoLock = builtins.fromTOML (builtins.readFile ./Cargo.lock);
2830
rustyV8Version = (builtins.head (builtins.filter (p: p.name == "v8") cargoLock.package)).version;
29-
rustyV8Target = {
31+
rustyV8Targets = {
3032
"x86_64-linux" = "x86_64-unknown-linux-gnu";
3133
"aarch64-linux" = "aarch64-unknown-linux-gnu";
3234
"x86_64-darwin" = "x86_64-apple-darwin";
3335
"aarch64-darwin" = "aarch64-apple-darwin";
34-
}.${system};
36+
};
37+
rustyV8Target = rustyV8Targets.${system};
3538
rustyV8 = pkgs.fetchurl {
3639
url = "https://github.com/denoland/rusty_v8/releases/download/v${rustyV8Version}/librusty_v8_release_${rustyV8Target}.a.gz";
3740
sha256 = {
38-
"x86_64-linux" = "sha256-chV1PAx40UH3Ute5k3lLrgfhih39Rm3KqE+mTna6ysE=";
39-
"aarch64-linux" = "sha256-4IivYskhUSsMLZY97+g23UtUYh4p5jk7CzhMbMyqXyY=";
40-
"x86_64-darwin" = "sha256-1jUuC+z7saQfPYILNyRJanD4+zOOhXU2ac/LFoytwho=";
41-
"aarch64-darwin" = "sha256-yHa1eydVCrfYGgrZANbzgmmf25p7ui1VMas2A7BhG6k=";
41+
"x86_64-linux" = "sha256-PYCBh8+RY1nvPOKXMCns5mDRo2j0SB3Edw/ut7npjxo=";
42+
"aarch64-linux" = "sha256-EGlTttOowHhoFBy8FQeokCnbPLi4tfkIhSek28TfcGQ=";
43+
"x86_64-darwin" = "sha256-61d4tQ/PcNPUvDuQsMNTNUO43zLZSVEHOjdGFG0u4W8=";
44+
"aarch64-darwin" = "sha256-BMKybPdxP9+7QD/yfbnPnFxD8N7kHPUkMcEEf4P4iSE=";
4245
}.${system};
4346
};
4447

@@ -93,6 +96,23 @@
9396
default = self.packages.${system}.deno;
9497
};
9598

99+
apps.nix-update-rusty-v8 = {
100+
type = "app";
101+
program = toString (pkgs.writeShellScript "update-rusty-v8" ''
102+
set -euo pipefail
103+
104+
function update() {
105+
sys=$1
106+
target=$2
107+
url="https://github.com/denoland/rusty_v8/releases/download/v${rustyV8Version}/librusty_v8_release_$target.a.gz"
108+
hash=$(nix store prefetch-file --json "$url" | ${pkgs.lib.getExe pkgs.jq} -r '.hash')
109+
sed -i "s|\"$sys\" = \"sha256-[^\"]*\";|\"$sys\" = \"$hash\";|" flake.nix
110+
}
111+
112+
${concatStringsSep "\n" (mapAttrsToList (sys: target: "update ${sys} ${target}") rustyV8Targets)}
113+
'');
114+
};
115+
96116
devShells.default = pkgs.mkShell {
97117
buildInputs = with pkgs; [
98118
rustToolchain

0 commit comments

Comments
 (0)