tvl-depot/web/pwcrypt/default.nix
Vincent Ambo 8b637521c6 feat(web/pwcrypt): little web application for creating LDAP accounts
This generates the format expected in `//ops/users`.

Note that as of this commit I have not actually tested whether the
generated hashes work, as OpenLDAP doesn't ship with a tool to do that
and I have to actually use it, spin up an LDAP server and bind to it.

The plan is to host this at something like `tvl.fyi/signup`. There is
no plan to automatically submit the generated stuff to the repo,
people still have to email us (and display their street cred).

Note that currently the generated hashes have slightly different
parameters than what //tools/hash-password creates. This might not
matter, but it's probably still a good idea to try and explicitly set
Argon2 parameters.

Change-Id: Ic162afbf7fb0e05ca6efc131b3bb0a4187e28029
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8776
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
2023-06-15 16:58:17 +00:00

51 lines
1.3 KiB
Nix

{ depot, lib, pkgs, ... }:
let
wasmRust = pkgs.rust-bin.stable.latest.default.override {
targets = [ "wasm32-unknown-unknown" ];
};
cargoToml = with builtins; fromTOML (readFile ./Cargo.toml);
wasmBindgenMatch =
cargoToml.dependencies.wasm-bindgen == "= ${pkgs.wasm-bindgen-cli.version}";
assertWasmBindgen = assert (lib.assertMsg wasmBindgenMatch ''
Due to instability in the Rust WASM ecosystem, the trunk build
tool enforces that the Cargo-dependency version of `wasm-bindgen`
MUST match the version of the CLI supplied in the environment.
This can get out of sync when nixpkgs is updated. To resolve it,
wasm-bindgen must be bumped in the Cargo.toml file and cargo needs
to be run to resolve the dependencies.
Versions of `wasm-bindgen` in Cargo.toml:
Expected: '= ${pkgs.wasm-bindgen-cli.version}'
Actual: '${cargoToml.dependencies.wasm-bindgen}'
''); pkgs.wasm-bindgen-cli;
deps = [
pkgs.binaryen
pkgs.sass
pkgs.trunk
wasmRust
assertWasmBindgen
];
in
pkgs.rustPlatform.buildRustPackage rec {
pname = "pwcrypt";
version = "canon";
src = lib.cleanSource ./.;
cargoLock.lockFile = ./Cargo.lock;
buildPhase = ''
export PATH=${lib.makeBinPath deps}:$PATH
mkdir home
export HOME=$PWD/home
trunk build --release -d $out
'';
dontInstall = true;
}