forked from ipetkov/crane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
95 lines (81 loc) · 2.31 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
{
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";
};
};
};
outputs = { nixpkgs, flake-utils, rust-overlay, ... }:
let
mkLib = pkgs: import ./lib {
inherit (pkgs) lib newScope;
};
in
{
inherit mkLib;
overlays.default = _final: _prev: { };
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";
path = ./examples/cross-musl;
};
cross-rust-overlay = {
description = "Cross compiling a rust program using rust-overlay";
path = ./examples/cross-rust-overlay;
};
custom-toolchain = {
description = "Build a cargo project with a custom toolchain";
path = ./examples/custom-toolchain;
};
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;
};
};
} // flake-utils.lib.eachDefaultSystem (system:
let
checks =
let
pkgsChecks = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
in
pkgsChecks.callPackages ./checks {
pkgs = pkgsChecks;
myLib = mkLib pkgsChecks;
};
pkgs = import nixpkgs {
inherit system;
};
# To override do: lib.overrideScope' (self: super: { ... });
lib = mkLib pkgs;
in
{
inherit checks lib;
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
jq
nixpkgs-fmt
];
};
});
}