|
1 | 1 | { |
2 | | - description = "Git repository summary on your terminal"; |
| 2 | + description = '' |
| 3 | + Git repository summary on your terminal |
| 4 | + ''; |
3 | 5 |
|
4 | 6 | inputs = { |
5 | 7 | nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; |
6 | | - |
7 | 8 | crane.url = "github:ipetkov/crane"; |
8 | | - |
9 | 9 | flake-utils.url = "github:numtide/flake-utils"; |
10 | 10 |
|
11 | 11 | advisory-db = { |
|
14 | 14 | }; |
15 | 15 | }; |
16 | 16 |
|
17 | | - outputs = { self, nixpkgs, crane, flake-utils, advisory-db, ... }: |
18 | | - flake-utils.lib.eachDefaultSystem (system: |
| 17 | + outputs = |
| 18 | + { |
| 19 | + self, |
| 20 | + nixpkgs, |
| 21 | + crane, |
| 22 | + flake-utils, |
| 23 | + advisory-db, |
| 24 | + ... |
| 25 | + }: |
| 26 | + flake-utils.lib.eachDefaultSystem ( |
| 27 | + system: |
19 | 28 | let |
20 | 29 | pkgs = nixpkgs.legacyPackages.${system}; |
21 | 30 |
|
|
25 | 34 | src = ./.; |
26 | 35 |
|
27 | 36 | # Common arguments can be set here to avoid repeating them later |
28 | | - commonArgs = { |
| 37 | + common = { |
29 | 38 | inherit src; |
30 | 39 | strictDeps = true; |
31 | 40 |
|
32 | | - buildInputs = with pkgs; |
| 41 | + # Bunch of libraries required for package proper work |
| 42 | + buildInputs = |
| 43 | + with pkgs; |
33 | 44 | [ |
34 | 45 | # package dependencies |
35 | 46 | zstd |
36 | | - ] ++ lib.optionals pkgs.stdenv.isDarwin (with pkgs; [ |
| 47 | + ] |
| 48 | + ++ lib.optionals pkgs.stdenv.isDarwin ( |
| 49 | + with pkgs; |
| 50 | + [ |
37 | 51 | # additional dependencies on Darwin systems |
38 | 52 | CoreFoundation |
39 | 53 | libresolv |
40 | 54 | Security |
41 | | - ]); |
42 | | - nativeBuildInputs = with pkgs; [ cmake pkg-config ]; |
| 55 | + ] |
| 56 | + ); |
| 57 | + # Software required for project build |
| 58 | + nativeBuildInputs = with pkgs; [ |
| 59 | + cmake |
| 60 | + pkg-config |
| 61 | + ]; |
| 62 | + # Tools required for checks |
43 | 63 | nativeCheckInputs = with pkgs; [ git ]; |
44 | 64 |
|
45 | 65 | # Additional environment variables can be set directly |
46 | 66 | # MY_CUSTOM_VAR = "some value"; |
47 | 67 | }; |
48 | 68 |
|
49 | | - # Build *just* the cargo dependencies, so we can reuse |
50 | | - # all of that work (e.g. via cachix) when running in CI |
51 | | - cargoArtifacts = craneLib.buildDepsOnly commonArgs; |
| 69 | + # Build dependencies only, so we will be able to reuse them further |
| 70 | + cargoArtifacts = craneLib.buildDepsOnly common; |
52 | 71 |
|
53 | 72 | # Build the actual crate itself, reusing the dependency |
54 | 73 | # artifacts from above. |
55 | | - onefetch = |
56 | | - craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; }); |
57 | | - in { |
| 74 | + build = craneLib.buildPackage (common // { inherit cargoArtifacts; }); |
| 75 | + in |
| 76 | + { |
58 | 77 | checks = { |
59 | 78 | # Build the crate as part of `nix flake check` for convenience |
60 | | - inherit onefetch; |
| 79 | + inherit build; |
61 | 80 |
|
62 | 81 | # Run clippy (and deny all warnings) on the crate source, |
63 | 82 | # again, reusing the dependency artifacts from above. |
64 | | - # |
65 | | - # Note that this is done as a separate derivation so that |
66 | | - # we can block the CI if there are issues here, but not |
67 | | - # prevent downstream consumers from building our crate by itself. |
68 | | - onefetch-clippy = craneLib.cargoClippy (commonArgs // { |
| 83 | + clippy = craneLib.cargoClippy ( |
| 84 | + common |
| 85 | + // { |
69 | 86 | inherit cargoArtifacts; |
70 | 87 | cargoClippyExtraArgs = "--all-targets -- --deny warnings"; |
71 | | - }); |
| 88 | + } |
| 89 | + ); |
72 | 90 |
|
73 | | - onefetch-doc = |
74 | | - craneLib.cargoDoc (commonArgs // { inherit cargoArtifacts; }); |
| 91 | + doc = craneLib.cargoDoc (common // { inherit cargoArtifacts; }); |
75 | 92 |
|
76 | 93 | # Check formatting |
77 | | - onefetch-fmt = craneLib.cargoFmt { inherit src; }; |
| 94 | + fmt = craneLib.cargoFmt { inherit src; }; |
78 | 95 |
|
79 | | - onefetch-toml-fmt = craneLib.taploFmt { |
| 96 | + tomlFmt = craneLib.taploFmt { |
80 | 97 | src = pkgs.lib.sources.sourceFilesBySuffices src [ ".toml" ]; |
81 | 98 | # taplo arguments can be further customized below as needed |
82 | 99 | # taploExtraArgs = "--config ./taplo.toml"; |
83 | 100 | }; |
84 | 101 |
|
85 | 102 | # Audit dependencies |
86 | | - onefetch-audit = craneLib.cargoAudit { inherit src advisory-db; }; |
| 103 | + audit = craneLib.cargoAudit { inherit src advisory-db; }; |
87 | 104 |
|
88 | 105 | # Audit licenses |
89 | | - onefetch-deny = craneLib.cargoDeny { inherit src; }; |
| 106 | + deny = craneLib.cargoDeny { inherit src; }; |
90 | 107 |
|
91 | 108 | # Run tests with cargo-nextest |
92 | 109 | # Consider setting `doCheck = false` on `my-crate` if you do not want |
93 | 110 | # the tests to run twice |
94 | | - onefetch-nextest = craneLib.cargoNextest (commonArgs // { |
| 111 | + nextest = craneLib.cargoNextest ( |
| 112 | + common |
| 113 | + // { |
95 | 114 | inherit cargoArtifacts; |
96 | 115 | partitions = 1; |
97 | 116 | partitionType = "count"; |
98 | 117 | cargoNextestPartitionsExtraArgs = "--no-tests=pass"; |
99 | | - }); |
| 118 | + } |
| 119 | + ); |
100 | 120 | }; |
101 | 121 |
|
102 | 122 | packages = rec { |
|
110 | 130 | default = onefetch-debug; |
111 | 131 | }; |
112 | 132 |
|
113 | | - apps.default = flake-utils.lib.mkApp { drv = onefetch; }; |
| 133 | + apps.default = flake-utils.lib.mkApp { drv = build; }; |
114 | 134 |
|
115 | 135 | devShells.default = craneLib.devShell { |
116 | 136 | # Inherit inputs from checks. |
|
123 | 143 | packages = with pkgs; [ |
124 | 144 | # pkgs.ripgrep |
125 | 145 | nixd |
126 | | - nixfmt |
| 146 | + nixfmt-rfc-style |
127 | 147 | ]; |
128 | 148 | }; |
129 | | - }); |
| 149 | + } |
| 150 | + ); |
130 | 151 | # Sets substituters to avoid locally building something already built |
131 | 152 | nixConfig = { |
132 | | - extra-substituters = |
133 | | - [ "https://crane.cachix.org" "https://cache.garnix.io" ]; |
| 153 | + extra-substituters = [ |
| 154 | + "https://crane.cachix.org" |
| 155 | + "https://cache.garnix.io" |
| 156 | + ]; |
134 | 157 | extra-trusted-public-keys = [ |
135 | 158 | "crane.cachix.org-1:8Scfpmn9w+hGdXH/Q9tTLiYAE/2dnJYRJP7kl80GuRk=" |
136 | 159 | "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" |
|
0 commit comments