buildWasmBindgenCli,wasm-bindgen-cli-*: init

Exposing an overridable cargoHash parameter is problematic because it
will produce silently broken FODs if we change the hashing scheme,
which we are currently doing across the tree because Cargo 1.84.0 has
changed the output of fetchCargoTarball, meaning all hashes have been
invalidated.  To avoid this happening in future, we are changing to
the fetchCargoVendor mechanism, which does not depend on
implementation details of Cargo.

The future-proof way to override a package with Cargo dependencies is
to pass a cargoDeps object.  This is more verbose, and requires the
caller to have access to the src object for the package.  To
compensate for this, I've introduced a buildWasmBindgenCli function
that is nicer to use than wasm-bindgen-cli.overrideAttrs, and I've
also introduced versioned attributes for wasm-bindgen-cli versions
currently in use in Nixpkgs, so that each package that wants to use a
particular version doesn't have to duplicate the src and cargoDeps
definitions for that version.

The unversioned "wasm-bindgen-cli" attribute is demoted to an alias,
with a view to its eventual removal.
This commit is contained in:
Alyssa Ross
2025-01-30 10:26:44 +01:00
parent b55dd979b8
commit bca1dde2b4
14 changed files with 125 additions and 55 deletions
+2 -8
View File
@@ -12,7 +12,7 @@
npmHooks,
python3,
rustc,
wasm-bindgen-cli,
wasm-bindgen-cli_0_2_92,
wasm-pack,
}:
@@ -20,12 +20,6 @@
let
wasm-bindgen-92 = wasm-bindgen-cli.override {
version = "0.2.92";
hash = "sha256-1VwY8vQy7soKEgbki4LD+v259751kKxSxmo/gqE6yV0=";
cargoHash = "sha256-aACJ+lYNEU8FFBs158G1/JG8sc6Rq080PeKCMnwdpH0=";
};
# the lindera-unidic v0.32.2 crate uses [1] an outdated unidic-mecab fork [2] and builds it in pure rust
# [1] https://github.com/lindera/lindera/blob/v0.32.2/lindera-unidic/build.rs#L5-L11
# [2] https://github.com/lindera/unidic-mecab
@@ -121,7 +115,7 @@ rustPlatform.buildRustPackage rec {
nodejs
rustc
rustc.llvmPackages.lld
wasm-bindgen-92
wasm-bindgen-cli_0_2_92
wasm-pack
httplz
]
@@ -9,16 +9,18 @@
stdenv,
curl,
darwin,
version ? "0.2.100",
hash ? "sha256-3RJzK7mkYFrs7C/WkhW9Rr4LdP5ofb2FdYGz1P7Uxog=",
cargoHash ? "sha256-tD0OY2PounRqsRiFh8Js5nyknQ809ZcHMvCOLrvYHRE=",
}:
{
version ? src.version,
src,
cargoDeps,
}:
rustPlatform.buildRustPackage rec {
pname = "wasm-bindgen-cli";
inherit version hash cargoHash;
src = fetchCrate { inherit pname version hash; };
inherit version src cargoDeps;
nativeBuildInputs = [ pkg-config ];
+2 -8
View File
@@ -5,19 +5,13 @@
, nixosTests
, rustPlatform
, rustc
, wasm-bindgen-cli
, wasm-bindgen-cli_0_2_95
, wasm-pack
, which
}:
let
wasm-bindgen-95 = wasm-bindgen-cli.override {
version = "0.2.95";
hash = "sha256-prMIreQeAcbJ8/g3+pMp1Wp9H5u+xLqxRxL+34hICss=";
cargoHash = "sha256-6iMebkD7FQvixlmghGGIvpdGwFNLfnUcFke/Rg8nPK4=";
};
commonDerivationAttrs = rec {
pname = "lldap";
version = "0.6.1";
@@ -44,7 +38,7 @@ let
pname = commonDerivationAttrs.pname + "-frontend";
nativeBuildInputs = [
wasm-pack wasm-bindgen-95 binaryen which rustc rustc.llvmPackages.lld
wasm-pack wasm-bindgen-cli_0_2_95 binaryen which rustc rustc.llvmPackages.lld
];
buildPhase = ''
+3 -6
View File
@@ -9,7 +9,7 @@
nodejs,
npmHooks,
llvmPackages,
wasm-bindgen-cli,
wasm-bindgen-cli_0_2_93,
binaryen,
zip,
}:
@@ -46,11 +46,8 @@ rustPlatform.buildRustPackage rec {
tailwindcss
trunk
# needs to match with wasm-bindgen version in upstreams Cargo.lock
(wasm-bindgen-cli.override {
version = "0.2.93";
hash = "sha256-DDdu5mM3gneraM85pAepBXWn3TMofarVR4NbjMdz3r0=";
cargoHash = "sha256-birrg+XABBHHKJxfTKAMSlmTVYLmnmqMDfRnmG6g/YQ=";
})
wasm-bindgen-cli_0_2_93
zip
];
+2 -8
View File
@@ -4,18 +4,12 @@
rustPlatform,
rustc,
wasm-pack,
wasm-bindgen-cli,
wasm-bindgen-cli_0_2_95,
binaryen,
}:
let
version = "0.1.1";
wasm-bindgen-cli-95 = wasm-bindgen-cli.override {
version = "0.2.95";
hash = "sha256-prMIreQeAcbJ8/g3+pMp1Wp9H5u+xLqxRxL+34hICss=";
cargoHash = "sha256-6iMebkD7FQvixlmghGGIvpdGwFNLfnUcFke/Rg8nPK4=";
};
in
rustPlatform.buildRustPackage {
pname = "tpsecore";
@@ -32,7 +26,7 @@ rustPlatform.buildRustPackage {
nativeBuildInputs = [
wasm-pack
wasm-bindgen-cli-95
wasm-bindgen-cli_0_2_95
binaryen
rustc.llvmPackages.lld
];
@@ -0,0 +1,19 @@
{
buildWasmBindgenCli,
fetchCrate,
rustPlatform,
}:
buildWasmBindgenCli rec {
src = fetchCrate {
pname = "wasm-bindgen-cli";
version = "0.2.100";
hash = "sha256-3RJzK7mkYFrs7C/WkhW9Rr4LdP5ofb2FdYGz1P7Uxog=";
};
cargoDeps = rustPlatform.fetchCargoTarball {
inherit src;
inherit (src) pname version;
hash = "sha256-tD0OY2PounRqsRiFh8Js5nyknQ809ZcHMvCOLrvYHRE=";
};
}
@@ -0,0 +1,19 @@
{
buildWasmBindgenCli,
fetchCrate,
rustPlatform,
}:
buildWasmBindgenCli rec {
src = fetchCrate {
pname = "wasm-bindgen-cli";
version = "0.2.92";
hash = "sha256-1VwY8vQy7soKEgbki4LD+v259751kKxSxmo/gqE6yV0=";
};
cargoDeps = rustPlatform.fetchCargoTarball {
inherit src;
inherit (src) pname version;
hash = "sha256-aACJ+lYNEU8FFBs158G1/JG8sc6Rq080PeKCMnwdpH0=";
};
}
@@ -0,0 +1,19 @@
{
buildWasmBindgenCli,
fetchCrate,
rustPlatform,
}:
buildWasmBindgenCli rec {
src = fetchCrate {
pname = "wasm-bindgen-cli";
version = "0.2.93";
hash = "sha256-DDdu5mM3gneraM85pAepBXWn3TMofarVR4NbjMdz3r0=";
};
cargoDeps = rustPlatform.fetchCargoTarball {
inherit src;
inherit (src) pname version;
hash = "sha256-birrg+XABBHHKJxfTKAMSlmTVYLmnmqMDfRnmG6g/YQ=";
};
}
@@ -0,0 +1,19 @@
{
buildWasmBindgenCli,
fetchCrate,
rustPlatform,
}:
buildWasmBindgenCli rec {
src = fetchCrate {
pname = "wasm-bindgen-cli";
version = "0.2.95";
hash = "sha256-prMIreQeAcbJ8/g3+pMp1Wp9H5u+xLqxRxL+34hICss=";
};
cargoDeps = rustPlatform.fetchCargoTarball {
inherit src;
inherit (src) pname version;
hash = "sha256-6iMebkD7FQvixlmghGGIvpdGwFNLfnUcFke/Rg8nPK4=";
};
}
+1 -8
View File
@@ -1,4 +1,4 @@
{ wasm-bindgen-cli, ... }@args:
args:
import ../generic.nix (
args
// {
@@ -14,12 +14,5 @@ import ../generic.nix (
"sspi-0.10.1" = "sha256-fkclC/plTh2d8zcmqthYmr5yXqbPTeFxI1VuaPX5vxk=";
};
};
# wasm-bindgen-cli version must match the version of wasm-bindgen in Cargo.lock
wasm-bindgen-cli = wasm-bindgen-cli.override {
version = "0.2.92";
hash = "sha256-1VwY8vQy7soKEgbki4LD+v259751kKxSxmo/gqE6yV0=";
cargoHash = "sha256-aACJ+lYNEU8FFBs158G1/JG8sc6Rq080PeKCMnwdpH0=";
};
}
)
+1 -8
View File
@@ -1,4 +1,4 @@
{ wasm-bindgen-cli, ... }@args:
args:
import ../generic.nix (
args
// {
@@ -13,12 +13,5 @@ import ../generic.nix (
"ironrdp-async-0.1.0" = "sha256-DOwDHavDaEda+JK9M6kbvseoXe2LxJg3MLTY/Nu+PN0=";
};
};
# wasm-bindgen-cli version must match the version of wasm-bindgen in Cargo.lock
wasm-bindgen-cli = wasm-bindgen-cli.override {
version = "0.2.93";
hash = "sha256-DDdu5mM3gneraM85pAepBXWn3TMofarVR4NbjMdz3r0=";
cargoHash = "sha256-birrg+XABBHHKJxfTKAMSlmTVYLmnmqMDfRnmG6g/YQ=";
};
}
)
+27 -4
View File
@@ -1,11 +1,34 @@
{ callPackages, lib, ... }@args:
{
callPackages,
lib,
wasm-bindgen-cli_0_2_92,
wasm-bindgen-cli_0_2_93,
...
}@args:
let
f = args: rec {
teleport_15 = import ./15 args;
teleport_16 = import ./16 args;
# wasm-bindgen-cli version must match the version of wasm-bindgen in Cargo.lock
teleport_15 = import ./15 (
args
// {
wasm-bindgen-cli = wasm-bindgen-cli_0_2_92;
}
);
teleport_16 = import ./16 (
args
// {
wasm-bindgen-cli = wasm-bindgen-cli_0_2_93;
}
);
teleport = teleport_16;
};
# Ensure the following callPackages invocation includes everything 'generic' needs.
f' = lib.setFunctionArgs f (builtins.functionArgs (import ./generic.nix));
in
callPackages f' (builtins.removeAttrs args [ "callPackages" ])
callPackages f' (
builtins.removeAttrs args [
"callPackages"
"wasm-bindgen-cli_0_2_92"
"wasm-bindgen-cli_0_2_93"
]
)
+1
View File
@@ -1483,6 +1483,7 @@ mapAliases {
wakatime = wakatime-cli; # 2024-05-30
wal_e = throw "wal_e was removed as it is unmaintained upstream and depends on the removed boto package; upstream recommends using wal-g or pgbackrest"; # Added 2024-09-22
wapp = tclPackages.wapp; # Added 2024-10-02
wasm-bindgen-cli = wasm-bindgen-cli_0_2_100;
wayfireApplications-unwrapped = throw ''
'wayfireApplications-unwrapped.wayfire' has been renamed to/replaced by 'wayfire'
'wayfireApplications-unwrapped.wayfirePlugins' has been renamed to/replaced by 'wayfirePlugins'
+3
View File
@@ -5339,6 +5339,9 @@ with pkgs;
webassemblyjs-cli = nodePackages."@webassemblyjs/cli-1.11.1";
webassemblyjs-repl = nodePackages."@webassemblyjs/repl-1.11.1";
buildWasmBindgenCli = callPackage ../build-support/wasm-bindgen-cli { };
wasm-strip = nodePackages."@webassemblyjs/wasm-strip";
wasm-text-gen = nodePackages."@webassemblyjs/wasm-text-gen-1.11.1";
wast-refmt = nodePackages."@webassemblyjs/wast-refmt-1.11.1";