password-hash-self-service/flake.nix

69 lines
1.8 KiB
Nix
Raw Normal View History

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";
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; };
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 = {
password-hash-self-service = naerskLib.buildPackage {
src = self;
2021-06-23 21:23:46 +02:00
nativeBuildInputs = with pkgs; [
binaryen # wasm-opt
trunk
2021-06-23 21:23:46 +02:00
wasm-bindgen-cli
];
# 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
trunk build --release --offline --frozen
2021-06-23 21:23:46 +02:00
runHook postBuild
'';
installPhase = ''
runHook preInstall
cp -r dist $out
2021-06-23 21:23:46 +02:00
runHook postInstall
'';
});
};
default = packages.password-hash-self-service;
};
2021-06-23 21:23:46 +02:00
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
binaryen # wasm-opt
rustToolchain
trunk
wasm-bindgen-cli
2021-06-23 21:23:46 +02:00
];
};
});
}