-
Notifications
You must be signed in to change notification settings - Fork 5
/
flake.nix
107 lines (92 loc) · 3.01 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
{
description = "ndc-spec";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs";
crane.url = "github:ipetkov/crane";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
};
outputs =
{ self
, flake-utils
, nixpkgs
, crane
, rust-overlay
}:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
buildDependencies =
[
pkgs.openssl
pkgs.pkg-config
];
runtimeDependencies =
pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.CoreFoundation
pkgs.darwin.apple_sdk.frameworks.Security
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration
pkgs.libiconv
];
buildArgs = {
pname = "ndc-spec";
src =
let
isCsvFile = path: _type: builtins.match ".*\\.csv$" path != null;
isJsonFile = path: _type: builtins.match ".*\\.json$" path != null;
isJsonLinesFile = path: _type: builtins.match ".*\\.jsonl$" path != null;
isJsonSchemaFile = path: _type: builtins.match ".*\\.jsonschema$" path != null;
isSnapshotFile = path: _type: builtins.match ".*\\.snap$" path != null;
isSourceFile = path: type:
isCsvFile path type
|| isJsonFile path type
|| isJsonLinesFile path type
|| isJsonSchemaFile path type
|| isSnapshotFile path type
|| craneLib.filterCargoSources path type;
in
pkgs.lib.cleanSourceWith { src = craneLib.path ./.; filter = isSourceFile; };
nativeBuildInputs = buildDependencies;
buildInputs = runtimeDependencies;
};
in
{
packages.cargo-artifacts = craneLib.buildDepsOnly buildArgs;
packages.default = craneLib.buildPackage (buildArgs // {
cargoArtifacts = self.packages.${system}.cargo-artifacts;
});
apps.ndc-reference = flake-utils.lib.mkApp {
drv = self.packages.${system}.default;
exePath = "/bin/ndc-reference";
};
apps.ndc-test = flake-utils.lib.mkApp {
drv = self.packages.${system}.default;
exePath = "/bin/ndc-test";
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = [
pkgs.cargo-edit
pkgs.cargo-machete
pkgs.cargo-nextest
pkgs.cargo-watch
rustToolchain
pkgs.just
pkgs.mdbook
pkgs.mdbook-pagetoc
pkgs.nodePackages.prettier
] ++ buildDependencies;
buildInputs = runtimeDependencies;
};
formatter = pkgs.nixpkgs-fmt;
});
}