crane/examples/quick-start-simple/flake.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
1.8 KiB
Nix
Raw Normal View History

2022-01-17 01:25:41 +03:00
{
description = "Build a cargo project without extra checks";
2022-01-17 01:25:41 +03:00
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
2022-01-17 01:25:41 +03:00
flake-utils.url = "github:numtide/flake-utils";
2022-01-17 01:25:41 +03:00
};
outputs = { self, nixpkgs, crane, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
2022-01-17 01:25:41 +03:00
craneLib = crane.mkLib pkgs;
# Common arguments can be set here to avoid repeating them later
# Note: changes here will rebuild all dependency crates
commonArgs = {
src = craneLib.cleanCargoSource ./.;
strictDeps = true;
buildInputs = [
# Add additional build inputs here
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
# Additional darwin specific inputs can be set here
pkgs.libiconv
];
};
my-crate = craneLib.buildPackage (commonArgs // {
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
# Additional environment variables or build phases/hooks can be set
# here *without* rebuilding all dependency crates
# MY_CUSTOM_VAR = "some value";
});
2022-01-17 01:25:41 +03:00
in
{
checks = {
inherit my-crate;
};
packages.default = my-crate;
2022-01-17 01:25:41 +03:00
apps.default = flake-utils.lib.mkApp {
2022-01-17 01:25:41 +03:00
drv = my-crate;
};
2023-09-03 20:33:10 +03:00
devShells.default = craneLib.devShell {
# Inherit inputs from checks.
checks = self.checks.${system};
2022-01-17 01:25:41 +03:00
# Additional dev-shell environment variables can be set directly
# MY_CUSTOM_DEVELOPMENT_VAR = "something else";
2023-09-03 20:33:10 +03:00
# Extra inputs can be added here; cargo and rustc are provided by default.
packages = [
# pkgs.ripgrep
2022-01-17 01:25:41 +03:00
];
};
});
}