-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
93 lines (92 loc) · 2.87 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
{
description = "VESA Monitor Control Command Set";
inputs = {
flakelib.url = "github:flakelib/fl";
nixpkgs = { };
rust = {
url = "github:arcnmx/nixexprs-rust";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, flakelib, nixpkgs, rust, ... }@inputs: let
nixlib = nixpkgs.lib;
in flakelib {
inherit inputs;
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
devShells = {
plain = {
mkShell
, enableRust ? true, cargo
, rustTools ? [ ]
, generate
}: mkShell {
inherit rustTools;
nativeBuildInputs = nixlib.optional enableRust cargo ++ [
generate
];
};
stable = { rust'stable, outputs'devShells'plain }: outputs'devShells'plain.override {
inherit (rust'stable) mkShell;
enableRust = false;
};
dev = { rust'unstable, outputs'devShells'plain }: outputs'devShells'plain.override {
inherit (rust'unstable) mkShell;
enableRust = false;
rustTools = [ "rust-analyzer" ];
};
default = { outputs'devShells }: outputs'devShells.plain;
};
checks = {
rustfmt = { rust'builders, source }: rust'builders.check-rustfmt-unstable {
src = source;
config = ./.rustfmt.toml;
};
versions = { rust'builders, source }: rust'builders.check-contents {
src = source;
patterns = [
{ path = "src/lib.rs"; docs'rs = {
inherit (self.lib.crate) name version;
}; }
{ path = "caps/src/lib.rs"; docs'rs = {
inherit (self.lib.crate.members.caps) name version;
}; }
{ path = "db/src/lib.rs"; docs'rs = {
inherit (self.lib.crate.members.db) name version;
}; }
];
};
test = { rustPlatform, source }: rustPlatform.buildRustPackage rec {
pname = self.lib.crate.package.name;
inherit (self.lib.crate) cargoLock version;
src = source;
cargoBuildFlags = [ "--workspace" ];
cargoTestFlags = cargoBuildFlags;
buildType = "debug";
meta.name = "cargo test";
};
};
legacyPackages = { callPackageSet }: callPackageSet {
source = { rust'builders }: rust'builders.wrapSource self.lib.crate.src;
generate = { rust'builders, outputHashes }: rust'builders.generateFiles {
paths = {
"lock.nix" = outputHashes;
};
};
outputHashes = { rust'builders }: rust'builders.cargoOutputHashes {
inherit (self.lib) crate;
};
} { };
lib = with nixlib; {
crate = rust.lib.importCargo {
inherit self;
path = ./Cargo.toml;
inherit (import ./lock.nix) outputHashes;
};
inherit (self.lib.crate.package) version;
};
config = rec {
name = "mccs-rs";
packages.namespace = [ name ];
};
};
}