Skip to content

Commit 7d29e15

Browse files
committed
flake: fmt, comments, renames
1 parent b7d3fe6 commit 7d29e15

File tree

1 file changed

+59
-36
lines changed

1 file changed

+59
-36
lines changed

flake.nix

Lines changed: 59 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
description = "Git repository summary on your terminal";
2+
description = ''
3+
Git repository summary on your terminal
4+
'';
35

46
inputs = {
57
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
6-
78
crane.url = "github:ipetkov/crane";
8-
99
flake-utils.url = "github:numtide/flake-utils";
1010

1111
advisory-db = {
@@ -14,8 +14,17 @@
1414
};
1515
};
1616

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:
1928
let
2029
pkgs = nixpkgs.legacyPackages.${system};
2130

@@ -25,78 +34,89 @@
2534
src = ./.;
2635

2736
# Common arguments can be set here to avoid repeating them later
28-
commonArgs = {
37+
common = {
2938
inherit src;
3039
strictDeps = true;
3140

32-
buildInputs = with pkgs;
41+
# Bunch of libraries required for package proper work
42+
buildInputs =
43+
with pkgs;
3344
[
3445
# package dependencies
3546
zstd
36-
] ++ lib.optionals pkgs.stdenv.isDarwin (with pkgs; [
47+
]
48+
++ lib.optionals pkgs.stdenv.isDarwin (
49+
with pkgs;
50+
[
3751
# additional dependencies on Darwin systems
3852
CoreFoundation
3953
libresolv
4054
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
4363
nativeCheckInputs = with pkgs; [ git ];
4464

4565
# Additional environment variables can be set directly
4666
# MY_CUSTOM_VAR = "some value";
4767
};
4868

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;
5271

5372
# Build the actual crate itself, reusing the dependency
5473
# artifacts from above.
55-
onefetch =
56-
craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; });
57-
in {
74+
build = craneLib.buildPackage (common // { inherit cargoArtifacts; });
75+
in
76+
{
5877
checks = {
5978
# Build the crate as part of `nix flake check` for convenience
60-
inherit onefetch;
79+
inherit build;
6180

6281
# Run clippy (and deny all warnings) on the crate source,
6382
# 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+
// {
6986
inherit cargoArtifacts;
7087
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
71-
});
88+
}
89+
);
7290

73-
onefetch-doc =
74-
craneLib.cargoDoc (commonArgs // { inherit cargoArtifacts; });
91+
doc = craneLib.cargoDoc (common // { inherit cargoArtifacts; });
7592

7693
# Check formatting
77-
onefetch-fmt = craneLib.cargoFmt { inherit src; };
94+
fmt = craneLib.cargoFmt { inherit src; };
7895

79-
onefetch-toml-fmt = craneLib.taploFmt {
96+
tomlFmt = craneLib.taploFmt {
8097
src = pkgs.lib.sources.sourceFilesBySuffices src [ ".toml" ];
8198
# taplo arguments can be further customized below as needed
8299
# taploExtraArgs = "--config ./taplo.toml";
83100
};
84101

85102
# Audit dependencies
86-
onefetch-audit = craneLib.cargoAudit { inherit src advisory-db; };
103+
audit = craneLib.cargoAudit { inherit src advisory-db; };
87104

88105
# Audit licenses
89-
onefetch-deny = craneLib.cargoDeny { inherit src; };
106+
deny = craneLib.cargoDeny { inherit src; };
90107

91108
# Run tests with cargo-nextest
92109
# Consider setting `doCheck = false` on `my-crate` if you do not want
93110
# the tests to run twice
94-
onefetch-nextest = craneLib.cargoNextest (commonArgs // {
111+
nextest = craneLib.cargoNextest (
112+
common
113+
// {
95114
inherit cargoArtifacts;
96115
partitions = 1;
97116
partitionType = "count";
98117
cargoNextestPartitionsExtraArgs = "--no-tests=pass";
99-
});
118+
}
119+
);
100120
};
101121

102122
packages = rec {
@@ -110,7 +130,7 @@
110130
default = onefetch-debug;
111131
};
112132

113-
apps.default = flake-utils.lib.mkApp { drv = onefetch; };
133+
apps.default = flake-utils.lib.mkApp { drv = build; };
114134

115135
devShells.default = craneLib.devShell {
116136
# Inherit inputs from checks.
@@ -123,14 +143,17 @@
123143
packages = with pkgs; [
124144
# pkgs.ripgrep
125145
nixd
126-
nixfmt
146+
nixfmt-rfc-style
127147
];
128148
};
129-
});
149+
}
150+
);
130151
# Sets substituters to avoid locally building something already built
131152
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+
];
134157
extra-trusted-public-keys = [
135158
"crane.cachix.org-1:8Scfpmn9w+hGdXH/Q9tTLiYAE/2dnJYRJP7kl80GuRk="
136159
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="

0 commit comments

Comments
 (0)