2021-06-23 21:23:46 +02:00
|
|
|
{
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
|
|
|
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
|
|
|
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
2022-07-16 19:19:15 +02:00
|
|
|
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
rust-overlay.inputs.flake-utils.follows = "flake-utils";
|
2021-06-23 21:23:46 +02:00
|
|
|
|
|
|
|
naersk.url = "github:nmattia/naersk";
|
|
|
|
naersk.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = { self, nixpkgs, rust-overlay, flake-utils, naersk }: flake-utils.lib.eachDefaultSystem (system:
|
|
|
|
let
|
|
|
|
overlays = [
|
2022-07-16 17:51:36 +02:00
|
|
|
rust-overlay.overlays.default
|
2021-06-23 21:23:46 +02:00
|
|
|
];
|
|
|
|
pkgs = import nixpkgs { inherit system overlays; };
|
2023-12-28 20:24:35 +01:00
|
|
|
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
|
|
|
naerskLib = pkgs.callPackage naersk {
|
|
|
|
rustc = rustToolchain;
|
|
|
|
cargo = rustToolchain;
|
|
|
|
};
|
2021-06-23 21:23:46 +02:00
|
|
|
in
|
|
|
|
rec {
|
|
|
|
packages = {
|
2023-12-28 22:58:45 +01:00
|
|
|
password-hash-self-service = naerskLib.buildPackage {
|
|
|
|
src = self;
|
2021-06-23 21:23:46 +02:00
|
|
|
|
|
|
|
nativeBuildInputs = with pkgs; [
|
2023-12-28 20:24:35 +01:00
|
|
|
binaryen # wasm-opt
|
2023-12-28 22:58:45 +01:00
|
|
|
trunk
|
2021-06-23 21:23:46 +02:00
|
|
|
wasm-bindgen-cli
|
|
|
|
];
|
|
|
|
|
2022-07-16 19:19:30 +02:00
|
|
|
# required, otherwise the dependencies are built for the host system
|
|
|
|
CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
|
|
|
|
|
2021-06-23 21:23:46 +02:00
|
|
|
overrideMain = (o: o // {
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2023-12-28 22:58:45 +01:00
|
|
|
trunk build --release --offline --frozen
|
2021-06-23 21:23:46 +02:00
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2023-12-28 22:58:45 +01:00
|
|
|
cp -r dist $out
|
2021-06-23 21:23:46 +02:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2023-12-28 22:58:45 +01:00
|
|
|
default = packages.password-hash-self-service;
|
2022-07-16 19:30:02 +02:00
|
|
|
};
|
2021-06-23 21:23:46 +02:00
|
|
|
|
|
|
|
devShell = pkgs.mkShell {
|
|
|
|
buildInputs = with pkgs; [
|
2023-12-28 20:24:35 +01:00
|
|
|
binaryen # wasm-opt
|
|
|
|
rustToolchain
|
2023-12-28 22:58:45 +01:00
|
|
|
trunk
|
2022-07-16 17:55:26 +02:00
|
|
|
wasm-bindgen-cli
|
2021-06-23 21:23:46 +02:00
|
|
|
];
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|