Co-authored-by: Smaug123 <3138005+Smaug123@users.noreply.github.com> Reviewed-on: #9
114 lines
3.0 KiB
Nix
114 lines
3.0 KiB
Nix
{
|
|
description = "Implementation of The Little Learner";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
rust-overlay = {
|
|
url = "github:oxalica/rust-overlay";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
crane = {
|
|
url = "github:ipetkov/crane";
|
|
};
|
|
};
|
|
|
|
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane }:
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
let
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
overlays = [ (import rust-overlay) ];
|
|
};
|
|
|
|
rustToolchain = pkgs.rust-bin.nightly.latest.default;
|
|
|
|
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
|
|
|
|
# Common build inputs for all derivations
|
|
commonArgs = {
|
|
src = pkgs.lib.cleanSourceWith {
|
|
src = ./.;
|
|
name = "source";
|
|
filter = path: type: (builtins.match ".*csv$" path != null || craneLib.filterCargoSources path type);
|
|
};
|
|
strictDeps = true;
|
|
|
|
buildInputs = with pkgs; [
|
|
openssl
|
|
];
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
pkg-config
|
|
];
|
|
};
|
|
|
|
# Build just the cargo dependencies
|
|
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
|
|
|
# Build the actual package
|
|
little_learner_app = craneLib.buildPackage (commonArgs // {
|
|
inherit cargoArtifacts;
|
|
});
|
|
in
|
|
{
|
|
packages = {
|
|
default = little_learner_app;
|
|
little_learner_app = little_learner_app;
|
|
};
|
|
|
|
apps.default = flake-utils.lib.mkApp {
|
|
drv = little_learner_app;
|
|
exePath = "/bin/little_learner_app";
|
|
};
|
|
|
|
devShells = {
|
|
default = craneLib.devShell {
|
|
# Inherit the build inputs from commonArgs
|
|
buildInputs = commonArgs.buildInputs;
|
|
nativeBuildInputs = commonArgs.nativeBuildInputs;
|
|
|
|
# Additional dev tools
|
|
packages = [
|
|
rustToolchain
|
|
pkgs.rust-analyzer
|
|
];
|
|
|
|
RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
|
|
};
|
|
|
|
ci = pkgs.mkShell {
|
|
buildInputs = commonArgs.buildInputs ++ [
|
|
pkgs.nodePackages.markdown-link-check
|
|
pkgs.nixpkgs-fmt
|
|
rustToolchain
|
|
];
|
|
|
|
nativeBuildInputs = commonArgs.nativeBuildInputs;
|
|
|
|
RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
|
|
};
|
|
};
|
|
|
|
checks = {
|
|
inherit little_learner_app;
|
|
|
|
# Run cargo fmt check
|
|
fmt = craneLib.cargoFmt {
|
|
inherit (commonArgs) src;
|
|
};
|
|
|
|
# Run clippy
|
|
clippy = craneLib.cargoClippy (commonArgs // {
|
|
inherit cargoArtifacts;
|
|
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
|
|
});
|
|
|
|
# Run tests
|
|
tests = craneLib.cargoTest (commonArgs // {
|
|
inherit cargoArtifacts;
|
|
});
|
|
};
|
|
});
|
|
}
|