-
Notifications
You must be signed in to change notification settings - Fork 8
/
flake.nix
105 lines (100 loc) · 3.04 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
{
description = "Lutgen";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
crane,
fenix,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs.lib) optionals;
stableCraneLib = crane.lib.${system};
craneLib = stableCraneLib.overrideToolchain fenix.packages.${system}.complete.toolchain;
src = craneLib.path ./.;
commonArgs = {
inherit src;
strictDeps = true;
buildInputs = [ ] ++ optionals pkgs.stdenv.isDarwin [ pkgs.libiconv ];
nativeBuildInputs = [ pkgs.installShellFiles ];
};
lutgen = stableCraneLib.buildPackage (
commonArgs
// {
doCheck = false;
postInstall = pkgs.lib.optionalString (pkgs.stdenv.buildPlatform.canExecute pkgs.stdenv.hostPlatform) ''
installManPage docs/lutgen.1
installShellCompletion --cmd lutgen \
--bash <($out/bin/lutgen --bpaf-complete-style-bash) \
--fish <($out/bin/lutgen --bpaf-complete-style-fish) \
--zsh <($out/bin/lutgen --bpaf-complete-style-zsh)
'';
}
);
in
{
checks =
let
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
in
{
fmt = craneLib.cargoFmt (commonArgs // { inherit cargoArtifacts; });
doc = craneLib.cargoDoc (
commonArgs
// {
inherit cargoArtifacts;
RUSTFLAGS = "-Dwarnings";
}
);
clippy = craneLib.cargoClippy (
commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets --all-features -- -Dclippy::all -Dwarnings";
}
);
nextest = craneLib.cargoNextest (
commonArgs
// {
inherit cargoArtifacts;
cargoNextestExtraArgs = "--all-targets --all-features --all";
}
);
doctest = craneLib.cargoTest (
commonArgs
// {
inherit cargoArtifacts;
cargoTextExtraArgs = "--doc";
}
);
};
packages = {
inherit lutgen;
default = lutgen;
};
apps.default = flake-utils.lib.mkApp { drv = lutgen; };
devShells.default = craneLib.devShell { checks = self.checks.${system}; };
formatter = pkgs.nixfmt-rfc-style;
}
)
// {
overlays.default = _: prev: { lutgen = self.packages.${prev.system}.default; };
};
}