{ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; rust-overlay.url = "github:oxalica/rust-overlay"; rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; jmdict-src.url = "http://ftp.edrdg.org/pub/Nihongo/JMdict.gz"; jmdict-src.flake = false; }; outputs = { self, nixpkgs, rust-overlay, jmdict-src }: let inherit (nixpkgs) lib; systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; forAllSystems = f: lib.genAttrs systems (system: let pkgs = import nixpkgs { inherit system; overlays = [ (import rust-overlay) ]; }; rust-bin = rust-overlay.lib.mkRustBin { } pkgs.buildPackages; toolchain = rust-bin.stable.latest.default.override { extensions = [ "rust-src" "rust-analyzer" "rust-std" ]; }; in f system pkgs toolchain); in { devShells = forAllSystems (system: pkgs: toolchain: { default = pkgs.mkShell { nativeBuildInputs = [ toolchain pkgs.cargo-flamegraph ]; RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library"; }; }); packages = forAllSystems (system: pkgs: toolchain: { jmdict = pkgs.runCommand "jmdict" { nativeBuildInputs = with pkgs; [ gzip xmlformat ]; } '' mkdir -p "$out" gzip -dkc ${jmdict-src} > "$out/JMdict.xml" xmlformat -i "$out/JMdict.xml" ''; }); }; }