-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
108 lines (103 loc) · 3.12 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
108
{
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
crane.url = "github:ipetkov/crane";
flake-compat.url = "github:edolstra/flake-compat";
flake-compat.flake = false;
};
outputs =
inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } (
{
self,
inputs,
lib,
...
}:
{
systems = [
"x86_64-linux"
"aarch64-linux"
];
imports = [
inputs.flake-parts.flakeModules.easyOverlay
inputs.treefmt-nix.flakeModule
];
flake = {
nixosModules.angrr = ./nixos/module.nix;
};
perSystem =
{
config,
self',
pkgs,
system,
...
}:
let
craneLib = inputs.crane.mkLib pkgs;
src = craneLib.cleanCargoSource (craneLib.path ./.);
bareCommonArgs = {
inherit src;
nativeBuildInputs = with pkgs; [ installShellFiles ];
buildInputs = [ ];
};
cargoArtifacts = craneLib.buildDepsOnly bareCommonArgs;
commonArgs = bareCommonArgs // {
inherit cargoArtifacts;
};
in
{
packages = {
angrr = craneLib.buildPackage (
commonArgs
// {
postInstall = ''
installShellCompletion --cmd angrr \
--bash <($out/bin/angrr completion bash) \
--fish <($out/bin/angrr completion fish) \
--zsh <($out/bin/angrr completion zsh)
'';
}
);
default = config.packages.angrr;
};
overlayAttrs.angrr = config.packages.angrr;
checks = {
inherit (self'.packages) angrr;
doc = craneLib.cargoDoc commonArgs;
fmt = craneLib.cargoFmt { inherit src; };
nextest = craneLib.cargoNextest (
commonArgs
// {
cargoNextestExtraArgs = lib.escapeShellArgs [ "--no-tests=warn" ];
}
);
clippy = craneLib.cargoClippy (
commonArgs // { cargoClippyExtraArgs = "--all-targets -- --deny warnings"; }
);
};
treefmt = {
projectRootFile = "flake.nix";
programs = {
nixfmt.enable = true;
rustfmt.enable = true;
prettier.enable = true;
taplo.enable = true;
};
};
devShells.default = pkgs.mkShell {
inputsFrom = lib.attrValues self'.checks;
packages = with pkgs; [
rustup
rust-analyzer
];
};
};
}
);
}