120 lines
3 KiB
Nix
120 lines
3 KiB
Nix
{
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
|
crane.url = "github:ipetkov/crane";
|
|
};
|
|
outputs =
|
|
{ self
|
|
, nixpkgs
|
|
, flake-utils
|
|
, rust-overlay
|
|
, crane
|
|
,
|
|
}:
|
|
flake-utils.lib.eachDefaultSystem (
|
|
system:
|
|
let
|
|
overlays = [
|
|
rust-overlay.overlays.default
|
|
];
|
|
pkgs = import nixpkgs {
|
|
inherit system overlays;
|
|
config = {
|
|
allowUnfree = true;
|
|
};
|
|
};
|
|
src = craneLib.cleanCargoSource ./.;
|
|
|
|
commonArgs = {
|
|
inherit src;
|
|
|
|
# Add any build inputs needed
|
|
buildInputs = with pkgs; [
|
|
openssl
|
|
pkg-config
|
|
];
|
|
|
|
# Add any native build inputs
|
|
nativeBuildInputs = with pkgs; [
|
|
rustPlatform.bindgenHook
|
|
pkg-config
|
|
];
|
|
|
|
checkType = "debug";
|
|
env = {
|
|
OPENSSL_NO_VENDOR = "1";
|
|
NIX_OUTPATH_USED_AS_RANDOM_SEED = "aaaaaaaaaa";
|
|
};
|
|
};
|
|
|
|
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
|
individualCrateArgs = commonArgs // {
|
|
inherit cargoArtifacts;
|
|
inherit (craneLib.crateNameFromCargoToml { inherit src; }) version;
|
|
# NB: we disable tests since we'll run them all via cargo-nextest
|
|
doCheck = false;
|
|
};
|
|
|
|
# Import rust setup
|
|
rustSetup = import ./nix/rust-setup.nix { inherit pkgs crane; };
|
|
inherit (rustSetup) rustVersion rustPlatform craneLib;
|
|
|
|
# Import vault-hier package
|
|
vault-hier = import ./nix/packages/vault-hier.nix {
|
|
inherit
|
|
pkgs
|
|
craneLib
|
|
individualCrateArgs
|
|
;
|
|
};
|
|
|
|
# Import devshell
|
|
devshell_with_src = import ./nix/devshell.nix {
|
|
inherit pkgs vault-hier rustVersion;
|
|
};
|
|
in
|
|
{
|
|
checks = {
|
|
inherit vault-hier;
|
|
|
|
my-workspace-clippy = craneLib.cargoClippy (commonArgs // {
|
|
inherit cargoArtifacts;
|
|
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
|
|
});
|
|
|
|
my-workspace-doc = craneLib.cargoDoc (commonArgs // {
|
|
inherit cargoArtifacts;
|
|
});
|
|
|
|
# Check formatting
|
|
my-workspace-fmt = craneLib.cargoFmt {
|
|
inherit src;
|
|
};
|
|
|
|
my-workspace-toml-fmt = craneLib.taploFmt {
|
|
src = pkgs.lib.sources.sourceFilesBySuffices src [ ".toml" ];
|
|
# taplo arguments can be further customized below as needed
|
|
# taploExtraArgs = "--config ./taplo.toml";
|
|
};
|
|
|
|
};
|
|
|
|
# Add packages output
|
|
packages = {
|
|
inherit vault-hier;
|
|
default = vault-hier;
|
|
};
|
|
|
|
devShells = {
|
|
inherit devshell_with_src;
|
|
default = devshell_with_src;
|
|
};
|
|
|
|
# Add formatter for `nix fmt`
|
|
formatter = pkgs.nixfmt-rfc-style;
|
|
}
|
|
);
|
|
}
|