-
Notifications
You must be signed in to change notification settings - Fork 21
/
flake.nix
138 lines (123 loc) · 4.35 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
mk-naked-shell = {
url = "github:yusdacra/mk-naked-shell";
flake = false;
};
treefmt = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
crane = {
url = "github:ipetkov/crane/v0.19.0";
flake = false;
};
dream2nix = {
url = "github:nix-community/dream2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {parts, ...} @ inp: let
l = inp.nixpkgs.lib // builtins;
flakeModule = {
imports = [./src/default.nix];
config = {
nci._inputs = {
inherit (inp) crane dream2nix rust-overlay;
};
};
};
in
parts.lib.mkFlake {inputs = inp;} {
imports = [
inp.treefmt.flakeModule
flakeModule
./examples/simple-crate/crates.nix
./examples/customize-profiles/crates.nix
./examples/simple-workspace/crates.nix
];
systems = ["x86_64-linux"];
flake = {
inherit flakeModule;
templates = {
default = inp.self.templates.simple;
simple = {
description = "A simple flake.nix template for getting started";
path = ./examples/simple;
welcomeText = ''
To get started:
1. edit the project `path` in `flake.nix` to point to your project.
2. change `my-crate` crate name to your own crate name.
3. (optionally) add any other crate (or project) you want to configure.
You're set!
'';
};
simple-crate = {
description = "A simple template with a Cargo crate pre-initialized";
path = ./examples/simple-crate;
welcomeText = ''
To get started, edit crate name in `flake.nix` and `Cargo.toml` to your liking.
And you should be good to go!
'';
};
simple-workspace = {
description = "A simple template with a Cargo workspace pre-initialized";
path = ./examples/simple-workspace;
welcomeText = ''
To get started:
1. edit crate names in `flake.nix` and `Cargo.toml`s to your liking,
2. edit project name in `flake.nix`
You're set!
'';
};
cross-compile-wasm = {
description = "An example showcasing WASM cross-compilation";
path = ./examples/cross-compile-wasm;
};
cross-compile-aarch64 = {
description = "An example showcasing aarch64 cross-compilation";
path = ./examples/cross-compile-aarch64;
};
cross-compile-windows = {
description = "An example showcasing windows cross-compilation";
path = ./examples/cross-compile-windows;
};
numtide-devshell = {
description = "Example showcasing using a numtide devshell instead of NCI's own";
path = ./examples/numtide-devshell;
};
};
};
perSystem = {config, ...}: let
profilesOut = config.nci.outputs."customize-profiles";
simpleOut = config.nci.outputs."my-crate";
workspaceOut = config.nci.outputs."my-project";
workspaceCrateOut = config.nci.outputs."my-workspace-crate";
otherWorkspaceCrateOut = config.nci.outputs."my-other-workspace-crate";
in {
treefmt = {
projectRootFile = "flake.nix";
programs.alejandra.enable = true;
};
nci.projects."simple".export = false;
nci.projects."profiles".export = false;
nci.projects."my-project".export = l.mkForce false;
checks."simple-test" = simpleOut.check;
checks."simple-clippy" = simpleOut.clippy;
checks."simple-devshell" = simpleOut.devShell;
checks."simple-workspace-test" = workspaceCrateOut.check;
checks."simple-workspace-test-other" = otherWorkspaceCrateOut.check;
checks."simple-workspace-devshell" = workspaceOut.devShell;
checks."profiles-test" = profilesOut.packages.release;
};
};
}