password-hash-self-service/flake.nix
Simon Bruder 5e49335c2c
Update dependencies
This updates both nixpkgs in the flake and also the wasm-pack dependency
in the cargo lockfile. This is to make the project still build on newer
platforms.

Flake lock file updates:

• Updated input 'flake-utils':
    'github:numtide/flake-utils/7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249' (2022-07-04)
  → 'github:numtide/flake-utils/4022d587cbbfd70fe950c1e2083a02621806a725' (2023-12-04)
• Added input 'flake-utils/systems':
    'github:nix-systems/default/da67096a3b9bf56a91d16901293e51ba5b49a27e' (2023-04-09)
• Updated input 'naersk':
    'github:nmattia/naersk/cddffb5aa211f50c4b8750adbec0bbbdfb26bb9f' (2022-06-12)
  → 'github:nmattia/naersk/aeb58d5e8faead8980a807c840232697982d47b9' (2023-10-27)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/4a01ca36d6bfc133bc617e661916a81327c9bbc8' (2022-07-14)
  → 'github:nixos/nixpkgs/5f64a12a728902226210bf01d25ec6cbb9d9265b' (2023-12-24)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/2cd36d4aef875867ee1d7963541ccb3ae50b358c' (2022-07-16)
  → 'github:oxalica/rust-overlay/347789ef125df15b685e8295364ad8ed331fef94' (2023-12-28)
2023-12-28 22:31:44 +01:00

104 lines
2.7 KiB
Nix

{
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";
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 = [
rust-overlay.overlays.default
];
pkgs = import nixpkgs { inherit system overlays; };
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
naerskLib = pkgs.callPackage naersk {
rustc = rustToolchain;
cargo = rustToolchain;
};
in
rec {
packages = {
backend = naerskLib.buildPackage {
src = ./backend;
nativeBuildInputs = with pkgs; [
binaryen # wasm-opt
wasm-bindgen-cli
wasm-pack
];
# required, otherwise the dependencies are built for the host system
CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
WASM_PACK_CACHE = "/build/wasm-pack-cache";
overrideMain = (o: o // {
buildPhase = ''
runHook preBuild
# FIXME this fails when the locked wasm-pack version is different from the one in nixpkgs
wasm-pack build --target web --release --mode no-install -- --offline
runHook postBuild
'';
installPhase = ''
runHook preInstall
cp -r pkg $out
runHook postInstall
'';
});
};
frontend = pkgs.stdenvNoCC.mkDerivation {
name = "password-hash-self-service";
src = self;
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir $out
cp \
index.html \
style.css \
app.js \
$out
mkdir $out/backend
ln -s ${packages.backend} $out/backend/pkg
runHook postInstall
'';
};
default = packages.frontend;
};
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
binaryen # wasm-opt
rustToolchain
wasm-bindgen-cli
wasm-pack
];
};
apps = {
serve = {
type = "app";
program = toString (pkgs.writeShellScript "serve" ''
${pkgs.python3}/bin/python3 -m http.server
'');
};
};
});
}