-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
flake.nix
150 lines (134 loc) · 3.93 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
141
142
143
144
145
146
147
148
149
150
{
description = "linkleaner";
inputs.nixpkgs.url = "github:msfjarvis/nixpkgs/nixpkgs-unstable";
inputs.systems.url = "github:msfjarvis/flake-systems";
inputs.advisory-db.url = "github:rustsec/advisory-db";
inputs.advisory-db.flake = false;
inputs.crane.url = "github:ipetkov/crane";
inputs.devshell.url = "github:numtide/devshell";
inputs.devshell.inputs.nixpkgs.follows = "nixpkgs";
inputs.fenix.url = "github:nix-community/fenix";
inputs.fenix.inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.flake-utils.inputs.systems.follows = "systems";
inputs.flake-compat.url = "github:nix-community/flake-compat";
inputs.flake-compat.flake = false;
outputs =
{
nixpkgs,
advisory-db,
crane,
devshell,
fenix,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ devshell.overlays.default ];
};
rustNightly = (import fenix { inherit pkgs; }).fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-XPGNBesOSwZJCXgynlavqa5QdsTAnodTmbx6t6XUWsY=";
};
craneLib = (crane.mkLib pkgs).overrideToolchain rustNightly;
commonArgs = {
src = craneLib.cleanCargoSource ./.;
buildInputs = [ ];
nativeBuildInputs = [ ];
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
linkleaner-fmt = craneLib.cargoFmt (
commonArgs
// {
inherit cargoArtifacts;
}
);
linkleaner-clippy = craneLib.cargoClippy (
commonArgs
// {
inherit cargoArtifacts;
}
);
linkleaner = craneLib.buildPackage (
commonArgs
// {
inherit cargoArtifacts;
doCheck = false;
}
);
linkleaner-nextest = craneLib.cargoNextest (
commonArgs
// {
cargoArtifacts = linkleaner;
partitions = 1;
partitionType = "count";
}
);
linkleaner-audit = craneLib.cargoAudit (
commonArgs
// {
inherit advisory-db cargoArtifacts;
}
);
in
{
checks = {
inherit
linkleaner
linkleaner-audit
linkleaner-clippy
linkleaner-fmt
linkleaner-nextest
;
};
# Expose the flyctl and skopeo packages for use in CI
packages = { inherit (pkgs) flyctl skopeo; };
packages.default = linkleaner;
packages.container = pkgs.dockerTools.buildImage {
name = "registry.fly.io/linkleaner";
tag = "latest";
created = "now";
copyToRoot = pkgs.buildEnv {
name = "linkleaner";
paths = [ linkleaner ];
pathsToLink = [ "/bin" ];
};
config.Cmd = [ "${linkleaner}/bin/linkleaner" ];
};
packages.ghContainer = pkgs.dockerTools.buildLayeredImage {
name = "ghcr.io/msfjarvis/linkleaner";
tag = "latest";
created = "now";
config.Cmd = [ "${linkleaner}/bin/linkleaner" ];
};
apps.default = flake-utils.lib.mkApp { drv = linkleaner; };
devShells.default = pkgs.devshell.mkShell {
bash = {
interactive = "";
};
env = [
{
name = "DEVSHELL_NO_MOTD";
value = 1;
}
];
packages = with pkgs; [
bacon
cargo-nextest
cargo-release
fenix.packages.${system}.rust-analyzer
flyctl
nil
rustNightly
skopeo
stdenv.cc
];
};
}
);
}