{
inputs = {
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};
outputs = { self, nixpkgs, crane, flake-utils, rust-overlay, ... }:
flake-utils.lib.eachDefaultSystem (localSystem:
let
pkgs = import nixpkgs {
inherit localSystem;
overlays = [ (import rust-overlay) ];
};
rustToolchain = pkgs.pkgsBuildHost.rust-bin.stable.latest.default;
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
commonArgs = {
src = craneLib.cleanCargoSource (craneLib.path ./.);
strictDeps = true;
nativeBuildInputs = with pkgs; [ pkg-config ];
};
cargoArtifacts =
craneLib.buildDepsOnly (commonArgs // { pname = "deps"; });
cargoClippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
pname = "clippy";
});
cargoDoc = craneLib.cargoDoc (commonArgs // {
inherit cargoArtifacts;
pname = "doc";
});
did-host = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
pname = "did-host";
});
in {
checks = { inherit did-host cargoClippy cargoDoc; };
apps = rec {
did-host = flake-utils.lib.mkApp {
drv = pkgs.writeScriptBin "did-host" ''
${self.packages.${localSystem}.did-host}/bin/did-host
'';
};
default = did-host;
};
packages = {
did-host = did-host;
default = did-host;
};
devShells.default = craneLib.devShell {
checks = self.checks.${localSystem};
packages = with pkgs; [
cargo-watch
nodePackages.prettier
rust-analyzer
];
};
});
}