forked from eza-community/powertest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
106 lines (90 loc) · 2.85 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
{
description = "powertest: powerfull trycmd test generator (as seen on eza)";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
treefmt-nix.url = "github:numtide/treefmt-nix";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = {
self,
flake-utils,
naersk,
nixpkgs,
treefmt-nix,
rust-overlay,
}:
flake-utils.lib.eachDefaultSystem (
system: let
overlays = [(import rust-overlay)];
pkgs = (import nixpkgs) {
inherit system overlays;
};
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
naersk' = pkgs.callPackage naersk {
cargo = toolchain;
rustc = toolchain;
clippy = toolchain;
};
treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
buildInputs = with pkgs; lib.optionals stdenv.isDarwin [libiconv darwin.apple_sdk.frameworks.Security];
in rec {
# For `nix fmt`
formatter = treefmtEval.config.build.wrapper;
packages = {
# For `nix build` & `nix run`:
default = naersk'.buildPackage {
src = ./.;
doCheck = true; # run `cargo test` on build
copyBins = true;
copyLibs = true;
singleStep = true;
inherit buildInputs;
nativeBuildInputs = with pkgs; [makeWrapper installShellFiles];
MAN_OUT = "./man";
preBuild = ''
mkdir -p "./$MAN_OUT";
'';
preInstall = ''
installManPage man/powertest.1
installShellCompletion \
--fish man/powertest.fish \
--bash man/powertest.bash \
--zsh man/_powertest
mkdir -p $out
'';
};
# Run `nix build .#check` to check code
check = naersk'.buildPackage {
src = ./.;
mode = "check";
inherit buildInputs;
};
# Run `nix build .#test` to run tests
test = naersk'.buildPackage {
src = ./.;
mode = "test";
inherit buildInputs;
};
# Run `nix build .#clippy` to lint code
clippy = naersk'.buildPackage {
src = ./.;
mode = "clippy";
inherit buildInputs;
};
};
# For `nix develop`:
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [rustup toolchain just zip];
};
# for `nix flake check`
checks = {
formatting = treefmtEval.config.build.check self;
build = packages.check;
test = packages.test;
lint = packages.clippy;
};
}
);
}