-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
100 lines (88 loc) · 2.21 KB
/
flake.nix
File metadata and controls
100 lines (88 loc) · 2.21 KB
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
{
inputs = {
nixpkgs.url = "https://flakehub.com/f/DeterminateSystems/nixpkgs-weekly/*";
fenix.url = "https://flakehub.com/f/nix-community/fenix/*";
fenix.inputs = {
nixpkgs.follows = "nixpkgs";
};
crane.url = "https://flakehub.com/f/ipetkov/crane/*";
};
outputs =
{
self,
nixpkgs,
crane,
fenix,
}:
let
inherit (nixpkgs) lib;
systems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-linux"
];
forEachSystem =
f:
lib.genAttrs systems (
system:
let
pkgs = import nixpkgs {
inherit system;
};
toolchain = with fenix.packages.${system}; stable.toolchain;
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
in
f { inherit pkgs craneLib toolchain; }
);
in
{
checks = forEachSystem (
{ pkgs, craneLib, ... }:
let
src = craneLib.cleanCargoSource ./.;
deps = craneLib.buildDepsOnly {
inherit src;
};
in
{
cargo-build = craneLib.cargoBuild {
inherit src;
cargoArtifacts = deps;
};
}
);
devShells = forEachSystem (
{ pkgs, toolchain, ... }:
let
# Helper to run inspect on something (usually a flake in the tests dir)
inspect = pkgs.writeShellScriptBin "inspect" ''
set -euo pipefail
nix eval \
--json \
--no-write-lock-file \
--override-input flake "$1" \
"https://flakehub.com/f/DeterminateSystems/inspect/*#contents.includingOutputPaths"
'';
serve-docs =
let
http-server = lib.getExe pkgs.http-server;
in
pkgs.writeShellScriptBin "serve-docs" ''
set -e
cargo doc
${http-server} target/doc
'';
in
{
default = pkgs.mkShell {
packages = [
inspect
serve-docs
toolchain
pkgs.nixfmt
];
};
}
);
};
}