-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
97 lines (90 loc) · 2.62 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
{
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
flake-utils.inputs.systems.follows = "systems";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
crane.url = "github:ipetkov/crane";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
systems.url = "github:nix-systems/default";
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;}
({
config,
self,
inputs,
lib,
getSystem,
...
}: {
systems = import inputs.systems;
imports = [
inputs.flake-parts.flakeModules.easyOverlay
inputs.treefmt-nix.flakeModule
];
flake = {
nixosModules.commit-notifier = ./nixos/commit-notifier.nix;
};
perSystem = {
config,
self',
pkgs,
system,
...
}: let
craneLib = inputs.crane.mkLib pkgs;
src = craneLib.cleanCargoSource (craneLib.path ./.);
bareCommonArgs = {
inherit src;
nativeBuildInputs = with pkgs; [
pkg-config
];
buildInputs = with pkgs; [
sqlite
libgit2
openssl
];
};
cargoArtifacts = craneLib.buildDepsOnly bareCommonArgs;
commonArgs = bareCommonArgs // {inherit cargoArtifacts;};
in {
packages = {
commit-notifier = craneLib.buildPackage commonArgs;
default = config.packages.commit-notifier;
};
overlayAttrs = {
inherit (config.packages) commit-notifier;
};
checks = {
inherit (self'.packages) commit-notifier;
doc = craneLib.cargoDoc commonArgs;
fmt = craneLib.cargoFmt {inherit src;};
nextest = craneLib.cargoNextest commonArgs;
clippy = craneLib.cargoClippy (commonArgs
// {
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});
};
treefmt = {
projectRootFile = "flake.nix";
programs = {
alejandra.enable = true;
rustfmt.enable = true;
shfmt.enable = true;
};
};
devShells.default = pkgs.mkShell {
inputsFrom = lib.attrValues self'.checks;
packages = with pkgs; [
rustup
rust-analyzer
];
};
};
});
}