-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
140 lines (112 loc) · 3.88 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
{
description = "kvsd";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};
};
outputs = { self, nixpkgs, fenix, crane, flake-utils, advisory-db, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ fenix.overlays.default ];
pkgs = import nixpkgs { inherit system overlays; };
rustToolchain = fenix.packages.${system}.fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-3jVIIf5XPnUU1CRaTyAiO0XHVbJl12MSx3eucTXCjtE=";
};
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
src = pkgs.lib.cleanSourceWith {
src = ./.; # The original, unfiltered source
filter = path: type:
# Default filter from crane (allow .rs files)
(craneLib.filterCargoSources path type);
};
darwinDeps = [
pkgs.libiconv
pkgs.darwin.apple_sdk.frameworks.Security
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration
];
commonArgs = {
inherit src;
strictDeps = true;
pname = "kvsd-deps";
version = "0.1";
buildInputs = [ ]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin darwinDeps;
CARGO_PROFILE = "dev";
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
kvsdCrate =
craneLib.crateNameFromCargoToml { cargoToml = ./Cargo.toml; };
kvsd = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
inherit (kvsdCrate) pname version;
doCheck = false;
CARGO_PROFILE = "release";
});
checks = {
inherit kvsd;
clippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "-- --deny warnings";
});
nextest = craneLib.cargoNextest (commonArgs // {
inherit cargoArtifacts;
cargoExtraArgs = "--no-capture";
});
audit = craneLib.cargoAudit {
inherit src advisory-db;
cargoAuditExtraArgs = let
ignoreAdvisories = pkgs.lib.concatStrings
(pkgs.lib.strings.intersperse " " (map (x: "--ignore ${x}")
(builtins.fromTOML
(builtins.readFile .cargo/audit.toml)).advisories.ignore));
in "${ignoreAdvisories}";
};
fmt = craneLib.cargoFmt commonArgs;
};
ci_packages = with pkgs; [
just
nushell # just set nu as shell
typos
];
# Inherits from checks cargo-nextest, cargo-audit
dev_packages = with pkgs;
[ git-cliff cargo-release oranda ] ++ ci_packages
## For cargo-release build
++ pkgs.lib.optionals pkgs.stdenv.isDarwin darwinDeps;
in {
inherit checks;
packages.default = self.packages."${system}".kvsd;
packages.kvsd = kvsd;
apps.default = flake-utils.lib.mkApp {
drv = kvsd;
name = "kvsd";
};
devShells.default = craneLib.devShell {
# Inherit inputs from checks
checks = self.checks.${system};
packages = dev_packages;
shellHook = ''
exec nu
'';
};
devShells.ci = craneLib.devShell { packages = ci_packages; };
});
nixConfig = {
extra-substituters = [ "https://kvsd.cachix.org" ];
extra-trusted-public-keys =
[ "kvsd.cachix.org-1:d4Vo1Qh1YC2H0kzCNapMJlP50J3JAydbP9cA+phQf/k=" ];
};
}