2021-12-26 22:47:16 +03:00
|
|
|
{
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
2021-12-31 04:18:17 +03:00
|
|
|
|
|
|
|
flake-compat = {
|
|
|
|
url = "github:edolstra/flake-compat";
|
|
|
|
flake = false;
|
|
|
|
};
|
2022-04-28 05:59:59 +03:00
|
|
|
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
2022-10-19 05:13:38 +03:00
|
|
|
|
|
|
|
rust-overlay = {
|
|
|
|
url = "github:oxalica/rust-overlay";
|
|
|
|
inputs = {
|
|
|
|
flake-utils.follows = "flake-utils";
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
};
|
2021-12-26 22:47:16 +03:00
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2022-06-02 03:09:29 +03:00
|
|
|
templates = rec {
|
2022-02-16 05:43:49 +03:00
|
|
|
alt-registry = {
|
|
|
|
description = "Build a cargo project with alternative crate registries";
|
|
|
|
path = ./examples/alt-registry;
|
|
|
|
};
|
|
|
|
|
2022-02-17 07:50:59 +03:00
|
|
|
cross-musl = {
|
|
|
|
description = "Building static binaries with musl";
|
2022-05-12 00:37:47 +03:00
|
|
|
path = ./examples/cross-musl;
|
2022-02-17 07:50:59 +03:00
|
|
|
};
|
|
|
|
|
2022-02-16 05:42:59 +03:00
|
|
|
cross-rust-overlay = {
|
|
|
|
description = "Cross compiling a rust program using rust-overlay";
|
|
|
|
path = ./examples/cross-rust-overlay;
|
|
|
|
};
|
|
|
|
|
2023-01-07 04:11:42 +03:00
|
|
|
cross-windows = {
|
|
|
|
description = "Cross compiling a rust program for windows";
|
|
|
|
path = ./examples/cross-windows;
|
|
|
|
};
|
|
|
|
|
2022-01-17 03:11:11 +03:00
|
|
|
custom-toolchain = {
|
|
|
|
description = "Build a cargo project with a custom toolchain";
|
|
|
|
path = ./examples/custom-toolchain;
|
|
|
|
};
|
|
|
|
|
2022-06-02 03:09:29 +03:00
|
|
|
default = quick-start;
|
2022-01-17 03:54:55 +03:00
|
|
|
quick-start = {
|
2022-01-17 03:11:11 +03:00
|
|
|
description = "Build a cargo project";
|
2022-01-17 03:54:55 +03:00
|
|
|
path = ./examples/quick-start;
|
|
|
|
};
|
|
|
|
|
|
|
|
quick-start-simple = {
|
|
|
|
description = "Build a cargo project without extra checks";
|
|
|
|
path = ./examples/quick-start-simple;
|
2022-01-17 03:11:11 +03:00
|
|
|
};
|
|
|
|
};
|
2022-04-28 05:59:59 +03:00
|
|
|
} // 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;
|
|
|
|
};
|
|
|
|
|
|
|
|
packages.book =
|
|
|
|
let
|
|
|
|
inherit (pkgs) lib;
|
|
|
|
root = ./.;
|
|
|
|
rootPrefix = toString root;
|
|
|
|
cleanedSrc = lib.cleanSourceWith {
|
|
|
|
src = root;
|
|
|
|
filter = path: type:
|
|
|
|
let
|
|
|
|
relativePath = lib.removePrefix rootPrefix path;
|
|
|
|
in
|
|
|
|
lib.any (prefix: lib.hasPrefix prefix relativePath) [
|
|
|
|
"/docs" # Build the docs directory
|
|
|
|
"/examples" # But also include examples as we cross-reference them
|
|
|
|
"/README.md"
|
|
|
|
"/CHANGELOG.md"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
in
|
|
|
|
pkgs.runCommand "crane-book" { } ''
|
|
|
|
${pkgs.mdbook}/bin/mdbook build --dest-dir $out ${cleanedSrc}/docs
|
|
|
|
'';
|
|
|
|
|
2022-10-19 05:13:38 +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;
|
2022-10-19 05:13:38 +03:00
|
|
|
};
|
|
|
|
|
2021-12-27 03:18:22 +03:00
|
|
|
# To override do: lib.overrideScope' (self: super: { ... });
|
2022-01-16 07:21:02 +03:00
|
|
|
lib = mkLib pkgs;
|
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
|
|
|
|
2022-10-19 05:13:38 +03:00
|
|
|
formatter = pkgs.nixpkgs-fmt;
|
2022-11-21 03:28:49 +03:00
|
|
|
|
2022-06-02 03:09:29 +03:00
|
|
|
devShells.default = pkgs.mkShell {
|
2022-01-04 23:55:36 +03:00
|
|
|
nativeBuildInputs = with pkgs; [
|
2022-05-29 23:26:42 +03:00
|
|
|
jq
|
2022-12-27 01:27:13 +03:00
|
|
|
mdbook
|
2022-01-04 23:55:36 +03:00
|
|
|
nixpkgs-fmt
|
|
|
|
];
|
2021-12-27 02:32:57 +03:00
|
|
|
};
|
|
|
|
});
|
2021-12-26 22:47:16 +03:00
|
|
|
}
|