crane/flake.nix

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

134 lines
3.4 KiB
Nix
Raw Normal View History

2021-12-26 22:47:16 +03:00
{
description = "A Nix library for building cargo projects. Never build twice thanks to incremental artifact caching.";
2021-12-26 22:47:16 +03:00
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
};
2021-12-26 22:47:16 +03:00
};
nixConfig = {
extra-substituters = [ "https://crane.cachix.org" ];
extra-trusted-public-keys = [ "crane.cachix.org-1:8Scfpmn9w+hGdXH/Q9tTLiYAE/2dnJYRJP7kl80GuRk=" ];
};
2022-10-24 02:20:22 +03:00
outputs = { nixpkgs, flake-utils, rust-overlay, ... }:
2021-12-26 22:47:16 +03:00
let
2022-01-16 07:21:02 +03:00
mkLib = pkgs: import ./lib {
inherit (pkgs) lib newScope;
};
2021-12-26 22:47:16 +03:00
in
{
2022-01-16 07:21:02 +03:00
inherit mkLib;
2022-10-24 02:20:22 +03:00
overlays.default = _final: _prev: { };
2022-01-17 01:25:41 +03:00
templates = rec {
alt-registry = {
description = "Build a cargo project with alternative crate registries";
path = ./examples/alt-registry;
};
cross-musl = {
description = "Building static binaries with musl";
2022-05-12 00:37:47 +03:00
path = ./examples/cross-musl;
};
cross-rust-overlay = {
description = "Cross compiling a rust program using rust-overlay";
path = ./examples/cross-rust-overlay;
};
cross-windows = {
description = "Cross compiling a rust program for windows";
path = ./examples/cross-windows;
};
custom-toolchain = {
description = "Build a cargo project with a custom toolchain";
path = ./examples/custom-toolchain;
};
2023-10-13 04:59:36 +03:00
end-to-end-testing = {
description = "Run End-to-End tests for a webapp";
path = ./examples/end-to-end-testing;
};
default = quick-start;
quick-start = {
description = "Build a cargo project";
path = ./examples/quick-start;
};
quick-start-simple = {
description = "Build a cargo project without extra checks";
path = ./examples/quick-start-simple;
};
trunk = {
description = "Build a trunk project";
path = ./examples/trunk;
};
trunk-workspace = {
description = "Build a workspace with a trunk member";
path = ./examples/trunk-workspace;
};
};
} // flake-utils.lib.eachDefaultSystem (system:
2021-12-27 02:32:57 +03:00
let
2022-12-27 01:27:13 +03:00
pkgs = import nixpkgs {
inherit system;
};
# To override do: lib.overrideScope' (self: super: { ... });
lib = mkLib pkgs;
packages = import ./pkgs {
inherit pkgs;
myLib = lib;
};
2022-12-27 01:27:13 +03:00
checks =
let
pkgsChecks = import nixpkgs {
inherit system;
overlays = [
rust-overlay.overlays.default
];
};
in
pkgsChecks.callPackages ./checks {
pkgs = pkgsChecks;
myLib = mkLib pkgsChecks;
2022-12-27 01:27:13 +03:00
myPkgs = packages;
};
2021-12-27 02:32:57 +03:00
in
{
2022-12-27 01:27:13 +03:00
inherit checks lib packages;
2021-12-27 02:32:57 +03:00
formatter = pkgs.nixpkgs-fmt;
2022-11-21 03:28:49 +03:00
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
2022-05-29 23:26:42 +03:00
jq
2022-12-27 01:27:13 +03:00
mdbook
nixpkgs-fmt
];
2021-12-27 02:32:57 +03:00
};
});
2021-12-26 22:47:16 +03:00
}